更新随机任务限定条件
This commit is contained in:
parent
6ff804b692
commit
288e899d39
@ -106,6 +106,8 @@ type (
|
||||
SendToTask(session IUserSession, taskType TaskType, param *pb.TaskParam) (code pb.ErrorCode)
|
||||
// 清理玩家任务数据
|
||||
CleanData(uid string)
|
||||
// 获取当前任务
|
||||
GetTaskById(uid string, taskId int32) *pb.DBTask
|
||||
}
|
||||
|
||||
// 随机任务
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
const (
|
||||
RtaskSubTypeChoose = "choose" //选择
|
||||
RtaskSubTypeList = "list" //随机任务列表
|
||||
RtaskSubTypeDotask = "dotask" //做任务
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
|
@ -3,7 +3,6 @@ package rtask
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -24,10 +23,10 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
}
|
||||
|
||||
// 是否已完成
|
||||
if _, ok := utils.Findx(rtask.FrtaskIds, req.RtaskId); !ok {
|
||||
code = pb.ErrorCode_RtaskUnFinished
|
||||
return
|
||||
}
|
||||
// if _, ok := utils.Findx(rtask.FrtaskIds, req.RtaskId); !ok {
|
||||
// code = pb.ErrorCode_RtaskUnFinished
|
||||
// return
|
||||
// }
|
||||
|
||||
// 获取当前任务配置
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
@ -36,12 +35,16 @@ func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (
|
||||
return
|
||||
}
|
||||
|
||||
// var nextTaskId int32
|
||||
if req.ChooseId == 0 {
|
||||
//读任务配置中的next taskId
|
||||
// nextTaskId = conf.IdAfter
|
||||
} else {
|
||||
// nextTaskId =
|
||||
//获取选项配置
|
||||
chooseCnf := this.moduleRtask.configure.getRtaskChooseCfg(req.ChooseId)
|
||||
if chooseCnf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
|
||||
// 校验限定条件
|
||||
if ok := this.moduleRtask.modelRtask.checkCondi(session.GetUserId(), chooseCnf.PreTid); !ok {
|
||||
return
|
||||
}
|
||||
|
||||
//发奖励
|
||||
|
@ -27,12 +27,27 @@ func (this *apiComp) dotask(session comm.IUserSession, req *pb.RtaskApplyReq) (c
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前任务配置
|
||||
conf := this.moduleRtask.configure.getRtaskById(req.RtaskId)
|
||||
if conf == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
|
||||
//验证该任务是否已完成
|
||||
if _, ok := utils.Findx(rtask.FrtaskIds, req.RtaskId); ok {
|
||||
code = pb.ErrorCode_RtaskFinished
|
||||
return
|
||||
}
|
||||
|
||||
//校验限定条件
|
||||
var ok bool
|
||||
if code, ok = this.moduleRtask.modelRtask.checkHandle(session.GetUserId(), conf); !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// 没有设置选项,表示任务完成
|
||||
if len(conf.ChooseId) == 0 {
|
||||
rtask.FrtaskIds = append(rtask.FrtaskIds, req.RtaskId)
|
||||
|
||||
// 更新完成的任务
|
||||
@ -43,5 +58,14 @@ func (this *apiComp) dotask(session comm.IUserSession, req *pb.RtaskApplyReq) (c
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
|
||||
// 发奖励
|
||||
code = this.moduleRtask.DispenseRes(session, conf.Reward, true)
|
||||
}
|
||||
|
||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeDotask, &pb.RtaskApplyResp{
|
||||
RtaskId: req.RtaskId,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -13,10 +13,16 @@ func (this *apiComp) listCheck(session comm.IUserSession, req *pb.RtasklistReq)
|
||||
|
||||
func (this *apiComp) list(session comm.IUserSession, req *pb.RtasklistReq) (code pb.ErrorCode, data proto.Message) {
|
||||
|
||||
// 获取当前玩家
|
||||
rtask := this.moduleRtask.modelRtask.GetRtask(session.GetUserId())
|
||||
if rtask == nil {
|
||||
code = pb.ErrorCode_RtaskNoRtask
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
rsp := &pb.RtasklistResp{}
|
||||
rsp := &pb.RtasklistResp{
|
||||
RtaskId: rtask.FrtaskIds,
|
||||
}
|
||||
if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeList, rsp); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
|
@ -59,6 +59,22 @@ func (this *configureComp) getRtaskTypeCfg() (data *cfg.GameRdtaskCondi, err err
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) getRtaskChoose() (data *cfg.GameRdtaskChoose, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(gameRtaskChoose); err != nil {
|
||||
return
|
||||
} else {
|
||||
if data, ok = v.(*cfg.GameRdtaskChoose); !ok {
|
||||
err = fmt.Errorf("%T is *cfg.getRtaskChoose", v)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取随机任务配置
|
||||
func (this *configureComp) getRtaskList() (data []*cfg.GameRdtaskData, err error) {
|
||||
cfg, err := this.getRtaskCfg()
|
||||
@ -71,6 +87,19 @@ func (this *configureComp) getRtaskList() (data []*cfg.GameRdtaskData, err error
|
||||
return
|
||||
}
|
||||
|
||||
// 获取选项配置
|
||||
func (this *configureComp) getRtaskChooseCfg(id int32) *cfg.GameRdtaskChooseData {
|
||||
cfg, err := this.getRtaskChoose()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if data, ok := cfg.GetDataMap()[id]; ok {
|
||||
return data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 查询任务类型
|
||||
func (this *configureComp) getRtaskTypeById(typeId int32) (data *cfg.GameRdtaskCondiData, err error) {
|
||||
cfg, err := this.getRtaskTypeCfg()
|
||||
|
@ -8,19 +8,23 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"github.com/spf13/cast"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type ModelRtask struct {
|
||||
modules.MCompModel
|
||||
moduleRtask *ModuleRtask
|
||||
service core.IService
|
||||
}
|
||||
|
||||
func (this *ModelRtask) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.TableName = comm.TableRtask
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.moduleRtask = module.(*ModuleRtask)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
@ -46,63 +50,153 @@ func (this *ModelRtask) setNextTask(uid string, rtaskId int32) error {
|
||||
return this.Change(uid, update)
|
||||
}
|
||||
|
||||
func (this *ModelRtask) doRtaskHandle(uid string, param *pb.RtaskParam) (rtaskId int32, err error) {
|
||||
log.Debugf("do rtask params: %v %v %v ", param.Param1, param.Param2, param.Param3)
|
||||
// 做任务之前的校验
|
||||
func (this *ModelRtask) checkHandle(uid string, conf *cfg.GameRdtaskData) (code pb.ErrorCode, ok bool) {
|
||||
//查询玩家的
|
||||
rtask := &pb.DBRtask{}
|
||||
if err = this.Get(uid, rtask); err != nil {
|
||||
if err := this.Get(uid, rtask); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
var taskId int32
|
||||
if len(rtask.FrtaskIds) == 0 {
|
||||
conf := this.moduleRtask.configure.getFirstTask()
|
||||
if conf != nil {
|
||||
taskId = conf.NextTid
|
||||
//判断前置任务状态
|
||||
if conf.PreTid != 0 {
|
||||
if _, ok := utils.Findx(rtask.FrtaskIds, conf.PreTid); !ok {
|
||||
code = pb.ErrorCode_RtaskPreNoFinish
|
||||
return code, false
|
||||
}
|
||||
} else {
|
||||
//TODO
|
||||
}
|
||||
|
||||
if rtask, ok := this.moduleRtask.rtaskHandleMap[taskId]; ok {
|
||||
for _, handle := range rtask.handlers {
|
||||
if ok := handle.fn(handle.cfg, param); !ok {
|
||||
log.Infof("uid: %v do rtask %v condition not", uid, taskId)
|
||||
break
|
||||
}
|
||||
}
|
||||
rtaskId = taskId
|
||||
//验证限定条件
|
||||
for _, v := range conf.Condition {
|
||||
this.checkCondi(uid, v)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 确定选项前的校验
|
||||
func (this *ModelRtask) checkCondi(uid string, condiId int32) (ok bool) {
|
||||
//验证限定条件
|
||||
if condi, ok := this.moduleRtask.rtaskHandleMap[condiId]; ok {
|
||||
if ok = condi.fn(uid, condi.cfg); !ok {
|
||||
log.Infof("uid: %v do rtask %v condition not", uid, condiId)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 英雄指定
|
||||
func (this *ModelRtask) HeroTarget(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1
|
||||
func (this *ModelRtask) HeroTarget(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
h := heroModule.(comm.IHero)
|
||||
for _, v := range h.GetHeroList(uid) {
|
||||
if cast.ToString(cfg.Data1) == v.HeroID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 指定英雄的等级
|
||||
func (this *ModelRtask) HeroLvTarget(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1 && cfg.Data1 == tp.Param2
|
||||
func (this *ModelRtask) HeroLvTarget(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
h := heroModule.(comm.IHero)
|
||||
var hero *pb.DBHero
|
||||
for _, v := range h.GetHeroList(uid) {
|
||||
if cast.ToString(cfg.Data1) == v.HeroID {
|
||||
hero = v
|
||||
}
|
||||
}
|
||||
if hero != nil {
|
||||
return cast.ToString(cfg.Data1) == hero.HeroID && cfg.Data1 == hero.Lv
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 指定英雄的指定装备的数量
|
||||
func (this *ModelRtask) EquipNum(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1 && cfg.Data2 == tp.Param2 && cfg.Data3 == tp.Param3
|
||||
func (this *ModelRtask) EquipNum(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
h := heroModule.(comm.IHero)
|
||||
var hero *pb.DBHero
|
||||
for _, v := range h.GetHeroList(uid) {
|
||||
if cast.ToString(cfg.Data1) == v.HeroID {
|
||||
hero = v
|
||||
}
|
||||
}
|
||||
|
||||
var count int32
|
||||
if hero != nil {
|
||||
// 验证装备
|
||||
_, ok := utils.Findx(hero.EquipID, cast.ToString(cfg.Data2))
|
||||
// 验证数量
|
||||
for _, v := range hero.EquipID {
|
||||
if v != "0" {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return cast.ToString(cfg.Data1) == hero.HeroID &&
|
||||
ok && cfg.Data3 == count
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 剧情ID
|
||||
func (this *ModelRtask) PoltId(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1
|
||||
func (this *ModelRtask) PoltId(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
//TODO
|
||||
return false
|
||||
}
|
||||
|
||||
// 每日任务
|
||||
func (this *ModelRtask) TaskDay(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1
|
||||
func (this *ModelRtask) TaskDay(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
taskModule, err := this.service.GetModule(comm.ModuleTask)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
itask := taskModule.(comm.ITask)
|
||||
|
||||
if task := itask.GetTaskById(uid, cfg.Data1); task == nil {
|
||||
return false
|
||||
} else {
|
||||
//任务完成
|
||||
if task.Status == 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 指定英雄的星级
|
||||
func (this *ModelRtask) HeroStarTarget(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool) {
|
||||
return cfg.Data1 == tp.Param1 && cfg.Data2 == tp.Param2
|
||||
func (this *ModelRtask) HeroStarTarget(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
h := heroModule.(comm.IHero)
|
||||
|
||||
var hero *pb.DBHero
|
||||
for _, v := range h.GetHeroList(uid) {
|
||||
if cast.ToString(cfg.Data1) == v.HeroID {
|
||||
hero = v
|
||||
}
|
||||
}
|
||||
|
||||
if hero != nil {
|
||||
return cast.ToString(cfg.Data1) == hero.HeroID && cfg.Data2 == hero.Star
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
@ -6,15 +6,14 @@ import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
// 随机任务
|
||||
type rtask struct {
|
||||
rtaskId int32
|
||||
handlers []*rtaskCondi
|
||||
}
|
||||
// type rtask struct {
|
||||
// rtaskId int32
|
||||
// handlers []*rtaskCondi
|
||||
// }
|
||||
|
||||
// 限定条件
|
||||
type rtaskCondi struct {
|
||||
@ -23,7 +22,7 @@ type rtaskCondi struct {
|
||||
}
|
||||
|
||||
// 设定返回值
|
||||
type rtaskHandle func(cfg *cfg.GameRdtaskCondiData, tp *pb.RtaskParam) (ok bool)
|
||||
type rtaskHandle func(uid string, cfg *cfg.GameRdtaskCondiData) (ok bool)
|
||||
|
||||
type ModuleRtask struct {
|
||||
modules.ModuleBase
|
||||
@ -31,12 +30,12 @@ type ModuleRtask struct {
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
|
||||
rtaskHandleMap map[int32]*rtask // 任务处理器
|
||||
rtaskHandleMap map[int32]*rtaskCondi // 任务处理器
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
return &ModuleRtask{
|
||||
rtaskHandleMap: make(map[int32]*rtask),
|
||||
rtaskHandleMap: make(map[int32]*rtaskCondi),
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,58 +56,55 @@ func (this *ModuleRtask) OnInstallComp() {
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
func (this *ModuleRtask) register(rtaskId int32, rtask *rtask) {
|
||||
if _, ok := this.rtaskHandleMap[rtaskId]; !ok {
|
||||
this.rtaskHandleMap[rtaskId] = rtask
|
||||
func (this *ModuleRtask) register(condiId int32, rtask *rtaskCondi) {
|
||||
if _, ok := this.rtaskHandleMap[condiId]; !ok {
|
||||
this.rtaskHandleMap[condiId] = rtask
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ModuleRtask) initRtaskHandle() {
|
||||
if data, err := this.configure.getRtaskList(); err == nil {
|
||||
for _, v := range data {
|
||||
var handlers []*rtaskCondi
|
||||
rtask := &rtask{
|
||||
rtaskId: v.Id,
|
||||
handlers: handlers,
|
||||
conf, err := this.configure.getRtaskTypeCfg()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
//遍历任务的限定条件
|
||||
for _, rtaskTypeId := range v.Condition {
|
||||
// 获取每个限定条件配置
|
||||
if typeCfg, err2 := this.configure.getRtaskTypeById(rtaskTypeId); err2 == nil {
|
||||
for _, v := range conf.GetDataList() {
|
||||
if typeCfg, err := this.configure.getRtaskTypeById(v.Id); err == nil {
|
||||
if typeCfg != nil {
|
||||
switch comm.TaskType(typeCfg.GetTypeId()) {
|
||||
case comm.RtaskTypeHeroTarget:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.HeroTarget,
|
||||
})
|
||||
case comm.RtaskTypeHeroLvTarget:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.HeroLvTarget,
|
||||
})
|
||||
case comm.RtaskTypeHeroStarTarget:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.HeroStarTarget,
|
||||
})
|
||||
|
||||
case comm.RtaskTypeEquipNum:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.EquipNum,
|
||||
})
|
||||
|
||||
case comm.RtaskTypePoltId:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.PoltId,
|
||||
})
|
||||
|
||||
case comm.RtaskTypeTaskDay:
|
||||
handlers = append(handlers, &rtaskCondi{
|
||||
this.register(v.Id, &rtaskCondi{
|
||||
cfg: typeCfg,
|
||||
fn: this.modelRtask.TaskDay,
|
||||
})
|
||||
|
||||
default:
|
||||
log.Warnf("%v rtask type not configure", typeCfg.GetTypeId())
|
||||
}
|
||||
@ -116,23 +112,75 @@ func (this *ModuleRtask) initRtaskHandle() {
|
||||
}
|
||||
}
|
||||
|
||||
this.register(v.Id, rtask)
|
||||
// if data, err := this.configure.getRtaskList(); err == nil {
|
||||
// for _, v := range data {
|
||||
// // var handlers []*rtaskCondi
|
||||
// // rtask := &rtask{
|
||||
// // rtaskId: v.Id,
|
||||
// // handlers: handlers,
|
||||
// // }
|
||||
|
||||
}
|
||||
}
|
||||
// //遍历任务的限定条件
|
||||
// for _, rtaskTypeId := range v.Condition {
|
||||
// // 获取每个限定条件配置
|
||||
// if typeCfg, err2 := this.configure.getRtaskTypeById(rtaskTypeId); err2 == nil {
|
||||
// if typeCfg != nil {
|
||||
// switch comm.TaskType(typeCfg.GetTypeId()) {
|
||||
// case comm.RtaskTypeHeroTarget:
|
||||
// this.register(v.Id, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.HeroTarget,
|
||||
// })
|
||||
// case comm.RtaskTypeHeroLvTarget:
|
||||
// handlers = append(handlers, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.HeroLvTarget,
|
||||
// })
|
||||
// case comm.RtaskTypeHeroStarTarget:
|
||||
// handlers = append(handlers, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.HeroStarTarget,
|
||||
// })
|
||||
// case comm.RtaskTypeEquipNum:
|
||||
// handlers = append(handlers, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.EquipNum,
|
||||
// })
|
||||
// case comm.RtaskTypePoltId:
|
||||
// handlers = append(handlers, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.PoltId,
|
||||
// })
|
||||
// case comm.RtaskTypeTaskDay:
|
||||
// handlers = append(handlers, &rtaskCondi{
|
||||
// cfg: typeCfg,
|
||||
// fn: this.modelRtask.TaskDay,
|
||||
// })
|
||||
|
||||
// default:
|
||||
// log.Warnf("%v rtask type not configure", typeCfg.GetTypeId())
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// this.register(v.Id, rtask)
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// 通知随机任务
|
||||
func (this *ModuleRtask) SendToRtask(session comm.IUserSession, param *pb.RtaskParam) (code pb.ErrorCode) {
|
||||
if taskId, err := this.modelRtask.doRtaskHandle(session.GetUserId(), param); err != nil {
|
||||
code = pb.ErrorCode_TaskHandle
|
||||
} else {
|
||||
if err := session.SendMsg(string(comm.ModuleRtask), "", &pb.RtaskFinishPush{
|
||||
RtaskId: taskId,
|
||||
}); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
}
|
||||
// func (this *ModuleRtask) SendToRtask(session comm.IUserSession, param *pb.RtaskParam) (code pb.ErrorCode) {
|
||||
// if taskId, err := this.modelRtask.doRtaskHandle(session.GetUserId(), param); err != nil {
|
||||
// code = pb.ErrorCode_TaskHandle
|
||||
// } else {
|
||||
// if err := session.SendMsg(string(comm.ModuleRtask), "", &pb.RtaskFinishPush{
|
||||
// RtaskId: taskId,
|
||||
// }); err != nil {
|
||||
// code = pb.ErrorCode_SystemError
|
||||
// }
|
||||
// }
|
||||
|
||||
return
|
||||
}
|
||||
// return
|
||||
// }
|
||||
|
@ -76,6 +76,21 @@ func (this *ModuleTask) resetActive(uid string, taskTag comm.TaskTag) {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取玩家指定任务
|
||||
func (this *ModuleTask) GetTaskById(uid string, taskId int32) *pb.DBTask {
|
||||
list := []*pb.DBTask{}
|
||||
if err := this.modelTask.GetList(uid, &list); err != nil {
|
||||
log.Errorf("GetTaskById err %v", err)
|
||||
return nil
|
||||
}
|
||||
for _, v := range list {
|
||||
if v.TaskId == taskId {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//重置任务
|
||||
func (this *ModuleTask) ResetTask(uid string, taskTag comm.TaskTag) {
|
||||
this.resetActive(uid, taskTag)
|
||||
@ -123,6 +138,7 @@ func (this *ModuleTask) register(taskType comm.TaskType, fn taskHandle) {
|
||||
}
|
||||
}
|
||||
|
||||
// 初始任务事件处理类
|
||||
func (this *ModuleTask) initTaskHandle() {
|
||||
if data, err := this.configure.getTaskList(); err == nil {
|
||||
for _, v := range data {
|
||||
|
@ -80,7 +80,7 @@ type DBChat struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //主键id
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
|
||||
Channel ChatChannel `protobuf:"varint,2,opt,name=channel,proto3,enum=ChatChannel" json:"channel"` //频道
|
||||
Suid string `protobuf:"bytes,3,opt,name=suid,proto3" json:"suid"` //发送用户id
|
||||
Slv int32 `protobuf:"varint,4,opt,name=slv,proto3" json:"slv"` //发送者等级
|
||||
|
@ -155,6 +155,7 @@ const (
|
||||
ErrorCode_RtaskUnFinished ErrorCode = 2202 //任务未完成
|
||||
ErrorCode_RtaskNoRtask ErrorCode = 2203 //任务未开启
|
||||
ErrorCode_RtaskRewarded ErrorCode = 2204 //已获取奖励
|
||||
ErrorCode_RtaskPreNoFinish ErrorCode = 2205 //前置未完成
|
||||
)
|
||||
|
||||
// Enum value maps for ErrorCode.
|
||||
@ -279,6 +280,7 @@ var (
|
||||
2202: "RtaskUnFinished",
|
||||
2203: "RtaskNoRtask",
|
||||
2204: "RtaskRewarded",
|
||||
2205: "RtaskPreNoFinish",
|
||||
}
|
||||
ErrorCode_value = map[string]int32{
|
||||
"Success": 0,
|
||||
@ -400,6 +402,7 @@ var (
|
||||
"RtaskUnFinished": 2202,
|
||||
"RtaskNoRtask": 2203,
|
||||
"RtaskRewarded": 2204,
|
||||
"RtaskPreNoFinish": 2205,
|
||||
}
|
||||
)
|
||||
|
||||
@ -434,7 +437,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_errorcode_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2a, 0xfb, 0x13, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x6f, 0x2a, 0x92, 0x14, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
||||
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
||||
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
@ -593,8 +596,10 @@ var file_errorcode_proto_rawDesc = []byte{
|
||||
0x99, 0x11, 0x12, 0x14, 0x0a, 0x0f, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x55, 0x6e, 0x46, 0x69, 0x6e,
|
||||
0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0x9a, 0x11, 0x12, 0x11, 0x0a, 0x0c, 0x52, 0x74, 0x61, 0x73,
|
||||
0x6b, 0x4e, 0x6f, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x10, 0x9b, 0x11, 0x12, 0x12, 0x0a, 0x0d, 0x52,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x65, 0x64, 0x10, 0x9c, 0x11, 0x42,
|
||||
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x65, 0x64, 0x10, 0x9c, 0x11, 0x12,
|
||||
0x15, 0x0a, 0x10, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x65, 0x4e, 0x6f, 0x46, 0x69, 0x6e,
|
||||
0x69, 0x73, 0x68, 0x10, 0x9d, 0x11, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -151,7 +151,7 @@ type DBHero struct {
|
||||
IsOverlying bool `protobuf:"varint,23,opt,name=isOverlying,proto3" json:"isOverlying"` // go_tags(`bson:"isOverlying"`) 是否允许叠加 默认true
|
||||
EnergyProperty map[string]int32 `protobuf:"bytes,24,rep,name=energyProperty,proto3" json:"energyProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"energyProperty"` //
|
||||
JuexProperty map[string]int32 `protobuf:"bytes,25,rep,name=juexProperty,proto3" json:"juexProperty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"juexProperty"` ////hp
|
||||
Status HeroType `protobuf:"varint,26,opt,name=status,proto3,enum=HeroType" json:"status" bson:"heroType"` //状态 (1 练功)
|
||||
Status HeroType `protobuf:"varint,26,opt,name=status,proto3,enum=HeroType" json:"status"` // 状态 (1 练功)
|
||||
}
|
||||
|
||||
func (x *DBHero) Reset() {
|
||||
|
Loading…
Reference in New Issue
Block a user