更新随机任务流程
This commit is contained in:
parent
9aa7af41d2
commit
4d171b8901
@ -50,27 +50,30 @@ func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.RtaskBattle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := utils.Findx(frtaskArr.RtaskIds, req.RtaskId); !ok {
|
if _, ok := utils.Findx(frtaskArr.RtaskIds, req.RtaskId); !ok {
|
||||||
// 更新完成的任务
|
if len(sideConf.ChooseId) == 0 && sideConf.EndTid[0] == -1 {
|
||||||
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
// 更新完成的任务
|
||||||
if rtask.FrtaskIds == nil {
|
frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId)
|
||||||
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
if rtask.FrtaskIds == nil {
|
||||||
}
|
rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds)
|
||||||
rtask.FrtaskIds[conf.Group] = frtaskArr
|
}
|
||||||
|
rtask.FrtaskIds[conf.Group] = frtaskArr
|
||||||
|
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
"frtaskIds": rtask.FrtaskIds,
|
"frtaskIds": rtask.FrtaskIds,
|
||||||
}
|
}
|
||||||
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发奖
|
// 发奖
|
||||||
for _, v := range sideConf.Reward {
|
for _, v := range sideConf.Reward {
|
||||||
if v.ChooseId == 0 {
|
if v.ChooseId == 0 {
|
||||||
this.moduleRtask.DispenseRes(session, v.Reward, true)
|
this.moduleRtask.DispenseRes(session, v.Reward, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeBattleFinish,
|
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeBattleFinish,
|
||||||
|
@ -150,6 +150,21 @@ func (this *configureComp) getRtaskTypeById(typeId int32) (data *cfg.GameRdtaskC
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) getRtaskCondis(typeId int32) (list []*cfg.GameRdtaskCondiData) {
|
||||||
|
cfg, err := this.getRtaskCondiCfg()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if cfg != nil {
|
||||||
|
for _, v := range cfg.GetDataList() {
|
||||||
|
if v.Type == typeId {
|
||||||
|
list = append(list, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 任务
|
// 任务
|
||||||
func (this *configureComp) getRtaskById(taskId int32) (data *cfg.GameRdtaskData) {
|
func (this *configureComp) getRtaskById(taskId int32) (data *cfg.GameRdtaskData) {
|
||||||
cfg, err := this.getRtaskCfg()
|
cfg, err := this.getRtaskCfg()
|
||||||
|
@ -209,34 +209,21 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range this.handleMap {
|
for _, codi := range this.configure.getRtaskCondis(int32(rtaskType)) {
|
||||||
// 找到任务类型
|
if v, ok := this.handleMap[codi.Id]; ok {
|
||||||
if int32(rtaskType) == v.cfg.Type {
|
|
||||||
if v.find == nil {
|
if v.find == nil {
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
if condiId, err = v.find(v.cfg, params...); condiId == 0 {
|
if condiId, err = v.find(v.cfg, params...); condiId == 0 {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Error(err.Error())
|
this.Error(err.Error())
|
||||||
}
|
}
|
||||||
continue
|
|
||||||
} else {
|
} else {
|
||||||
//数据记录方式是1
|
|
||||||
// if v.cfg.Datatype == 1 ||
|
|
||||||
// v.cfg.Datatype == 2 && this.ModuleSys.IsAccess("task", user.Lv) {
|
|
||||||
condis = append(condis, v)
|
condis = append(condis, v)
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(condis) == 0 {
|
|
||||||
this.Warnf("没有找到符合的条件任务, typeId: %v params: %v", rtaskType, params)
|
|
||||||
code = pb.ErrorCode_RtaskCondiNoFound
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// update
|
// update
|
||||||
for _, v := range condis {
|
for _, v := range condis {
|
||||||
if v.update != nil {
|
if v.update != nil {
|
||||||
|
@ -101,9 +101,10 @@ func (this *ModelTask) getTaskListByTag(uid string, taskTag comm.TaskTag) (newli
|
|||||||
} else {
|
} else {
|
||||||
if isReceived(curTask.Key) {
|
if isReceived(curTask.Key) {
|
||||||
newlist = append(newlist, v)
|
newlist = append(newlist, v)
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
// else {
|
||||||
|
// break
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +260,6 @@ func (this *ModelTask) inStrategy(uid string, heroCfgId int32) (taskIds []int32,
|
|||||||
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
func (this *ModelTask) doTaskHandle(event interface{}, next func(event interface{})) {
|
||||||
tl := event.(*TaskListen)
|
tl := event.(*TaskListen)
|
||||||
|
|
||||||
// 获取玩家的指定事件列表
|
|
||||||
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
data, err := this.moduleTask.configure.getTasks(int32(tl.TaskType))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.moduleTask.Errorf("taskHandle err %v", err)
|
this.moduleTask.Errorf("taskHandle err %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user