合并日常和随机任务条件
This commit is contained in:
parent
fa0c02991d
commit
45fea5cf76
@ -2,6 +2,7 @@
|
||||
{
|
||||
"id": 100100,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 0,
|
||||
"condition": [
|
||||
@ -15,6 +16,7 @@
|
||||
{
|
||||
"id": 100101,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100100,
|
||||
"condition": [
|
||||
@ -27,6 +29,7 @@
|
||||
{
|
||||
"id": 100102,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100100,
|
||||
"condition": [
|
||||
@ -40,6 +43,7 @@
|
||||
{
|
||||
"id": 100103,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100101,
|
||||
"condition": [
|
||||
@ -52,6 +56,7 @@
|
||||
{
|
||||
"id": 100104,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100103,
|
||||
"condition": [
|
||||
@ -64,6 +69,7 @@
|
||||
{
|
||||
"id": 100105,
|
||||
"group": 1,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100104,
|
||||
"condition": [
|
||||
@ -76,10 +82,11 @@
|
||||
{
|
||||
"id": 100201,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 0,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2001
|
||||
@ -88,10 +95,11 @@
|
||||
{
|
||||
"id": 100202,
|
||||
"group": 2,
|
||||
"subgroup": 100201,
|
||||
"type": 2,
|
||||
"preTid": 100201,
|
||||
"condition": [
|
||||
101
|
||||
170
|
||||
],
|
||||
"sidequest": [
|
||||
2033,
|
||||
@ -101,11 +109,11 @@
|
||||
{
|
||||
"id": 100203,
|
||||
"group": 2,
|
||||
"subgroup": 100201,
|
||||
"type": 2,
|
||||
"preTid": 100201,
|
||||
"condition": [
|
||||
101,
|
||||
107
|
||||
101
|
||||
],
|
||||
"sidequest": [
|
||||
2002,
|
||||
@ -115,10 +123,11 @@
|
||||
{
|
||||
"id": 100204,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100201,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2005
|
||||
@ -127,10 +136,11 @@
|
||||
{
|
||||
"id": 100205,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100204,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2006
|
||||
@ -139,36 +149,38 @@
|
||||
{
|
||||
"id": 100206,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100205,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2034
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 100207,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100206,
|
||||
"condition": [
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2007,
|
||||
2008
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 100207,
|
||||
"group": 2,
|
||||
"type": 2,
|
||||
"preTid": 100206,
|
||||
"condition": [
|
||||
101
|
||||
],
|
||||
"sidequest": [
|
||||
2009,
|
||||
2010
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 100208,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100207,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2011,
|
||||
@ -178,10 +190,11 @@
|
||||
{
|
||||
"id": 100209,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100208,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2013,
|
||||
@ -192,10 +205,11 @@
|
||||
{
|
||||
"id": 100210,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100209,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2016,
|
||||
@ -206,10 +220,11 @@
|
||||
{
|
||||
"id": 100211,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100210,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2019
|
||||
@ -218,10 +233,11 @@
|
||||
{
|
||||
"id": 100212,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100211,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2020
|
||||
@ -230,10 +246,11 @@
|
||||
{
|
||||
"id": 100213,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100212,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2021,
|
||||
@ -244,10 +261,11 @@
|
||||
{
|
||||
"id": 100214,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100213,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2024,
|
||||
@ -258,10 +276,11 @@
|
||||
{
|
||||
"id": 100215,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100214,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2027,
|
||||
@ -272,10 +291,11 @@
|
||||
{
|
||||
"id": 100216,
|
||||
"group": 2,
|
||||
"subgroup": 0,
|
||||
"type": 2,
|
||||
"preTid": 100215,
|
||||
"condition": [
|
||||
101
|
||||
0
|
||||
],
|
||||
"sidequest": [
|
||||
2030,
|
||||
|
@ -167,7 +167,7 @@
|
||||
"needItem": [
|
||||
0
|
||||
],
|
||||
"nextTid": 100207
|
||||
"nextTid": 0
|
||||
},
|
||||
{
|
||||
"id": 20006,
|
||||
@ -197,7 +197,7 @@
|
||||
"needItem": [
|
||||
0
|
||||
],
|
||||
"nextTid": 100207
|
||||
"nextTid": 100208
|
||||
},
|
||||
{
|
||||
"id": 20009,
|
||||
|
@ -817,7 +817,7 @@
|
||||
"datatype": 2,
|
||||
"type": 1,
|
||||
"inited": [],
|
||||
"data1": 25004,
|
||||
"data1": 44006,
|
||||
"data2": 0,
|
||||
"data3": 0,
|
||||
"data4": 0,
|
||||
@ -828,7 +828,7 @@
|
||||
"datatype": 2,
|
||||
"type": 70,
|
||||
"inited": [],
|
||||
"data1": 102,
|
||||
"data1": 101,
|
||||
"data2": 0,
|
||||
"data3": 0,
|
||||
"data4": 0,
|
||||
|
@ -471,7 +471,7 @@
|
||||
20004
|
||||
],
|
||||
"endTid": [
|
||||
-1
|
||||
171
|
||||
],
|
||||
"storyEnd": 0,
|
||||
"reward": [
|
||||
@ -559,11 +559,17 @@
|
||||
"location": "middle",
|
||||
"point": "model_02",
|
||||
"storyBegin": 308,
|
||||
"Entity": [],
|
||||
"EntityChange": [],
|
||||
"Entity": [
|
||||
"MainLine"
|
||||
],
|
||||
"EntityChange": [
|
||||
"default"
|
||||
],
|
||||
"EntityStateChange": [],
|
||||
"EntityInteractive": [],
|
||||
"modelaction": "Enter",
|
||||
"EntityInteractive": [
|
||||
false
|
||||
],
|
||||
"modelaction": "",
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": -90,
|
||||
@ -582,7 +588,7 @@
|
||||
"endTid": [
|
||||
-1
|
||||
],
|
||||
"storyEnd": 0,
|
||||
"storyEnd": 311,
|
||||
"reward": [
|
||||
{
|
||||
"ChooseId": 20008,
|
||||
@ -595,7 +601,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"nextTid": 100207,
|
||||
"nextTid": 100208,
|
||||
"CD": 0
|
||||
},
|
||||
{
|
||||
@ -604,16 +610,10 @@
|
||||
"location": "middle",
|
||||
"point": "model_02",
|
||||
"storyBegin": 311,
|
||||
"Entity": [
|
||||
"Earth"
|
||||
],
|
||||
"EntityChange": [
|
||||
"default"
|
||||
],
|
||||
"Entity": [],
|
||||
"EntityChange": [],
|
||||
"EntityStateChange": [],
|
||||
"EntityInteractive": [
|
||||
false
|
||||
],
|
||||
"EntityInteractive": [],
|
||||
"modelaction": "",
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
@ -936,7 +936,7 @@
|
||||
},
|
||||
{
|
||||
"id": 2019,
|
||||
"objType": 1,
|
||||
"objType": 2,
|
||||
"location": "left",
|
||||
"point": "icon_01",
|
||||
"storyBegin": 321,
|
||||
@ -969,7 +969,7 @@
|
||||
},
|
||||
{
|
||||
"id": 2020,
|
||||
"objType": 1,
|
||||
"objType": 2,
|
||||
"location": "left",
|
||||
"point": "icon_01",
|
||||
"storyBegin": 323,
|
||||
@ -997,7 +997,7 @@
|
||||
],
|
||||
"storyEnd": 322,
|
||||
"reward": [],
|
||||
"nextTid": 100212,
|
||||
"nextTid": 100213,
|
||||
"CD": 0
|
||||
},
|
||||
{
|
||||
@ -1007,7 +1007,7 @@
|
||||
"point": "model_02",
|
||||
"storyBegin": 324,
|
||||
"Entity": [
|
||||
"Earth"
|
||||
"MainLine"
|
||||
],
|
||||
"EntityChange": [
|
||||
"globe"
|
||||
@ -1427,5 +1427,36 @@
|
||||
"reward": [],
|
||||
"nextTid": 100204,
|
||||
"CD": 0
|
||||
},
|
||||
{
|
||||
"id": 2034,
|
||||
"objType": 1,
|
||||
"location": "middle",
|
||||
"point": "model_02",
|
||||
"storyBegin": 337,
|
||||
"Entity": [],
|
||||
"EntityChange": [],
|
||||
"EntityStateChange": [],
|
||||
"EntityInteractive": [],
|
||||
"modelaction": "Enter",
|
||||
"rotation": {
|
||||
"x": 0,
|
||||
"y": -90,
|
||||
"z": 0
|
||||
},
|
||||
"modelstate": 0,
|
||||
"popup": "",
|
||||
"special": "",
|
||||
"enableAi": false,
|
||||
"boxreplace": "",
|
||||
"timeline": "",
|
||||
"chooseId": [],
|
||||
"endTid": [
|
||||
-1
|
||||
],
|
||||
"storyEnd": 0,
|
||||
"reward": [],
|
||||
"nextTid": 100207,
|
||||
"CD": 0
|
||||
}
|
||||
]
|
@ -209,7 +209,8 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
this.goList.cachedList.Items[i].Checked = false
|
||||
this.goList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||
}
|
||||
this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal))
|
||||
this.goList.changeFileCount()
|
||||
// this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal))
|
||||
this.goList.itemList.Refresh()
|
||||
}
|
||||
|
||||
@ -244,6 +245,7 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
json_overrideBtn.Disable()
|
||||
defer func() {
|
||||
json_overrideBtn.Enable()
|
||||
this.jsonList.itemList.Refresh()
|
||||
}()
|
||||
for _, v := range this.jsonList.selItemIds {
|
||||
// logrus.WithField("path1", filepath.Join(tmpDir.Text, "json", v)).Debug("copy json")
|
||||
@ -271,7 +273,8 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
list.cachedList.Items[i].Checked = false
|
||||
list.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||
}
|
||||
list.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(list.selItemIds), list.fileTotal))
|
||||
this.jsonList.changeFileCount()
|
||||
// list.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(list.selItemIds), list.fileTotal))
|
||||
list.itemList.Refresh()
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,7 @@ const (
|
||||
EventUserOffline core.Event_Key = "Event_UserOffline" //用户离线事件
|
||||
|
||||
EventUserChanged core.Event_Key = "event_user_changed" //用户数据变化
|
||||
EventTaskChanged core.Event_Key = "event_task_changed" //任务数据变化
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -127,6 +127,8 @@ type (
|
||||
SendToRtask(session IUserSession, rtaskType TaskType, params ...int32) (code pb.ErrorCode)
|
||||
// 初始化条件数据
|
||||
InitCondiData(uid string) error
|
||||
// 获取任务条件记录
|
||||
GetCondiData(uid string) *pb.DBRtaskRecord
|
||||
}
|
||||
|
||||
//好友
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/core/cbase"
|
||||
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
@ -93,6 +93,9 @@ func (this *ModelRtaskRecord) initCondiData(uid string) error {
|
||||
if len(v.Inited) != 5 {
|
||||
continue
|
||||
}
|
||||
if _, ok := dr.Vals[v.Id]; ok {
|
||||
continue
|
||||
}
|
||||
vals := []int32{}
|
||||
for i, p := range v.Inited {
|
||||
if p == 1 {
|
||||
|
@ -252,3 +252,8 @@ func (this *ModuleRtask) CheckCondi(uid string, condiId int32) (code pb.ErrorCod
|
||||
func (this *ModuleRtask) InitCondiData(uid string) error {
|
||||
return this.modelRtaskRecord.initCondiData(uid)
|
||||
}
|
||||
|
||||
// 获取玩家任务条件记录
|
||||
func (this *ModuleRtask) GetCondiData(uid string) *pb.DBRtaskRecord {
|
||||
return this.modelRtaskRecord.getRecord(uid)
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
package rtask
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules/task"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"time"
|
||||
@ -65,7 +67,6 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond
|
||||
err = this.Change(uid, update)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@ -106,7 +107,6 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
|
||||
"vals": record.Vals,
|
||||
}
|
||||
err = this.Change(uid, update)
|
||||
|
||||
} else {
|
||||
record.Vals[cfg.Id] = &pb.RtaskData{
|
||||
Data: toMap(vals...),
|
||||
@ -119,5 +119,18 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
|
||||
err = this.Change(uid, update)
|
||||
}
|
||||
}
|
||||
|
||||
//日/周/成就任务监听触发
|
||||
tl := new(task.TaskListen)
|
||||
tl.Uid = uid
|
||||
tl.TaskType = comm.TaskType(cfg.Id)
|
||||
if im, err := this.service.GetModule(comm.ModuleTask); err == nil {
|
||||
if mt, ok := im.(*task.ModuleTask); ok {
|
||||
mt.GetEventApp().Dispatch(comm.EventTaskChanged, tl)
|
||||
}
|
||||
}else{
|
||||
this.moduleRtask.Printf("get ModuleTask err: %v", err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package task
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"sort"
|
||||
@ -14,12 +14,15 @@ import (
|
||||
type ModelTask struct {
|
||||
modules.MCompModel
|
||||
moduleTask *ModuleTask
|
||||
EventApp *event_v2.App
|
||||
}
|
||||
|
||||
func (this *ModelTask) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableTask
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.moduleTask = module.(*ModuleTask)
|
||||
this.EventApp = event_v2.NewApp()
|
||||
this.EventApp.Listen(comm.EventTaskChanged, this.doTaskHandle)
|
||||
return
|
||||
}
|
||||
|
||||
@ -36,10 +39,21 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli
|
||||
return list[i].Sort < list[j].Sort
|
||||
})
|
||||
|
||||
//
|
||||
dr := this.moduleTask.ModuleRtask.GetCondiData(uid)
|
||||
if dr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 筛选出指定tag的任务
|
||||
var taskList []*pb.DBTask
|
||||
for _, v := range list {
|
||||
if v.Tag == int32(taskTag) {
|
||||
if p, ok := dr.Vals[v.TypeId]; ok {
|
||||
if len(p.Data) > 0 {
|
||||
v.Progress = p.Data[0]
|
||||
}
|
||||
}
|
||||
taskList = append(taskList, v)
|
||||
}
|
||||
}
|
||||
@ -126,7 +140,6 @@ func (this *ModelTask) initTask(uid string, taskTag comm.TaskTag) error {
|
||||
TypeId: cnf.TypeId,
|
||||
TaskId: cnf.Key,
|
||||
Active: cnf.Active,
|
||||
Progress: cnf.ConditionSecond,
|
||||
Sort: cnf.IdList,
|
||||
}
|
||||
if err := this.AddList(uid, task.Id, task); err != nil {
|
||||
@ -206,6 +219,7 @@ func (this *ModelTask) clearTask(uid string, taskTag ...comm.TaskTag) {
|
||||
}
|
||||
|
||||
//进入卡牌攻略
|
||||
// Deprecated
|
||||
func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32, err error) {
|
||||
//检查此英雄攻略是否完成
|
||||
taskList := this.getTaskListByTag(uid, comm.TASK_STRATEGY)
|
||||
@ -213,10 +227,10 @@ func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32,
|
||||
for _, v := range taskList {
|
||||
conf := this.moduleTask.configure.getTaskById(v.TaskId)
|
||||
if conf != nil {
|
||||
if conf.RestrictiveCondition == heroCfgId && v.Status != 1 {
|
||||
allFinished = false
|
||||
break
|
||||
}
|
||||
// if conf.RestrictiveCondition == heroCfgId && v.Status != 1 {
|
||||
// allFinished = false
|
||||
// break
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,68 +253,58 @@ func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32,
|
||||
return
|
||||
}
|
||||
|
||||
// 任务类型-装备升级
|
||||
func (this *ModelTask) UpEquip(uid string, taskId int32, tp *pb.TaskParam) *pb.DBTask {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 任务类型-英雄星级升级
|
||||
func (this *ModelTask) UpHeroStar(uid string, taskId int32, tp *pb.TaskParam) *pb.DBTask {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 任务类型-英雄等级升级
|
||||
func (this *ModelTask) UpHeroLevel(uid string, taskId int32, tp *pb.TaskParam) *pb.DBTask {
|
||||
if task, ok := this.checkTask(uid, taskId); ok {
|
||||
var progress int32
|
||||
// 任务完成
|
||||
if tp.Second >= task.Progress {
|
||||
progress = 0
|
||||
update := map[string]interface{}{
|
||||
"progress": progress,
|
||||
"status": 1,
|
||||
}
|
||||
if err := this.modifyUserTask(task.Uid, task.Id, update); err != nil {
|
||||
log.Errorf("err %v", err)
|
||||
return nil
|
||||
}
|
||||
task.Progress = progress
|
||||
task.Status = 1
|
||||
return task
|
||||
} else {
|
||||
// 任务未完成
|
||||
progress = task.Progress - tp.Second
|
||||
if progress <= 0 {
|
||||
progress = 0
|
||||
}
|
||||
update := map[string]interface{}{
|
||||
"progress": progress,
|
||||
}
|
||||
if err := this.modifyUserTask(task.Uid, task.Id, update); err != nil {
|
||||
this.moduleTask.Errorf("err %v", err)
|
||||
return nil
|
||||
}
|
||||
task.Progress = progress
|
||||
return task
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 任务处理
|
||||
func (this *ModelTask) doTaskHandle(uid string, taskType comm.TaskType, taskParam *pb.TaskParam) (tasks []*pb.DBTask, err error) {
|
||||
data, err := this.moduleTask.configure.getTasks(int32(taskType))
|
||||
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
||||
tl := event.(*TaskListen)
|
||||
|
||||
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
||||
if err != nil {
|
||||
this.moduleTask.Errorf("taskHandle err %v", err)
|
||||
return nil, err
|
||||
return
|
||||
}
|
||||
|
||||
dr := this.moduleTask.ModuleRtask.GetCondiData(tl.Uid)
|
||||
if dr == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, conf := range data {
|
||||
if handle, ok := this.moduleTask.taskHandleMap[conf.TypeId]; ok {
|
||||
if task := handle(uid, conf.Key, taskParam); task != nil {
|
||||
tasks = append(tasks, task)
|
||||
ret, ok := dr.Vals[conf.TypeId]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if task, ok := this.checkTask(tl.Uid, conf.Key); ok {
|
||||
update := make(map[string]interface{})
|
||||
var progress int32
|
||||
if code := this.moduleTask.ModuleRtask.CheckCondi(tl.Uid, conf.TypeId); code == pb.ErrorCode_Success {
|
||||
// update data
|
||||
if ret != nil && len(ret.Data) > 0 {
|
||||
progress = ret.Data[0]
|
||||
}
|
||||
update = map[string]interface{}{
|
||||
"progress": progress,
|
||||
"status": 1,
|
||||
}
|
||||
} else {
|
||||
if ret != nil && len(ret.Data) > 0 {
|
||||
progress = ret.Data[0]
|
||||
}
|
||||
update = map[string]interface{}{
|
||||
"progress": progress,
|
||||
}
|
||||
}
|
||||
if err = this.modifyUserTask(tl.Uid, task.Id, update); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type TaskListen struct {
|
||||
event_v2.Event
|
||||
Uid string
|
||||
TaskType comm.TaskType
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
event_v2 "go_dreamfactory/lego/sys/event/v2"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
@ -19,12 +20,12 @@ type ModuleTask struct {
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
|
||||
taskHandleMap map[int32]taskHandle //任务处理器
|
||||
// taskHandleMap map[int32]taskHandle //任务处理器
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
return &ModuleTask{
|
||||
taskHandleMap: make(map[int32]taskHandle),
|
||||
// taskHandleMap: make(map[int32]taskHandle),
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,9 +33,13 @@ func (this *ModuleTask) GetType() core.M_Modules {
|
||||
return comm.ModuleTask
|
||||
}
|
||||
|
||||
func (this *ModuleTask) GetEventApp() *event_v2.App {
|
||||
return this.modelTask.EventApp
|
||||
}
|
||||
|
||||
func (this *ModuleTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
this.initTaskHandle()
|
||||
// this.initTaskHandle()
|
||||
return
|
||||
}
|
||||
|
||||
@ -119,19 +124,19 @@ func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
||||
|
||||
//任务处理
|
||||
func (this *ModuleTask) SendToTask(session comm.IUserSession, taskType comm.TaskType, taskPram *pb.TaskParam) (code pb.ErrorCode) {
|
||||
if tasks, err := this.modelTask.doTaskHandle(session.GetUserId(), taskType, taskPram); err != nil {
|
||||
code = pb.ErrorCode_TaskHandle
|
||||
} else {
|
||||
for _, t := range tasks {
|
||||
if err := session.SendMsg(string(comm.ModuleTask), TaskSubTypeFinishedPush, &pb.TaskFinishedPush{TaskId: t.TaskId}); err != nil {
|
||||
this.modelTask.moduleTask.Errorf("SendToTask sendmsg err:%v", err)
|
||||
}
|
||||
// 每日任务
|
||||
if t.Tag == int32(comm.TASK_DAILY) {
|
||||
this.ModuleRtask.SendToRtask(session, comm.Rtype3, t.TaskId)
|
||||
}
|
||||
}
|
||||
}
|
||||
// if tasks, err := this.modelTask.doTaskHandle(session.GetUserId(), taskType, taskPram); err != nil {
|
||||
// code = pb.ErrorCode_TaskHandle
|
||||
// } else {
|
||||
// for _, t := range tasks {
|
||||
// if err := session.SendMsg(string(comm.ModuleTask), TaskSubTypeFinishedPush, &pb.TaskFinishedPush{TaskId: t.TaskId}); err != nil {
|
||||
// this.modelTask.moduleTask.Errorf("SendToTask sendmsg err:%v", err)
|
||||
// }
|
||||
// // 每日任务
|
||||
// if t.Tag == int32(comm.TASK_DAILY) {
|
||||
// this.ModuleRtask.SendToRtask(session, comm.Rtype3, t.TaskId)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
@ -154,29 +159,29 @@ func (this *ModuleTask) CleanData(uid string) {
|
||||
//任务处理器注册
|
||||
type taskHandle func(uid string, taskId int32, tp *pb.TaskParam) *pb.DBTask
|
||||
|
||||
func (this *ModuleTask) register(taskType comm.TaskType, fn taskHandle) {
|
||||
if _, ok := this.taskHandleMap[int32(taskType)]; !ok {
|
||||
this.taskHandleMap[int32(taskType)] = fn
|
||||
}
|
||||
}
|
||||
// func (this *ModuleTask) register(taskType comm.TaskType, fn taskHandle) {
|
||||
// if _, ok := this.taskHandleMap[int32(taskType)]; !ok {
|
||||
// this.taskHandleMap[int32(taskType)] = fn
|
||||
// }
|
||||
// }
|
||||
|
||||
// 初始任务事件处理类
|
||||
func (this *ModuleTask) initTaskHandle() {
|
||||
if data, err := this.configure.getTaskList(); err == nil {
|
||||
for _, v := range data {
|
||||
switch v.TypeId {
|
||||
case int32(comm.TaskTypeUpEquip):
|
||||
this.register(comm.TaskTypeUpEquip, this.modelTask.UpEquip)
|
||||
case int32(comm.TaskTypeUpHeroStar):
|
||||
this.register(comm.TaskTypeUpHeroStar, this.modelTask.UpHeroStar)
|
||||
case int32(comm.TaskTypeUpHeroLevel):
|
||||
this.register(comm.TaskTypeUpHeroLevel, this.modelTask.UpHeroLevel)
|
||||
default:
|
||||
log.Warnf("%v task type not supported", v.TypeId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// func (this *ModuleTask) initTaskHandle() {
|
||||
// if data, err := this.configure.getTaskList(); err == nil {
|
||||
// for _, v := range data {
|
||||
// switch v.TypeId {
|
||||
// case int32(comm.TaskTypeUpEquip):
|
||||
// this.register(comm.TaskTypeUpEquip, this.modelTask.UpEquip)
|
||||
// case int32(comm.TaskTypeUpHeroStar):
|
||||
// this.register(comm.TaskTypeUpHeroStar, this.modelTask.UpHeroStar)
|
||||
// case int32(comm.TaskTypeUpHeroLevel):
|
||||
// this.register(comm.TaskTypeUpHeroLevel, this.modelTask.UpHeroLevel)
|
||||
// default:
|
||||
// log.Warnf("%v task type not supported", v.TypeId)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
func (this *ModuleTask) GetTaskFinished(uid string, taskTage comm.TaskTag) []*pb.DBTask {
|
||||
return this.modelTask.getFinishTasks(uid, taskTage)
|
||||
|
@ -20,16 +20,16 @@ import (
|
||||
type ModelUser struct {
|
||||
modules.MCompModel
|
||||
module *User
|
||||
eventApp *event_v2.App
|
||||
EventApp *event_v2.App
|
||||
}
|
||||
|
||||
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableUser
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.module = module.(*User)
|
||||
this.eventApp = event_v2.NewApp()
|
||||
this.eventApp.Listen(comm.EventUserChanged, this.ChangeExp)
|
||||
this.eventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
|
||||
this.EventApp = event_v2.NewApp()
|
||||
this.EventApp.Listen(comm.EventUserChanged, this.ChangeExp)
|
||||
this.EventApp.Listen(comm.EventUserChanged, this.ChangeLevel)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ func (this *User) EventUserChanged(session comm.IUserSession) {
|
||||
ul.exp = user.Exp
|
||||
ul.lv = user.Lv
|
||||
}
|
||||
this.modelUser.eventApp.Dispatch(comm.EventUserChanged, ul)
|
||||
this.modelUser.EventApp.Dispatch(comm.EventUserChanged, ul)
|
||||
}
|
||||
|
||||
func (this *User) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {
|
||||
|
@ -16,8 +16,6 @@ type GameTaskRoundData struct {
|
||||
IdTag int32
|
||||
TaskDisplay string
|
||||
TypeId int32
|
||||
ConditionSecond int32
|
||||
RestrictiveCondition int32
|
||||
Active int32
|
||||
IdAfter int32
|
||||
JumpInterface int32
|
||||
@ -37,8 +35,6 @@ func (_v *GameTaskRoundData)Deserialize(_buf map[string]interface{}) (err error)
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id_tag"].(float64); !_ok_ { err = errors.New("id_tag error"); return }; _v.IdTag = int32(_tempNum_) }
|
||||
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["task_display"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.TaskDisplay error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.TaskDisplay, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type_id"].(float64); !_ok_ { err = errors.New("type_id error"); return }; _v.TypeId = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["condition_second"].(float64); !_ok_ { err = errors.New("condition_second error"); return }; _v.ConditionSecond = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["restrictive_condition"].(float64); !_ok_ { err = errors.New("restrictive_condition error"); return }; _v.RestrictiveCondition = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["active"].(float64); !_ok_ { err = errors.New("active error"); return }; _v.Active = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id_after"].(float64); !_ok_ { err = errors.New("id_after error"); return }; _v.IdAfter = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["jump_interface"].(float64); !_ok_ { err = errors.New("jump_interface error"); return }; _v.JumpInterface = int32(_tempNum_) }
|
||||
|
Loading…
Reference in New Issue
Block a user