bingo worldtask

This commit is contained in:
wh_zcy 2023-05-29 15:23:48 +08:00
parent 0c0615b756
commit e1e364f9c2
4 changed files with 103 additions and 9 deletions

View File

@ -64,9 +64,11 @@ func (this *BingoView) CreateView(t *model.TestCase) fyne.CanvasObject {
var bingo string var bingo string
if ttxt == "" && nEntry.Text == "" { if ttxt == "" && nEntry.Text == "" {
bingo = fmt.Sprintf("bingo:%s", aSel.Selected) bingo = fmt.Sprintf("bingo:%s", aSel.Selected)
} else if ttxt == "" { } else if ttxt != "" && nEntry.Text == "" {
bingo = fmt.Sprintf("bingo:%s,%s", aSel.Selected, ttxt)
} else if ttxt == "" && nEntry.Text != "" {
bingo = fmt.Sprintf("bingo:%s,%s", aSel.Selected, nEntry.Text) bingo = fmt.Sprintf("bingo:%s,%s", aSel.Selected, nEntry.Text)
} else { } else if ttxt != "" && nEntry.Text != "" {
bingo = fmt.Sprintf("bingo:%s,%s,%s", aSel.Selected, ttxt, nEntry.Text) bingo = fmt.Sprintf("bingo:%s,%s,%s", aSel.Selected, ttxt, nEntry.Text)
} }
logrus.Info(bingo) logrus.Info(bingo)

View File

@ -396,6 +396,8 @@ type (
TaskCondFinishNotify(session IUserSession, condIds []int32) error TaskCondFinishNotify(session IUserSession, condIds []int32) error
// bingo任务 // bingo任务
BingoJumpTask(session IUserSession, groupId, rtaskId int32) error BingoJumpTask(session IUserSession, groupId, rtaskId int32) error
// 通过任务ID bingo
JumpTaskByTaskId(session IUserSession, rtaskId int32) error
// 查询我的世界任务 // 查询我的世界任务
GetMyWorldtask(uid string) *pb.DBWorldtask GetMyWorldtask(uid string) *pb.DBWorldtask
// 获取分组任务 // 获取分组任务

View File

@ -33,33 +33,33 @@ type GM struct {
configure *configureComp configure *configureComp
} }
//模块名 // 模块名
func (this *GM) GetType() core.M_Modules { func (this *GM) GetType() core.M_Modules {
return comm.ModuleGM return comm.ModuleGM
} }
//模块初始化接口 注册用户创建角色事件 // 模块初始化接口 注册用户创建角色事件
func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *GM) 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.(base.IRPCXService) this.service = service.(base.IRPCXService)
return return
} }
//模块初始化接口 注册用户创建角色事件 // 模块初始化接口 注册用户创建角色事件
func (this *GM) Start() (err error) { func (this *GM) Start() (err error) {
err = this.ModuleBase.Start() err = this.ModuleBase.Start()
this.service.RegisterFunctionName(string(comm.Rpc_ModuleGMCreateCmd), this.Rpc_ModuleGMCreateCmd) this.service.RegisterFunctionName(string(comm.Rpc_ModuleGMCreateCmd), this.Rpc_ModuleGMCreateCmd)
return return
} }
//装备组件 // 装备组件
func (this *GM) OnInstallComp() { func (this *GM) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
} }
//bingo:Iamyoudad // bingo:Iamyoudad
func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorCode) { func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorCode) {
cmd = strings.Replace(cmd, " ", "", -1) // 去空格 cmd = strings.Replace(cmd, " ", "", -1) // 去空格
@ -162,6 +162,19 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
) )
} }
} }
} else if len(datas) == 2 && (datas[0] == "worldtask") {
module, err := this.service.GetModule(comm.ModuleWorldtask)
if err != nil {
return
}
if wt, ok := module.(comm.IWorldtask); ok {
if err = wt.JumpTaskByTaskId(session, utils.ToInt32(datas[1])); err != nil {
this.Error("bingo 世界任务",
log.Field{Key: "params", Value: datas},
log.Field{Key: "err", Value: err.Error()},
)
}
}
} else if len(datas) == 1 && (datas[0] == "manhero") { // 获取满星、等级、觉醒、共鸣技能 } else if len(datas) == 1 && (datas[0] == "manhero") { // 获取满星、等级、觉醒、共鸣技能
module1, err := this.service.GetModule(comm.ModuleHero) module1, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {

View File

@ -190,7 +190,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
//遍历 //遍历
if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 { if taskConf.Ontxe != 0 && taskConf.IdAfter != 0 {
for _, v := range this.worldtaskConf.GetDataList() { for _, v := range this.worldtaskConf.GetDataList() {
if v.Group == groupId && v.Key <= taskId && v.Des == 2 { //只做主线的des=2 if v.Group == groupId && v.Key <= taskId && v.Des == 2 {
mytask.TaskList = append(mytask.TaskList, v.Key) mytask.TaskList = append(mytask.TaskList, v.Key)
} }
} }
@ -202,7 +202,7 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
"taskList": mytask.TaskList, "taskList": mytask.TaskList,
} }
//当前任务 //下个任务
nextTaskIds := this.modelWorldtask.findNextTasks(taskId) nextTaskIds := this.modelWorldtask.findNextTasks(taskId)
if mytask.CurrentTask == nil { if mytask.CurrentTask == nil {
@ -226,6 +226,73 @@ func (this *Worldtask) BingoJumpTask(session comm.IUserSession, groupId, taskId
return session.SendMsg(string(this.GetType()), "finishids", rsp) return session.SendMsg(string(this.GetType()), "finishids", rsp)
} }
// 通过任务ID bingo
func (this *Worldtask) JumpTaskByTaskId(session comm.IUserSession, taskId int32) error {
uid := session.GetUserId()
//查询当前世界任务数据
mytask, err := this.modelWorldtask.getWorldtask(uid)
if err != nil {
return err
}
// 如果是空 或Uid是空 初始一条基础数据
if mytask == nil {
mytask = &pb.DBWorldtask{}
mytask.Uid = uid
if err := this.modelWorldtask.Add(uid, mytask); err != nil {
this.Error("添加世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
return err
}
} else if mytask.Uid == "" {
update := map[string]interface{}{
"uid": uid,
}
if err := this.modelWorldtask.Change(uid, update); err != nil {
this.Error("更新世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err})
return err
}
}
//重置taskList
mytask.TaskList = []int32{}
// 判断任务ID是否已完成
// if _, ok := utils.Findx(mytask.TaskList, taskId); ok {
// this.Error("GM 世界任务已完成", log.Field{Key: "taskId", Value: taskId})
// return comm.NewCustomError(pb.ErrorCode_WorldtaskFinihed)
// }
// 获取当前bingo的任务配置
taskConf := this.worldtaskConf.GetDataMap()[taskId]
if taskConf == nil {
return comm.NewCustomError(pb.ErrorCode_ConfigNoFound)
}
// 返回所有前置任务
mytask.TaskList = this.recursionTasks(taskId, mytask.TaskList)
update := map[string]interface{}{
"taskList": mytask.TaskList,
}
if mytask.CurrentTask == nil {
mytask.CurrentTask = make(map[int32]*pb.Worldtask)
}
mytask.CurrentTask[taskConf.Group] = &pb.Worldtask{
TaskId: taskId,
TaskType: taskConf.Des,
}
update["currentTask"] = mytask.CurrentTask
if err := this.modelWorldtask.Change(uid, update); err != nil {
return err
}
rsp := &pb.WorldtaskFinishIdsPush{}
return session.SendMsg(string(this.GetType()), "finishids", rsp)
}
// 返回任务ID // 返回任务ID
func (this *Worldtask) GetWorldTaskBy(session comm.IUserSession, groupId int32) (taskId int32) { func (this *Worldtask) GetWorldTaskBy(session comm.IUserSession, groupId int32) (taskId int32) {
uid := session.GetUserId() uid := session.GetUserId()
@ -331,3 +398,13 @@ func (this *Worldtask) UpdateTaskStatus(uid string, taskId int32) {
} }
} }
func (this *Worldtask) recursionTasks(taskId int32, taskList []int32) []int32 {
if taskConf, ok := this.worldtaskConf.GetDataMap()[taskId]; ok {
if taskConf.Ontxe > 0 {
taskList = append(taskList, taskConf.Ontxe)
this.recursionTasks(taskConf.Ontxe, taskList)
}
}
return taskList
}