diff --git a/cmd/v2/ui/views/dispatch.go b/cmd/v2/ui/views/dispatch.go index b7ec9c3e1..a7860b0df 100644 --- a/cmd/v2/ui/views/dispatch.go +++ b/cmd/v2/ui/views/dispatch.go @@ -41,7 +41,7 @@ func (d *DispatchView) CreateView(t *model.TestCase) fyne.CanvasObject { //玩家公告 d.noticeLabl = new(widget.Label) - noticeBtn := widget.NewButton("玩家公告", func() { + noticeFun := func() { d.itemList.Reset() if err := service.GetPttService().SendToClient( t.MainType, @@ -51,7 +51,9 @@ func (d *DispatchView) CreateView(t *model.TestCase) fyne.CanvasObject { logrus.Error(err) return } - + } + noticeBtn := widget.NewButton("玩家公告", func() { + noticeFun() }) //刷新公告 refreshBtn := widget.NewButton("刷新公告", func() { @@ -63,6 +65,7 @@ func (d *DispatchView) CreateView(t *model.TestCase) fyne.CanvasObject { logrus.Error(err) return } + noticeFun() }) //领取奖励 diff --git a/cmd/v2/ui/views/worldtask_mine.go b/cmd/v2/ui/views/worldtask_mine.go index 2605444a3..86d7774ad 100644 --- a/cmd/v2/ui/views/worldtask_mine.go +++ b/cmd/v2/ui/views/worldtask_mine.go @@ -125,7 +125,7 @@ func (this *WorldtaskMineView) CreateView(t *model.TestCase) fyne.CanvasObject { widget.NewFormItem("任务ID", taskIdEntry), ) - dconf := dialog.NewCustom("接取任务", "关闭", form, this.w) + dconf := dialog.NewCustom("交付任务", "关闭", form, this.w) form.OnSubmit = func() { if err := service.GetPttService().SendToClient( @@ -156,7 +156,7 @@ func (this *WorldtaskMineView) CreateView(t *model.TestCase) fyne.CanvasObject { widget.NewFormItem("任务ID", taskIdEntry), ) - dconf := dialog.NewCustom("接取任务", "关闭", form, this.w) + dconf := dialog.NewCustom("战斗完成", "关闭", form, this.w) form.OnSubmit = func() { if err := service.GetPttService().SendToClient( @@ -176,7 +176,33 @@ func (this *WorldtaskMineView) CreateView(t *model.TestCase) fyne.CanvasObject { dconf.Resize(fyne.NewSize(400, 200)) dconf.Show() }) - barBtn := container.NewHBox(refreshBtn, acceptBtn, completeBtn, this.juqingBtn, battleBtn) + + // 章节奖励 + chapterBtn := widget.NewButton("章节奖励", func() { + groupId := widget.NewEntry() + groupId.PlaceHolder = "章节ID" + form := widget.NewForm( + widget.NewFormItem("章节ID", groupId), + ) + dconf := dialog.NewCustom("章节奖励", "关闭", form, this.w) + form.OnSubmit = func() { + if err := service.GetPttService().SendToClient( + t.MainType, + "chapterreward", + &pb.WorldtaskChapterawardReq{ + GroupId: cast.ToInt32(groupId.Text), + }); err != nil { + logrus.Error(err) + } + dconf.Hide() + } + form.SubmitText = "确定" + + dconf.Resize(fyne.NewSize(400, 200)) + dconf.Show() + }) + + barBtn := container.NewHBox(refreshBtn, acceptBtn, completeBtn, this.juqingBtn, battleBtn, chapterBtn) c := container.NewBorder(barBtn, nil, nil, nil, this.itemList.ItemList) this.mineData() diff --git a/comm/const.go b/comm/const.go index ca6adca4f..ffb4c143a 100644 --- a/comm/const.go +++ b/comm/const.go @@ -129,8 +129,7 @@ const ( TablePagoda = "pagoda" ///武馆数据表 TableMartialhall = "martialhall" - // 美食馆 - TableGourmet = "gourmet" + // 随机任务 TableRtask = "rtask" // 随机任务触发记录 diff --git a/modules/gourmet/api_createorder.go b/modules/gourmet/api_createorder.go deleted file mode 100644 index ff54ee241..000000000 --- a/modules/gourmet/api_createorder.go +++ /dev/null @@ -1,149 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - "go_dreamfactory/sys/configure" - cfg "go_dreamfactory/sys/configure/structs" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode) { - if len(req.Order) == 0 { - code = pb.ErrorCode_ReqParameterError - return - } - return -} - -///美食城创建订单 -func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) { - var ( - res []*cfg.Gameatn // 订单消耗 - costTime int32 // 当前订单的总耗时 - szTime map[int32]int32 // 记录每个类型的订单耗时 key 是技能组type value 订单耗时 - privilegeAddItme int32 // 特权额外增加的时间 - ) - szTime = make(map[int32]int32, 0) - code = this.CreateOrderCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - // 记录每个食材耗时 - for k, v := range _gourmet.Skill { - _skillCfg := this.module.configure.GetGourmetConfigData(k, v) - szTime[k] += _skillCfg.Needtime - // 高效制作技能 - for k1, v1 := range _gourmet.SpecialSkill { - specalSkill := this.module.configure.GetGourmetConfigData(k1, v1) - szTime[k] += specalSkill.Needtime - } - } - - // if !utils.IsToday(_gourmet.Ctime) { // 跨天了 - // _gourmet.Ctime = configure.Now().Unix() - // _gourmet.OrderCostTime = 0 - // } - // 计算消耗 - for _, order := range req.Order { - if order.FoodCount == 0 { - continue - } - if v, ok := szTime[order.FoodType]; ok { - costTime += v * order.FoodCount - } - if v, ok := _gourmet.Skill[order.FoodType]; ok { - conf := this.module.configure.GetGourmetConfigData(order.FoodType, v) - res = append(res, conf.DeliciousConsume...) - } - } - - // 校验时间 - cfgCom := this.module.configure.GetGlobalConf() // 获取总的下单时长 - if cfgCom == nil { - return - } - privilegeAddItme = this.module.ModulePrivilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType8) - _gourmet.OrderCostTime += costTime - if cfgCom.Gourmet+privilegeAddItme < _gourmet.OrderCostTime { // 大于总时长是不允许的 - code = pb.ErrorCode_GourmetMoreOrderTime - return - } - - if _gourmet.Foods == nil { // 队列数据为nil 直接将订单数据给ta - _gourmet.Foods = req.Order - } else { - for _, v := range req.Order { - bFound := false - for _, v1 := range _gourmet.Foods { - if v.FoodType == v1.FoodType { - v1.FoodCount += v.FoodCount // 加对应的数量 - bFound = true - break - } - } - if !bFound { - _gourmet.Foods = append(_gourmet.Foods, v) - } - } - } - // 重新计算时间 - for _, v := range _gourmet.Foods { - if v1, ok := szTime[v.FoodType]; ok { - v.CookTime = v1 * v.FoodCount - } - } - if _gourmet.CookingFood != nil && _gourmet.CookingFood.ETime == 0 { - _gourmet.CookingFood = nil - } - if _gourmet.CookingFood == nil { - for _, v := range _gourmet.Foods { - if v.FoodCount > 0 { - v.FoodCount-- - v.CookTime = v.FoodCount * szTime[v.FoodType] - // 获取生产时间 - _gourmet.CookingFood = &pb.Cooking{ - FoodType: v.FoodType, - ETime: configure.Now().Unix() + int64(szTime[v.FoodType]), - STime: configure.Now().Unix(), - } - if v.FoodCount == 0 { - v.CookTime = 0 - } - if _gourmet.Ctime == 0 { - _gourmet.Ctime = configure.Now().Unix() - } - break - } - } - } - - if code = this.module.ConsumeRes(session, res, true); code != pb.ErrorCode_Success { // 消耗校验 - return - } - - // 校验通过 写数据 - mapData := make(map[string]interface{}, 0) - mapData["foods"] = _gourmet.Foods - mapData["orderCostTime"] = _gourmet.OrderCostTime - mapData["cookingFood"] = _gourmet.CookingFood // 正在做的 - mapData["ctime"] = _gourmet.Ctime - code = this.module.ModifyGourmetData(session.GetUserId(), mapData) - - session.SendMsg(string(this.module.GetType()), GourmetCreateOrderResp, &pb.GourmetCreateOrderResp{Data: _gourmet}) - - iTotal := 0 - for _, v := range req.Order { - iTotal += int(v.FoodCount) - } - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype150, int32(iTotal)) - go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype150, int32(iTotal))) - return -} diff --git a/modules/gourmet/api_foodskilllv.go b/modules/gourmet/api_foodskilllv.go deleted file mode 100644 index aacd31ed9..000000000 --- a/modules/gourmet/api_foodskilllv.go +++ /dev/null @@ -1,70 +0,0 @@ -package gourmet - -import ( - "crypto/rand" - "go_dreamfactory/comm" - "go_dreamfactory/pb" - "math/big" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) SkillLVCheck(session comm.IUserSession, req *pb.GourmetSkillLvReq) (code pb.ErrorCode) { - if req.SkillType == 0 { - code = pb.ErrorCode_ReqParameterError - } - return -} - -///美食城厨师技能升级 -func (this *apiComp) SkillLV(session comm.IUserSession, req *pb.GourmetSkillLvReq) (code pb.ErrorCode, dat proto.Message) { - var ( - bSpecial bool // 是不是特殊技能 - ) - code = this.SkillLVCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - - skilllv, ok := _gourmet.Skill[req.SkillType] - if !ok { // 校验技能存不存在 - skilllv, ok = _gourmet.SpecialSkill[req.SkillType] - if !ok { - code = pb.ErrorCode_ReqParameterError - return - } - bSpecial = true - } - - if this.module.configure.GetGourmetConfigData(req.SkillType, skilllv+1) == nil { // 下一级是否存在 - code = pb.ErrorCode_GourmetSkillMaxLv - return - } - _skillCfg := this.module.configure.GetGourmetConfigData(req.SkillType, skilllv) // 获取技能配置 - - code = this.module.ConsumeRes(session, _skillCfg.SkillConsume, true) // 消耗检测 - if code != pb.ErrorCode_Success { - return - } - // 概率升级 - n, _ := rand.Int(rand.Reader, big.NewInt(1000)) - - if n.Int64() < int64(_skillCfg.Probability) { // 可以升级 - // 技能升级成功 - if bSpecial { // 通用技能升级 - _gourmet.SpecialSkill[req.SkillType] += 1 - this.module.modelGourmet.CalculationSpecialSkillLv(session.GetUserId(), _gourmet, req.SkillType, _gourmet.SpecialSkill[req.SkillType]) - } else { // 某一类型技能升级 - _gourmet.Skill[req.SkillType] += 1 - this.module.modelGourmet.CalculationGourmetbySkiiLv(session.GetUserId(), _gourmet, req.SkillType, _gourmet.Skill[req.SkillType]) - } - } - session.SendMsg(string(this.module.GetType()), GourmetSkillLvResp, &pb.GourmetSkillLvResp{Data: _gourmet}) - return -} diff --git a/modules/gourmet/api_getReward.go b/modules/gourmet/api_getReward.go deleted file mode 100644 index 86d1e2b6a..000000000 --- a/modules/gourmet/api_getReward.go +++ /dev/null @@ -1,42 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) GetRewardCheck(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode) { - - return -} - -///美食城领取奖励 -func (this *apiComp) GetReward(session comm.IUserSession, req *pb.GourmetGetRewardReq) (code pb.ErrorCode, data proto.Message) { - code = this.GetRewardCheck(session, req) - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - if len(_gourmet.Items) > 0 { - res := make([]*cfg.Gameatn, 0) - for _, v := range _gourmet.Items { - res = append(res, &cfg.Gameatn{ - A: v.A, - T: v.T, - N: v.N, - }) - } - code = this.module.DispenseRes(session, res, true) - _gourmet.Items = nil - mapData := make(map[string]interface{}, 0) - mapData["items"] = nil - code = this.module.ModifyGourmetData(session.GetUserId(), mapData) - } - session.SendMsg(string(this.module.GetType()), GourmetGetRewardResp, &pb.GourmetGetRewardResp{Data: _gourmet}) - return -} diff --git a/modules/gourmet/api_getlist.go b/modules/gourmet/api_getlist.go deleted file mode 100644 index c791c1fb6..000000000 --- a/modules/gourmet/api_getlist.go +++ /dev/null @@ -1,37 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/pb" - - "google.golang.org/protobuf/proto" -) - -//参数校验 -func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.GourmetGetListReq) (code pb.ErrorCode) { - - return -} - -///获取美食城基本信息 -func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListReq) (code pb.ErrorCode, data proto.Message) { - - code = this.GetListCheck(session, req) - if code != pb.ErrorCode_Success { - return // 参数校验失败直接返回 - } - _gourmet, err := this.module.modelGourmet.getGourmetList(session.GetUserId()) - if err != nil { - code = pb.ErrorCode_DBError - return - } - - // 计算订单信息 - this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _gourmet) - session.SendMsg(string(this.module.GetType()), GourmetGetListResp, &pb.GourmetGetListResp{Data: _gourmet}) - - // 任务统计 - // this.module.ModuleRtask.SendToRtask(session, comm.Rtype136, _gourmet.TotalTime) - go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype136, _gourmet.TotalTime)) - return -} diff --git a/modules/gourmet/comp_configure.go b/modules/gourmet/comp_configure.go index f982649a2..e9f437445 100644 --- a/modules/gourmet/comp_configure.go +++ b/modules/gourmet/comp_configure.go @@ -6,21 +6,18 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" - "sync" ) const ( - game_gourmet = "game_gourmet.json" - game_food = "game_breakingbad.json" + //game_gourmet = "game_gourmet.json" + game_food = "game_breakingbad.json" ) ///配置管理基础组件 type configureComp struct { - hlock sync.RWMutex modules.MCompConfigure - _gourmetMap map[int64]*cfg.GameGourmetData - module *Gourmet - normal string + module *Gourmet + normal string } //组件初始化接口 @@ -30,33 +27,12 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp err = this.LoadMultiConfigure(map[string]interface{}{ game_food: cfg.NewGameBreakingbad, }) - this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0) - configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() { - if v, err := this.GetConfigure(game_gourmet); err == nil { - if configure, ok := v.(*cfg.GameGourmet); ok { - this.hlock.Lock() - defer this.hlock.Unlock() - for _, value := range configure.GetDataList() { - this._gourmetMap[int64(value.Type<<16)+int64(value.Level)] = value - } - return - } - } - log.Errorf("get game_pagoda conf err:%v", err) - return - }) configure.RegisterConfigure(game_food, cfg.NewGameBreakingbad, this.SetGrormetCookBookConf) return } -// 获取美食馆配置数据 -func (this *configureComp) GetGourmetConfigData(gourmetType int32, level int32) (data *cfg.GameGourmetData) { - - return this._gourmetMap[int64(gourmetType<<16)+int64(level)] -} - //加载多个配置文件 func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) { for k, v := range confs { @@ -73,22 +49,6 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } -func (this *configureComp) GetGourmetSkillConfigBySkillType(skillType int32) (data []int32) { - data = make([]int32, 0) - if v, err := this.GetConfigure(game_gourmet); err == nil { - if configure, ok := v.(*cfg.GameGourmet); ok { - this.hlock.Lock() - defer this.hlock.Unlock() - for _, value := range configure.GetDataList() { - if value.SkillType == skillType && value.Initial == 1 { - data = append(data, value.Type) - } - } - return - } - } - return -} func (this *configureComp) SetGrormetCookBookConf() { diff --git a/modules/gourmet/model_gourmet.go b/modules/gourmet/model_gourmet.go deleted file mode 100644 index 06dce9310..000000000 --- a/modules/gourmet/model_gourmet.go +++ /dev/null @@ -1,202 +0,0 @@ -package gourmet - -import ( - "go_dreamfactory/comm" - "go_dreamfactory/lego/core" - "go_dreamfactory/lego/sys/redis" - "go_dreamfactory/modules" - "go_dreamfactory/pb" - "go_dreamfactory/sys/configure" - "go_dreamfactory/utils" - - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/x/bsonx" -) - -type modelGourmet struct { - modules.MCompModel - module *Gourmet -} - -func (this *modelGourmet) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.TableName = string(comm.TableGourmet) - err = this.MCompModel.Init(service, module, comp, options) - this.module = module.(*Gourmet) - // uid 创建索引 - this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ - Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, - }) - return -} - -func (this *modelGourmet) getGourmetList(uid string) (result *pb.DBGourmet, err error) { - result = &pb.DBGourmet{} - if err = this.Get(uid, result); err != nil { - if redis.RedisNil != err { // 没有数据直接创建新的数据 - - result.Id = primitive.NewObjectID().Hex() - result.Uid = uid - result.Skill = make(map[int32]int32, 0) - szSkill := this.module.configure.GetGourmetSkillConfigBySkillType(1) // 查表获取初始技能 - for _, v := range szSkill { - result.Skill[v] = 1 - } - - szSpecailSkill := this.module.configure.GetGourmetSkillConfigBySkillType(2) // 高效制作 等通用技能 - result.SpecialSkill = make(map[int32]int32, 0) - for _, v := range szSpecailSkill { - result.SpecialSkill[v] = 1 - } - result.SpecialSkill[1005] = 1 // 通用技能 - if err = this.Add(uid, result); err != nil { - this.module.Errorf("err:%v", err) - err = nil - return - } - } - return - } - err = nil - return result, err -} -func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]interface{}) error { - return this.Change(uid, data) -} - -// 计算订单信息 -func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) { - var ( - szTime map[int32]int32 // 食材耗时 - zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了 - ) - mapData := make(map[string]interface{}, 0) - szTime = make(map[int32]int32, 0) - - // 记录每个食材耗时 - for k, v := range gourmet.Skill { - // 计算出需要的时间 - _skillCfg := this.module.configure.GetGourmetConfigData(k, v) - szTime[k] += _skillCfg.Needtime - // 高效制作技能 - for k1, v1 := range gourmet.SpecialSkill { - specalSkill := this.module.configure.GetGourmetConfigData(k1, v1) - szTime[k] += specalSkill.Needtime - } - } - - // 有订单在做 - zeroTime = utils.GetTodayZeroTime(configure.Now().Unix()) - - if (gourmet.CookingFood != nil && gourmet.CookingFood.ETime >= configure.Now().Unix()) || gourmet.CookingFood == nil { - for _, order := range gourmet.Foods { - _gourmetcfg := this.module.configure.GetGourmetConfigData(order.FoodType, gourmet.Skill[order.FoodType]) // 美食家配置表 - if order.FoodCount > 0 { - if gourmet.CookingFood.ETime > configure.Now().Unix() { - break - } - order.FoodCount-- - if order.FoodCount == 0 { - order.CookTime = 0 - } - order.CookTime = order.FoodCount * szTime[order.FoodType] - if gourmet.CookingFood == nil { - gourmet.CookingFood = &pb.Cooking{} - gourmet.CookingFood.STime = configure.Now().Unix() - gourmet.CookingFood.ETime = configure.Now().Unix() + int64(szTime[order.FoodType]) - // 如果此时跨天了 清除订单时常 - if gourmet.CookingFood.STime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时 - gourmet.OrderCostTime = 0 - for _, order := range gourmet.Foods { // 重新计算订单时常 - gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType] - } - } - } else { - gourmet.CookingFood.STime += int64(szTime[order.FoodType]) - oldTime := gourmet.CookingFood.ETime - gourmet.CookingFood.ETime += int64(szTime[order.FoodType]) - // 如果此时跨天了 清除订单时常 - if oldTime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时 - gourmet.OrderCostTime = 0 - for _, order := range gourmet.Foods { // 重新计算订单时常 - gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType] - } - } - } - gourmet.CookingFood.FoodType = order.FoodType - // 设置掉落组 - gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励 - // 记录下订单时间 - gourmet.Ctime = gourmet.CookingFood.ETime - gourmet.TotalTime += szTime[order.FoodType] - } - } - - if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= configure.Now().Unix() { - _gourmetcfg := this.module.configure.GetGourmetConfigData(gourmet.CookingFood.FoodType, gourmet.Skill[gourmet.CookingFood.FoodType]) - gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) - gourmet.CookingFood = nil - } - } - - // 保存信息 - mapData["items"] = gourmet.Items - mapData["foods"] = gourmet.Foods - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["cookingFood"] = gourmet.CookingFood // 正在做的 - mapData["totalTime"] = gourmet.TotalTime - mapData["ctime"] = gourmet.Ctime - this.module.ModifyGourmetData(uid, mapData) // 同步数据 -} - -// 技能等级提高了 重新计算订单时间(只对订单中数据有影响) -func (this *modelGourmet) CalculationGourmetbySkiiLv(uid string, gourmet *pb.DBGourmet, skillType int32, skilllv int32) { - mapData := make(map[string]interface{}, 0) - var totalTime int32 - for _, v := range gourmet.Foods { - if v.FoodCount > 0 && v.FoodType == skillType { - _skillCfg := this.module.configure.GetGourmetConfigData(skillType, skilllv) - if _skillCfg != nil { - totalTime += _skillCfg.Needtime * v.FoodCount - v.CookTime += totalTime - mapData["foods"] = gourmet.Foods - } - break - } - } - // 总时间也减少了 - gourmet.OrderCostTime += totalTime - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["skill"] = gourmet.Skill - this.module.ModifyGourmetData(uid, mapData) -} - -// 升级高效制作技能重计算时间消耗 -func (this *modelGourmet) CalculationSpecialSkillLv(uid string, gourmet *pb.DBGourmet, skillType int32, skilllv int32) { - mapData := make(map[string]interface{}, 0) - var totalTime int32 - for _, v := range gourmet.Foods { - if v.FoodCount > 0 { - preScaleTime := 0 - preSkillConf := this.module.configure.GetGourmetConfigData(skillType, skilllv-1) - if preSkillConf != nil { - preScaleTime = int(preSkillConf.Needtime) - } - _skillCfg := this.module.configure.GetGourmetConfigData(skillType, skilllv) - if _skillCfg != nil { - scaleTime := (_skillCfg.Needtime - int32(preScaleTime)) * v.FoodCount - totalTime += scaleTime - v.CookTime += scaleTime - if v.CookTime < 0 { // 担心配置错误 为负数情况 所以这里做下判断 - v.CookTime = 0 - } - } - } - } - // 总时间也减少了 - mapData["foods"] = gourmet.Foods - gourmet.OrderCostTime += totalTime - mapData["orderCostTime"] = gourmet.OrderCostTime - mapData["specialSkill"] = gourmet.SpecialSkill - this.module.ModifyGourmetData(uid, mapData) -} diff --git a/modules/gourmet/module.go b/modules/gourmet/module.go index 219ae351c..e75058532 100644 --- a/modules/gourmet/module.go +++ b/modules/gourmet/module.go @@ -10,17 +10,15 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" - "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "math/big" ) type Gourmet struct { modules.ModuleBase - modelGourmet *modelGourmet - api *apiComp - configure *configureComp - modelAtlas *modelAtlas + api *apiComp + configure *configureComp + modelAtlas *modelAtlas } func NewModule() core.IModule { @@ -40,115 +38,15 @@ func (this *Gourmet) Init(service core.IService, module core.IModule, options co func (this *Gourmet) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) - this.modelGourmet = this.RegisterComp(new(modelGourmet)).(*modelGourmet) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelAtlas = this.RegisterComp(new(modelAtlas)).(*modelAtlas) } -// 接口信息 -func (this *Gourmet) ModifyGourmetData(uid string, data map[string]interface{}) (code pb.ErrorCode) { - err := this.modelGourmet.modifyGourmetDataByObjId(uid, data) - if err != nil { - code = pb.ErrorCode_DBError - } - return -} - //红点查询 func (this *Gourmet) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { - reddot = make(map[comm.ReddotType]bool) - for _, v := range rid { - switch v { - case comm.Reddot20: - reddot[comm.Reddot20] = this.CheckPoint20(session.GetUserId()) - break - case comm.Reddot21: - reddot[comm.Reddot21] = this.CheckPoint21(session.GetUserId()) - break - case comm.Reddot22: - reddot[comm.Reddot22] = this.CheckPoint22(session.GetUserId()) - break - } - } return } -func (this *Gourmet) CheckPoint20(uid string) bool { - - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - return false - } - if _gourmet.OrderCostTime > 0 { - return false - } - return true -} - -func (this *Gourmet) CheckPoint21(uid string) bool { - - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - - return false - } - for skillType := range _gourmet.Skill { - skilllv, _ := _gourmet.Skill[skillType] - if this.configure.GetGourmetConfigData(skillType, skillType+1) == nil { // 下一级是否存在 - - return false - } - _skillCfg := this.configure.GetGourmetConfigData(skillType, skilllv) // 获取技能配置 - for _, v := range _skillCfg.SkillConsume { - if v.A == comm.AttrType { //用户属性资源 - if amount := this.ModuleUser.QueryAttributeValue(uid, v.T); amount < int64(v.N) { - - return false - } - } else if v.A == comm.ItemType { //道具资源 - if amount := this.ModuleItems.QueryItemAmount(uid, v.T); amount < uint32(v.N) { - - return false - } - } - } - } - // 特殊技能判断 - for skillType := range _gourmet.SpecialSkill { - skilllv, _ := _gourmet.Skill[skillType] - if this.configure.GetGourmetConfigData(skillType, skillType+1) == nil { // 下一级是否存在 - - return false - } - _skillCfg := this.configure.GetGourmetConfigData(skillType, skilllv) // 获取技能配置 - for _, v := range _skillCfg.SkillConsume { - if v.A == comm.AttrType { //用户属性资源 - if amount := this.ModuleUser.QueryAttributeValue(uid, v.T); amount < int64(v.N) { - - return false - } - } else if v.A == comm.ItemType { //道具资源 - if amount := this.ModuleItems.QueryItemAmount(uid, v.T); amount < uint32(v.N) { - - return false - } - } - } - } - return true -} - -func (this *Gourmet) CheckPoint22(uid string) bool { - _gourmet, err := this.modelGourmet.getGourmetList(uid) - if err != nil { - - return false - } - if len(_gourmet.Items) > 0 { // 有可领取的 直接返回 - return true - } - return false -} // 获取做菜成功率 返回菜单的ID func (this *Gourmet) GetSuccessRate(m map[string]int32, conf *cfg.GameBreakingbadData) (cid string) { diff --git a/modules/worldtask/api_accept.go b/modules/worldtask/api_accept.go index 16d65122f..0eec060b2 100644 --- a/modules/worldtask/api_accept.go +++ b/modules/worldtask/api_accept.go @@ -59,9 +59,11 @@ func (a *apiComp) Accept(session comm.IUserSession, req *pb.WorldtaskAcceptReq) session.SendMsg(string(a.module.GetType()), "accept", rsp) //判断是否要结束任务 - if (len(curTaskConf.Completetask) == 1 && curTaskConf.Completetask[0] == 0) || - len(curTaskConf.Completetask) == 0 { - + if (len(curTaskConf.Completetask) == 1 && curTaskConf.Completetask[0] == 0 || + len(curTaskConf.Completetask) == 0) && curTaskConf.DeliverNpc == 0 { + //结束任务 + a.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf) + a.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf) } return } diff --git a/modules/worldtask/api_chapterreward.go b/modules/worldtask/api_chapterreward.go new file mode 100644 index 000000000..4f38fbfac --- /dev/null +++ b/modules/worldtask/api_chapterreward.go @@ -0,0 +1,58 @@ +package worldtask + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +func (this *apiComp) ChapterrewardCheck(session comm.IUserSession, req *pb.WorldtaskChapterawardReq) (code pb.ErrorCode) { + if req.GroupId <= 0 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) Chapterreward(session comm.IUserSession, req *pb.WorldtaskChapterawardReq) (code pb.ErrorCode, data proto.Message) { + if code = this.ChapterrewardCheck(session, req); code != pb.ErrorCode_Success { + return + } + + uid := session.GetUserId() + rsp := &pb.WorldtaskChapterawardResp{} + myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid) + if err != nil { + this.module.Error("获取玩家世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) + code = pb.ErrorCode_DBError + return + } + + if stats, ok := myWorldtask.Chapters[req.GroupId]; !ok { + code = pb.ErrorCode_WorldtaskChapterUnFinished + return + } else { + if stats == 2 { + code = pb.ErrorCode_WorldtaskChapterReceived + return + } + } + + gwa, err := this.module.configure.getWorldAllCfg() + if err != nil || gwa == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + rewardCnf := gwa.GetDataMap()[req.GroupId] + if rewardCnf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + + this.module.DispenseRes(session, rewardCnf.Reword, true) + + session.SendMsg(this.service.GetType(), "chapterreward", rsp) + return +} diff --git a/modules/worldtask/api_completetask.go b/modules/worldtask/api_completetask.go index 75a0575cc..a4886cf80 100644 --- a/modules/worldtask/api_completetask.go +++ b/modules/worldtask/api_completetask.go @@ -23,6 +23,14 @@ func (this *apiComp) CompleteCondi(session comm.IUserSession, req *pb.WorldtaskC } rsp := &pb.WorldtaskCompleteCondiResp{} uid := session.GetUserId() + + // 当前任务配置 + curTaskConf, err := this.module.configure.getWorldtaskById(req.TaskId) + if err != nil || curTaskConf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + myWorldtask, err := this.module.modelWorldtask.getWorldtask(uid) if err != nil { this.module.Error("获取玩家世界任务失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) @@ -65,5 +73,12 @@ func (this *apiComp) CompleteCondi(session comm.IUserSession, req *pb.WorldtaskC } session.SendMsg(string(this.module.GetType()), "completecondi", rsp) + + //判断是否要结束任务 + if curTaskConf.DeliverNpc == 0 { + //结束任务 + this.module.modelWorldtask.taskFinish(session, req.GroupId, req.TaskId, myWorldtask, curTaskConf) + this.module.modelWorldtask.taskFinishPush(session, req.GroupId, myWorldtask, curTaskConf) + } return } diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index eff561d75..7dd8143c1 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -73,13 +73,16 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe updateCheckCond := func(userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask { //检查下个任务的完成条件 nextTaskConf, err := this.module.configure.getWorldtaskById(nextTaskId) - if err != nil || curTaskConf == nil { + if err != nil { code = pb.ErrorCode_ConfigNoFound return nil } if nextTaskConf == nil { return nil } + if nextTaskConf.Des == 1 || nextTaskConf.Des == 4 { + return nil + } if userTask.CurrentTask == nil { userTask.CurrentTask = make(map[int32]*pb.Worldtask) @@ -131,6 +134,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } userTask.CurrentTask[nextTaskConf.Group] = nwt update["currentTask"] = userTask.CurrentTask + } } @@ -173,13 +177,17 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } } else { // 章节完成 - // if _, ok := utils.Findx(userTask.Chapters, req.GroupId); !ok { - // userTask.Chapters = append(userTask.Chapters, req.GroupId) - // update := map[string]interface{}{ - // "chapters": userTask.Chapters, - // } - // this.module.modelWorldtask.Change(uid, update) - // } + if _, ok := userTask.Chapters[req.GroupId]; !ok { + if userTask.Chapters == nil { + userTask.Chapters = make(map[int32]int32) + userTask.Chapters[req.GroupId] = 1 //已解锁待领取 + update := map[string]interface{}{ + "chapters": userTask.Chapters, + } + this.module.modelWorldtask.Change(uid, update) + } + } + } } diff --git a/modules/worldtask/configure.go b/modules/worldtask/configure.go index 0a2f7dc5c..dd9233fe4 100644 --- a/modules/worldtask/configure.go +++ b/modules/worldtask/configure.go @@ -10,6 +10,7 @@ import ( const ( gameWorldTask = "game_worldtask.json" gameWorldtaskBattle = "game_worldbattle.json" + gameWorldAll = "game_worldall.json" ) type configureComp struct { @@ -21,6 +22,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp err = this.LoadMultiConfigure(map[string]interface{}{ gameWorldTask: cfg.NewGameWorldTask, gameWorldtaskBattle: cfg.NewGameWorldBattle, + gameWorldAll: cfg.NewGameWorldAll, }) return } @@ -41,6 +43,22 @@ func (this *configureComp) getWorldtaskCfg() (data *cfg.GameWorldTask, err error return } +func (this *configureComp) getWorldAllCfg() (data *cfg.GameWorldAll, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(gameWorldAll); err != nil { + return + } else { + if data, ok = v.(*cfg.GameWorldAll); !ok { + err = fmt.Errorf("%T is *cfg.GameWorldAll", v) + return + } + } + return +} + func (this *configureComp) getWorldtaskById(taskId int32) (*cfg.GameWorldTaskData, error) { gwt, err := this.getWorldtaskCfg() if err != nil { diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index 2046ed674..5a33ee321 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -148,3 +148,141 @@ func (this *ModelWorldtask) findNextTasks(parentTaskId int32) (taskIds []int32) } return } + +func (this *ModelWorldtask) updateCheckCond(uid string, userTask *pb.DBWorldtask, nextTaskId int32) *pb.DBWorldtask { + //检查下个任务的完成条件 + nextTaskConf, err := this.moduleWorldtask.configure.getWorldtaskById(nextTaskId) + if err != nil { + return nil + } + if nextTaskConf == nil { + return nil + } + + if userTask.CurrentTask == nil { + userTask.CurrentTask = make(map[int32]*pb.Worldtask) + } + + update := make(map[string]interface{}) + if (len(nextTaskConf.Completetask) == 1 && nextTaskConf.Completetask[0] == 0) || + len(nextTaskConf.Completetask) == 0 { + wt := &pb.Worldtask{ + TaskId: nextTaskId, + TaskType: nextTaskConf.Des, + CondiIds: []int32{}, + } + userTask.CurrentTask[nextTaskConf.Group] = wt + update["currentTask"] = userTask.CurrentTask + } else { + for _, condiId := range nextTaskConf.Completetask { + if condiId == 0 { + continue + } + nwt, ok := userTask.CurrentTask[nextTaskConf.Group] + if ok { + nwt.TaskId = nextTaskId + nwt.TaskType = nextTaskConf.Des + } else { + nwt = &pb.Worldtask{ + TaskId: nextTaskId, + TaskType: nextTaskConf.Des, + } + } + if m, err := this.service.GetModule(comm.ModuleRtask); err == nil { + iwt, ok := m.(comm.IRtask) + if ok { + if mc := iwt.CheckCondi(uid, condiId); mc != pb.ErrorCode_Success { + this.moduleWorldtask.Debug("任务完成条件不满足", + log.Field{Key: "uid", Value: uid}, + log.Field{Key: "taskId", Value: nextTaskId}, + log.Field{Key: "condiId", Value: condiId}, + ) + } else { + if ok { + nwt.CondiIds = append(nwt.CondiIds, condiId) + } else { + condiIds := []int32{condiId} + nwt.CondiIds = condiIds + } + } + } + } + userTask.CurrentTask[nextTaskConf.Group] = nwt + update["currentTask"] = userTask.CurrentTask + + } + } + + if len(update) > 0 { + if err := this.Change(uid, update); err != nil { + return nil + } + } + + return userTask +} + +func (this *ModelWorldtask) taskFinishPush(session comm.IUserSession, groupId int32, userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) { + nextTaskIds := this.findNextTasks(curTaskConf.Key) + this.moduleWorldtask.Debug("nextTaskIds", log.Field{Key: "nextTaskIds", Value: nextTaskIds}) + + nextTask := make(map[int32]*pb.Worldtask) + for _, next := range nextTaskIds { + ut := this.updateCheckCond(session.GetUserId(), userTask, next) + if ut != nil { + for k, v := range ut.CurrentTask { + nextTask[k] = &pb.Worldtask{ + TaskId: v.TaskId, + } + } + } + } + + if curTaskConf.IdAfter != 0 { + // 任务完成推送 + session.SendMsg(string(this.moduleWorldtask.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ + NextTask: nextTask, + }) + } else { + // 章节完成 + if _, ok := userTask.Chapters[groupId]; !ok { + if userTask.Chapters == nil { + userTask.Chapters = make(map[int32]int32) + userTask.Chapters[groupId] = 1 //已解锁待领取 + update := map[string]interface{}{ + "chapters": userTask.Chapters, + } + this.Change(session.GetUserId(), update) + } + } + } +} + +func (this *ModelWorldtask) taskFinish(session comm.IUserSession, groupId, taskId int32, userTask *pb.DBWorldtask, curTaskConf *cfg.GameWorldTaskData) { + if err := this.finishTask(groupId, taskId, userTask); err != nil { + this.moduleWorldtask.Error("完成任务失败", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "groupId", Value: groupId}, + log.Field{Key: "taskId", Value: taskId}, + log.Field{Key: "err", Value: err.Error()}, + ) + return + } + + //判断是否配置了通知module + if len(curTaskConf.Module) == 0 { + this.moduleWorldtask.DispenseRes(session, curTaskConf.Reword, true) + } else { + for _, m := range curTaskConf.Module { + i, err := this.service.GetModule(core.M_Modules(m)) + if err != nil { + this.moduleWorldtask.Errorln(err) + continue + } + + if ic, ok := i.(comm.ITaskComplete); ok { + ic.TaskComplete(session, taskId) + } + } + } +} diff --git a/modules/worldtask/module.go b/modules/worldtask/module.go index 2d1e64a25..53d7a5334 100644 --- a/modules/worldtask/module.go +++ b/modules/worldtask/module.go @@ -69,7 +69,7 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in finishedTaskIds := make(map[int32]int32) //达成的任务条件 for _, c := range this.worldtaskConf.GetDataList() { for _, v := range c.Completetask { - if v == condId { + if v == condId { finishedTaskIds[c.Group] = c.Key groupId = c.Group taskId = c.Key @@ -107,7 +107,9 @@ func (this *Worldtask) TaskCondFinishNotify(session comm.IUserSession, condId in TaskId: taskId, CondiIds: wt.CondiIds, }) - this.Debug("推送完成条件", log.Field{Key: "condiIds", Value: taskId}) + this.Debug("推送完成条件", + log.Field{Key: "condiIds", Value: wt.CondiIds}, + log.Field{Key: "taskId", Value: taskId}) return nil } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index b752f263e..cab15dbb9 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -312,13 +312,15 @@ const ( ErrorCode_PayRenewTimeErr ErrorCode = 3702 // 续费时间没达到要求 ErrorCode_PayOrderCompleted ErrorCode = 3703 // 订单已完成 // worldtask - ErrorCode_WorldtaskFinish ErrorCode = 3801 //任务完成失败 - ErrorCode_WorldtaskLvNotEnough ErrorCode = 3802 //等级不满足 - ErrorCode_WorldtaskNoAccept ErrorCode = 3803 //不能接取 - ErrorCode_WorldtaskNoComplete ErrorCode = 3804 //任务条件未完成 - ErrorCode_WorldtaskFinihed ErrorCode = 3805 //任务已完成 - ErrorCode_WorldtaskLastUnFinished ErrorCode = 3806 //上个任务未完成 - ErrorCode_WorldtaskGroupIdNosame ErrorCode = 3807 //组ID不一致 + ErrorCode_WorldtaskFinish ErrorCode = 3801 //任务完成失败 + ErrorCode_WorldtaskLvNotEnough ErrorCode = 3802 //等级不满足 + ErrorCode_WorldtaskNoAccept ErrorCode = 3803 //不能接取 + ErrorCode_WorldtaskNoComplete ErrorCode = 3804 //任务条件未完成 + ErrorCode_WorldtaskFinihed ErrorCode = 3805 //任务已完成 + ErrorCode_WorldtaskLastUnFinished ErrorCode = 3806 //上个任务未完成 + ErrorCode_WorldtaskGroupIdNosame ErrorCode = 3807 //组ID不一致 + ErrorCode_WorldtaskChapterUnFinished ErrorCode = 3808 //章节任务未完成 + ErrorCode_WorldtaskChapterReceived ErrorCode = 3809 //章节奖励已领取 // academy ErrorCode_AcademyTaskNoCompleteTask ErrorCode = 3901 //未完成任务 // AutoBattle @@ -627,6 +629,8 @@ var ( 3805: "WorldtaskFinihed", 3806: "WorldtaskLastUnFinished", 3807: "WorldtaskGroupIdNosame", + 3808: "WorldtaskChapterUnFinished", + 3809: "WorldtaskChapterReceived", 3901: "AcademyTaskNoCompleteTask", 4001: "AutoBattleNoData", 4002: "AutoBattleStatesErr", @@ -927,6 +931,8 @@ var ( "WorldtaskFinihed": 3805, "WorldtaskLastUnFinished": 3806, "WorldtaskGroupIdNosame": 3807, + "WorldtaskChapterUnFinished": 3808, + "WorldtaskChapterReceived": 3809, "AcademyTaskNoCompleteTask": 3901, "AutoBattleNoData": 4001, "AutoBattleStatesErr": 4002, @@ -992,7 +998,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, 0x98, 0x36, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xd8, 0x36, 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, 0x14, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, @@ -1376,7 +1382,11 @@ var file_errorcode_proto_rawDesc = []byte{ 0x17, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xde, 0x1d, 0x12, 0x1b, 0x0a, 0x16, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x4e, - 0x6f, 0x73, 0x61, 0x6d, 0x65, 0x10, 0xdf, 0x1d, 0x12, 0x1e, 0x0a, 0x19, 0x41, 0x63, 0x61, 0x64, + 0x6f, 0x73, 0x61, 0x6d, 0x65, 0x10, 0xdf, 0x1d, 0x12, 0x1f, 0x0a, 0x1a, 0x57, 0x6f, 0x72, 0x6c, + 0x64, 0x74, 0x61, 0x73, 0x6b, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x55, 0x6e, 0x46, 0x69, + 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xe0, 0x1d, 0x12, 0x1d, 0x0a, 0x18, 0x57, 0x6f, 0x72, + 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, + 0x65, 0x69, 0x76, 0x65, 0x64, 0x10, 0xe1, 0x1d, 0x12, 0x1e, 0x0a, 0x19, 0x41, 0x63, 0x61, 0x64, 0x65, 0x6d, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x10, 0xbd, 0x1e, 0x12, 0x15, 0x0a, 0x10, 0x41, 0x75, 0x74, 0x6f, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xa1, 0x1f, 0x12, diff --git a/pb/worldtask_db.pb.go b/pb/worldtask_db.pb.go index 862b3690c..6971d71ea 100644 --- a/pb/worldtask_db.pb.go +++ b/pb/worldtask_db.pb.go @@ -28,7 +28,7 @@ type DBWorldtask struct { Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //玩家ID TaskList []int32 `protobuf:"varint,3,rep,packed,name=taskList,proto3" json:"taskList" bson:"taskList"` // 任务列表 CurrentTask map[int32]*Worldtask `protobuf:"bytes,4,rep,name=currentTask,proto3" json:"currentTask" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"currentTask"` //正在进行的任务 - Chapters []int32 `protobuf:"varint,5,rep,packed,name=chapters,proto3" json:"chapters" bson:"chapters"` //章节ID + Chapters map[int32]int32 `protobuf:"bytes,5,rep,name=chapters,proto3" json:"chapters" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3" bson:"chapters"` //key章节ID v状态 1已解锁2已领取 } func (x *DBWorldtask) Reset() { @@ -84,7 +84,7 @@ func (x *DBWorldtask) GetCurrentTask() map[int32]*Worldtask { return nil } -func (x *DBWorldtask) GetChapters() []int32 { +func (x *DBWorldtask) GetChapters() map[int32]int32 { if x != nil { return x.Chapters } @@ -174,33 +174,38 @@ var File_worldtask_worldtask_db_proto protoreflect.FileDescriptor var file_worldtask_worldtask_db_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x77, 0x6f, 0x72, 0x6c, - 0x64, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe4, - 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x10, + 0x64, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbd, + 0x02, 0x0a, 0x0b, 0x44, 0x42, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x44, 0x42, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1a, 0x0a, - 0x08, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, - 0x08, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x4a, 0x0a, 0x10, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, - 0x2e, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, 0x01, 0x0a, 0x09, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, - 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, - 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, - 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x70, 0x63, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x70, 0x63, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, - 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, - 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x4e, 0x70, 0x63, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x64, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x4e, 0x70, - 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x52, 0x0b, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x36, 0x0a, + 0x08, 0x63, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x44, 0x42, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x43, 0x68, + 0x61, 0x70, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x63, 0x68, 0x61, + 0x70, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x4a, 0x0a, 0x10, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x54, 0x61, 0x73, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x57, 0x6f, 0x72, + 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x1a, 0x3b, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x70, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, + 0x01, 0x0a, 0x09, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, + 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, + 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x70, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x09, 0x6e, 0x70, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, + 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x05, + 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x49, 0x64, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, + 0x6c, 0x69, 0x76, 0x65, 0x72, 0x4e, 0x70, 0x63, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, + 0x64, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x4e, 0x70, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -215,20 +220,22 @@ func file_worldtask_worldtask_db_proto_rawDescGZIP() []byte { return file_worldtask_worldtask_db_proto_rawDescData } -var file_worldtask_worldtask_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_worldtask_worldtask_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_worldtask_worldtask_db_proto_goTypes = []interface{}{ (*DBWorldtask)(nil), // 0: DBWorldtask (*Worldtask)(nil), // 1: Worldtask nil, // 2: DBWorldtask.CurrentTaskEntry + nil, // 3: DBWorldtask.ChaptersEntry } var file_worldtask_worldtask_db_proto_depIdxs = []int32{ 2, // 0: DBWorldtask.currentTask:type_name -> DBWorldtask.CurrentTaskEntry - 1, // 1: DBWorldtask.CurrentTaskEntry.value:type_name -> Worldtask - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 3, // 1: DBWorldtask.chapters:type_name -> DBWorldtask.ChaptersEntry + 1, // 2: DBWorldtask.CurrentTaskEntry.value:type_name -> Worldtask + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_worldtask_worldtask_db_proto_init() } @@ -268,7 +275,7 @@ func file_worldtask_worldtask_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_worldtask_worldtask_db_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, },