事件处理
This commit is contained in:
parent
a621f8b495
commit
ef8176943b
@ -45,14 +45,26 @@ func (this *apiComp) Event(session comm.IUserSession, req *pb.StonehengeEventReq
|
||||
}
|
||||
return
|
||||
}
|
||||
if v, ok := stone.Rooms.Eventid[req.Eventid]; !ok || v == true { // 不存在该事件
|
||||
if eventConf, err = this.module.configure.GetStoneEventDataById(req.Eventid); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("req.Eventid err :%d", req.Eventid),
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// EventType29 特殊事件
|
||||
if eventConf.EventType != EventType29 {
|
||||
if v, ok := stone.Rooms.Eventid[req.Eventid]; !ok || v == true { // 不存在该事件
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: fmt.Sprintf("req.Eventid err :%d", req.Eventid),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
_, bBox := stone.Rooms.Box[req.Eventid]
|
||||
if stone.Rooms.Eventid[req.Eventid] || bBox { // 重复完成
|
||||
errdata = &pb.ErrorData{
|
||||
@ -71,14 +83,7 @@ func (this *apiComp) Event(session comm.IUserSession, req *pb.StonehengeEventReq
|
||||
}
|
||||
return
|
||||
}
|
||||
if eventConf, err = this.module.configure.GetStoneEventDataById(req.Eventid); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if len(eventConf.CostItem) > 0 {
|
||||
if errdata = this.module.CheckRes(session, eventConf.CostItem); errdata != nil {
|
||||
return
|
||||
|
@ -134,6 +134,25 @@ func (this *apiComp) GotoRoom(session comm.IUserSession, req *pb.StonehengeGotoR
|
||||
stone.Rooms.Portal = []int32{c.PortalGroup}
|
||||
}
|
||||
}
|
||||
// 判断传送门是否开启
|
||||
stone.Rooms.Complete = true
|
||||
|
||||
for _, v := range curRoomConf.Condition {
|
||||
for k, ok := range stone.Rooms.Eventid {
|
||||
if !ok {
|
||||
if eventConf, err := this.module.configure.GetStoneEventDataById(k); err == nil {
|
||||
if eventConf.EventType == v {
|
||||
stone.Rooms.Complete = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !stone.Rooms.Complete {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
update["rooms"] = stone.Rooms
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
session.SendMsg(string(this.module.GetType()), "gotoroom", &pb.StonehengeGotoRoomResp{
|
||||
|
@ -57,13 +57,13 @@ func (this *apiComp) Store(session comm.IUserSession, req *pb.StonehengeStoreReq
|
||||
return
|
||||
}
|
||||
// 校验 是否有这个事件
|
||||
if _, ok := stone.Rooms.Eventid[storeConf.EventId]; ok {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_StonehengeCantBuy,
|
||||
Title: pb.ErrorCode_StonehengeCantBuy.String(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// if _, ok := stone.Rooms.Eventid[storeConf.EventId]; ok {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_StonehengeCantBuy,
|
||||
// Title: pb.ErrorCode_StonehengeCantBuy.String(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
stone.Rooms.Shop[storeConf.EventId] += 1
|
||||
|
||||
stone.Rooms.Eventid[storeConf.EventId] = false
|
||||
|
@ -52,6 +52,16 @@ func (this *apiComp) Story(session comm.IUserSession, req *pb.StonehengeStoryReq
|
||||
if req.Cid == -1 {
|
||||
stone.Rooms.Story = 0
|
||||
stone.Rooms.Eventid[req.Eventid] = true
|
||||
|
||||
this.module.modelStonehenge.EventOpenRoom(req.Eventid, stone)
|
||||
update["rooms"] = stone.Rooms
|
||||
this.module.modelStonehenge.ChangeStonehengeData(session.GetUserId(), update)
|
||||
session.SendMsg(string(this.module.GetType()), "story", &pb.StonehengeStoryResp{
|
||||
Story: stone.Rooms.Story,
|
||||
NewEvent: newEvent,
|
||||
Room: stone.Rooms,
|
||||
})
|
||||
return
|
||||
} else {
|
||||
if conf, err = this.module.configure.GetStoneStoryConf(req.Cid); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
|
@ -132,5 +132,22 @@ func (this *MStonehenge) AddNewEvent(event []int32, stone *pb.DBStonehenge) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 完成事件 开启传送门
|
||||
func (this *MStonehenge) EventOpenRoom(event int32, stone *pb.DBStonehenge) {
|
||||
stone.Rooms.Complete = true
|
||||
if curRoomConf, err := this.module.configure.GetStoneRoomDataById(stone.Rooms.Roomid); err == nil {
|
||||
for _, v := range curRoomConf.Condition {
|
||||
if eventConf, err := this.module.configure.GetStoneEventDataById(event); err == nil {
|
||||
if eventConf.EventType == v {
|
||||
stone.Rooms.Complete = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if !stone.Rooms.Complete {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user