83 lines
2.2 KiB
Go
83 lines
2.2 KiB
Go
package caravan
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) GetStoryCheck(session comm.IUserSession, req *pb.CaravanGetStoryReq) (errdata *pb.ErrorData) {
|
|
if req.Cid == 0 || req.Citystory == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStoryReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
resp *pb.CaravanGetStoryResp
|
|
update map[string]interface{}
|
|
bAccept bool
|
|
)
|
|
resp = &pb.CaravanGetStoryResp{}
|
|
update = make(map[string]interface{})
|
|
if errdata = this.GetStoryCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
list, _ := this.module.modelCaravan.getCaravanList(session.GetUserId())
|
|
|
|
conf, err := this.module.configure.GetCaravanEventById(req.Cid)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if list.Eventid != req.Cid {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
if req.Citystory == conf.Citynormal { //接受剧情
|
|
|
|
module, err := this.service.GetModule(comm.ModuleWorldtask)
|
|
if err != nil {
|
|
return
|
|
}
|
|
if wt, ok := module.(comm.IWorldtask); ok {
|
|
list.Taskid = wt.GetWorldTaskBy(session, conf.Worldtask)
|
|
if list.Taskid != 0 { // 任务接取成功
|
|
bAccept = true
|
|
list.Eventid = req.Citystory
|
|
list.Taskid = conf.Worldtask
|
|
list.Tasktime = configure.Now().Unix()
|
|
update["eventid"] = list.Eventid
|
|
update["task"] = list.Taskid
|
|
update["tasktime"] = list.Tasktime
|
|
}
|
|
}
|
|
}
|
|
if !bAccept { // 拒绝剧情 重置
|
|
list.Eventid = 0
|
|
list.Taskid = 0
|
|
list.Tasktime = 0
|
|
update["eventid"] = list.Eventid
|
|
update["task"] = list.Taskid
|
|
update["tasktime"] = list.Tasktime
|
|
}
|
|
this.configure.GetAllEquipmentConfigure()
|
|
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)
|
|
|
|
resp.Data = list
|
|
session.SendMsg(string(this.module.GetType()), "getstory", resp)
|
|
return
|
|
}
|