This commit is contained in:
meixiongfeng 2023-05-17 10:27:05 +08:00
parent bb6ba7f9db
commit 5b5d24041d
3 changed files with 67 additions and 45 deletions

View File

@ -18,6 +18,7 @@ func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStory
var ( var (
resp *pb.CaravanGetStoryResp resp *pb.CaravanGetStoryResp
update map[string]interface{} update map[string]interface{}
bAccept bool
) )
update = make(map[string]interface{}) update = make(map[string]interface{})
if code = this.GetStoryCheck(session, req); code != pb.ErrorCode_Success { if code = this.GetStoryCheck(session, req); code != pb.ErrorCode_Success {
@ -39,20 +40,31 @@ func (this *apiComp) GetStory(session comm.IUserSession, req *pb.CaravanGetStory
return return
} }
if req.Citystory == conf.Citynormal { //接受剧情 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.GetUserId(), conf.Worldtask)
if list.Taskid != 0 { // 任务接取成功
bAccept = true
list.Eventid = req.Citystory list.Eventid = req.Citystory
list.Task = conf.Worldtask list.Taskid = conf.Worldtask
list.Tasktime = configure.Now().Unix() list.Tasktime = configure.Now().Unix()
update["eventid"] = list.Eventid update["eventid"] = list.Eventid
update["task"] = list.Task update["task"] = list.Taskid
update["tasktime"] = list.Tasktime update["tasktime"] = list.Tasktime
}
} else { // 拒绝剧情 重置 }
}
if !bAccept { // 拒绝剧情 重置
list.Eventid = 0 list.Eventid = 0
list.Task = 0 list.Taskid = 0
list.Tasktime = 0 list.Tasktime = 0
update["eventid"] = list.Eventid update["eventid"] = list.Eventid
update["task"] = list.Task update["task"] = list.Taskid
update["tasktime"] = list.Tasktime update["tasktime"] = list.Tasktime
} }
this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update) this.module.modelCaravan.modifyCaravanDataByObjId(session.GetUserId(), update)

View File

@ -17,6 +17,7 @@ type Caravan struct {
modelCaravan *modelCaravan modelCaravan *modelCaravan
api *apiComp api *apiComp
configure *configureComp configure *configureComp
service core.IService
} }
func NewModule() core.IModule { func NewModule() core.IModule {
@ -29,7 +30,7 @@ func (this *Caravan) GetType() core.M_Modules {
func (this *Caravan) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Caravan) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service
return return
} }
@ -219,24 +220,32 @@ func (this *Caravan) refreshCaravanItemInfo(uid string, data *pb.DBCaravan) {
// 校验随机事件是否超时 // 校验随机事件是否超时
func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCaravan) { func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCaravan) {
if data.Eventid != 0 { if data.Eventid != 0 {
if even := this.configure.GetCaravanEventById(data.Eventid); even != nil { if list := this.configure.GetCaravanEventById(data.Eventid); list != nil {
// 校验任务是否超时 // 校验任务是否超时
if data.Tasktime-configure.Now().Unix() > int64(even.Eventtime) { //TODO 任务超时 通知任务模块处理 并清理相关数据 if data.Tasktime-configure.Now().Unix() > int64(list.Eventtime) { //TODO 任务超时 通知任务模块处理 并清理相关数据
module, err := this.service.GetModule(comm.ModuleWorldtask)
if err != nil {
return
}
if wt, ok := module.(comm.IWorldtask); ok {
wt.UpdateTaskStatus(session.GetUserId(), data.Taskid) // 通知任务模块 任务超时
}
this.CleanCaravanTask(session.GetUserId(), data) //任务超时 清理任务数据 this.CleanCaravanTask(session.GetUserId(), data) //任务超时 清理任务数据
// 任务超时发送任务失败推送 // 任务超时发送任务失败推送
resp := &pb.CaravanTaskCompletePush{} resp := &pb.CaravanTaskCompletePush{}
resp.Data = data resp.Data = data
resp.BSuccess = false resp.BSuccess = false
if len(even.Unreword) == 2 && even.Unreword[0] == 1 { if len(list.Unreword) == 2 && list.Unreword[0] == 1 { // 类型为1 的 直接扣除虚拟币
this.ConsumeRes(session, []*cfg.Gameatn{{ this.ConsumeRes(session, []*cfg.Gameatn{{
A: "attr", A: "attr",
T: "merchantmoney", T: "merchantmoney",
N: even.Unreword[1], N: list.Unreword[1],
}}, true) }}, true)
resp.Reward = append(resp.Reward, &pb.UserAssets{ resp.Reward = append(resp.Reward, &pb.UserAssets{
A: "attr", A: "attr",
T: "merchantmoney", T: "merchantmoney",
N: -even.Unreword[1], N: -list.Unreword[1], // 扣除虚拟币
}) })
} }
session.SendMsg(string(this.GetType()), "taskcomplete", resp) session.SendMsg(string(this.GetType()), "taskcomplete", resp)
@ -247,18 +256,18 @@ func (this *Caravan) CheckCaravanTask(session comm.IUserSession, data *pb.DBCara
func (this *Caravan) CleanCaravanTask(uid string, data *pb.DBCaravan) { func (this *Caravan) CleanCaravanTask(uid string, data *pb.DBCaravan) {
if data.Eventid != 0 { if data.Eventid != 0 {
data.Eventid = 0 data.Eventid = 0
data.Task = 0 data.Taskid = 0
data.Tasktime = 0 data.Tasktime = 0
update := make(map[string]interface{}) update := make(map[string]interface{})
update["eventid"] = data.Eventid update["eventid"] = data.Eventid
update["task"] = data.Task update["task"] = data.Taskid
update["tasktime"] = data.Tasktime update["tasktime"] = data.Tasktime
this.modelCaravan.modifyCaravanDataByObjId(uid, update) this.modelCaravan.modifyCaravanDataByObjId(uid, update)
} }
} }
func (this *Caravan) TaskComplete(session comm.IUserSession, taskid int32) { func (this *Caravan) TaskComplete(session comm.IUserSession, taskid int32) {
this.Debug("TaskComplete", this.Debug("Caravan TaskComplete",
log.Field{Key: "session", Value: session.GetUserId()}, log.Field{Key: "session", Value: session.GetUserId()},
log.Field{Key: "taskid", Value: taskid}, log.Field{Key: "taskid", Value: taskid},
) )
@ -269,7 +278,7 @@ func (this *Caravan) TaskComplete(session comm.IUserSession, taskid int32) {
if conf := this.configure.GetCaravanEventById(taskid); conf != nil { if conf := this.configure.GetCaravanEventById(taskid); conf != nil {
if list, err := this.modelCaravan.getCaravanList(session.GetUserId()); err != nil { if list, err := this.modelCaravan.getCaravanList(session.GetUserId()); err != nil {
if list.Eventid == taskid { if list.Taskid == taskid {
this.CleanCaravanTask(session.GetUserId(), list) //任务完成 清理任务数据 this.CleanCaravanTask(session.GetUserId(), list) //任务完成 清理任务数据
resp = &pb.CaravanTaskCompletePush{} resp = &pb.CaravanTaskCompletePush{}
resp.Data = list resp.Data = list

View File

@ -232,7 +232,7 @@ type DBCaravan struct {
Profit int64 `protobuf:"varint,8,opt,name=profit,proto3" json:"profit"` // 虚拟货利润 Profit int64 `protobuf:"varint,8,opt,name=profit,proto3" json:"profit"` // 虚拟货利润
Resettime int64 `protobuf:"varint,9,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间 Resettime int64 `protobuf:"varint,9,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间
Curcity int32 `protobuf:"varint,10,opt,name=curcity,proto3" json:"curcity"` // 当前城市 Curcity int32 `protobuf:"varint,10,opt,name=curcity,proto3" json:"curcity"` // 当前城市
Task int32 `protobuf:"varint,11,opt,name=task,proto3" json:"task"` // 对应对应世界任务组 worldtask 210 Taskid int32 `protobuf:"varint,11,opt,name=taskid,proto3" json:"taskid"` // 对应对应世界任务组 worldtask
Eventid int32 `protobuf:"varint,12,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID(事件配置唯一id) Eventid int32 `protobuf:"varint,12,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID(事件配置唯一id)
Tasktime int64 `protobuf:"varint,13,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间 Tasktime int64 `protobuf:"varint,13,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间
Baglimit int32 `protobuf:"varint,14,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限 Baglimit int32 `protobuf:"varint,14,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限
@ -340,9 +340,9 @@ func (x *DBCaravan) GetCurcity() int32 {
return 0 return 0
} }
func (x *DBCaravan) GetTask() int32 { func (x *DBCaravan) GetTaskid() int32 {
if x != nil { if x != nil {
return x.Task return x.Taskid
} }
return 0 return 0
} }
@ -394,7 +394,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69,
0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22,
0xdd, 0x04, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0xe1, 0x04, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12,
0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
@ -413,26 +413,27 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{
0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65,
0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79,
0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12,
0x12, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52,
0x61, 0x73, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0c, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74,
0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69,
0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20,
0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x67, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a,
0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x61, 0x67, 0x08, 0x62, 0x61, 0x67, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52,
0x6c, 0x69, 0x6d, 0x69, 0x74, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x08, 0x62, 0x61, 0x67, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x67, 0x49, 0x6e,
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x40, 0x0a,
0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47,
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x42, 0x0a, 0x09, 0x43, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a,
0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x42, 0x0a, 0x09, 0x43, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f,
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x69, 0x74, 0x79, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e,
0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x43, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a,
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
} }
var ( var (