战斗任务

This commit is contained in:
wh_zcy 2022-11-11 15:08:44 +08:00
parent 01cf37bd2b
commit 9870184e47
5 changed files with 21 additions and 15 deletions

View File

@ -178,4 +178,5 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
this.moonfantasy.Trigger(session, report)
return pb.ErrorCode_Success, true
}

View File

@ -141,8 +141,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
}
// 初始化随机任务数据
// TODO: 判断次功能开启时再初始化
go this.module.ModuleRtask.InitCondiData(user.Uid)
this.module.ModuleRtask.InitCondiData(user.Uid)
// 日常登录任务
this.module.ModuleRtask.SendToRtask(session, comm.Rtype7, 1)

View File

@ -74,7 +74,7 @@ func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
func (this *ModelUser) GetUser(uid string) (user *pb.DBUser) {
user = &pb.DBUser{}
if err := this.Get(uid, user); err != nil {
this.module.Errorln(err)
this.module.Errorf("GetUser uid:%v err:%v",uid,err)
return
}
return

View File

@ -40,7 +40,7 @@ func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBa
// var isWin bool
if code, _ = ibattle.CheckBattleReport(session, req.Report); code == pb.ErrorCode_Success {
//触发任务
go this.module.ModuleRtask.SendToRtask(session, comm.Rtype70, 1, req.BattleConfId)
this.module.ModuleRtask.SendToRtask(session, comm.Rtype70, 1, req.BattleConfId)
}
}

View File

@ -44,6 +44,23 @@ func (this *Worldtask) GetType() core.M_Modules {
// 任务条件达成通知
func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) error {
uid := session.GetUserId()
conf, err := this.configure.getWorldtaskCfg()
if err != nil || conf == nil {
return err
}
finishedTaskIds := make(map[int32]int32) //达成的任务条件
for _, c := range conf.GetDataList() {
if c.Completetask == condId && c.Completetask != 0 {
finishedTaskIds[c.Group] = c.Key
}
}
if len(finishedTaskIds) == 0 {
return nil
}
//下一个任务ID
var nextTaskId int32
// 获取用户信息
@ -61,17 +78,6 @@ func (this *Worldtask) TaskcondNotify(session comm.IUserSession, condId int32) e
if userTask.Uid != "" {
//查找任务ID根据condId 可能会找出不同的任务
// 遍历配置表
conf, err := this.configure.getWorldtaskCfg()
if err != nil || conf == nil {
return err
}
finishedTaskIds := make(map[int32]int32) //达成的任务条件
for _, c := range conf.GetDataList() {
if c.Completetask == condId && c.Completetask != 0 {
finishedTaskIds[c.Group] = c.Key
}
}
for k, id := range finishedTaskIds {
taskConf, err := this.configure.getWorldtaskById(id)