From 1949c0e4ead9ac16c9cd762705d4f0b1f129da1f Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 12 May 2023 19:15:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=95=86=E9=98=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/model_troll.go | 4 ++ modules/caravan/module.go | 49 +++++++++++------------- modules/modulebase.go | 42 +++++++++++++++++++++ modules/smithy/api_forgeequip.go | 59 ++++++++++++++++------------- modules/smithy/model_stove.go | 23 +++++++++--- pb/caravan_db.pb.go | 64 +++++++++++++++++++++++++------- 6 files changed, 168 insertions(+), 73 deletions(-) diff --git a/modules/caravan/model_troll.go b/modules/caravan/model_troll.go index 14f241cee..adad81c74 100644 --- a/modules/caravan/model_troll.go +++ b/modules/caravan/model_troll.go @@ -40,6 +40,10 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err Num: 0, Profit: 0, Resettime: 0, + Curcity: 0, + Task: 0, + Eventid: 0, + Tasktime: 0, } if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err { // 创建一条数据 diff --git a/modules/caravan/module.go b/modules/caravan/module.go index ab35c5f69..b3a1f031c 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -55,30 +55,25 @@ func (this *Caravan) InitCaravanCityData(uid string, data *pb.DBCaravan) { Like: []int32{}, Unlike: []int32{}, } - if v.Citytype == 1 { // + + if len(v.Special) > int(v.Citytypenum) { + ids := utils.RandomNumbers(0, len(v.Special), int(v.Citytypenum)) + for _, id := range ids { + city.Like = append(city.Like, v.Special[id]) + } + } else { city.Like = append(city.Like, v.Special...) - city.Unlike = append(city.Like, v.Exspecial...) - } else { // 不喜欢的 随机 citytypenum 个 - if len(v.Special) > int(v.Citytypenum) { - ids := utils.RandomNumbers(0, len(v.Special), int(v.Citytypenum)) - for _, id := range ids { - - city.Like = append(city.Like, v.Special[id]) - } - } else { - city.Like = append(city.Like, v.Special...) - } - - if len(v.Exspecial) > int(v.Exspecialnum) { - ids := utils.RandomNumbers(0, len(v.Exspecial), int(v.Exspecialnum)) - for _, id := range ids { - - city.Like = append(city.Like, v.Exspecial[id]) - } - } else { - city.Unlike = append(city.Like, v.Exspecial...) - } } + + if len(v.Exspecial) > int(v.Exspecialnum) { + ids := utils.RandomNumbers(0, len(v.Exspecial), int(v.Exspecialnum)) + for _, id := range ids { + city.Like = append(city.Like, v.Exspecial[id]) + } + } else { + city.Unlike = append(city.Like, v.Exspecial...) + } + data.City[v.Id] = city } } @@ -95,12 +90,10 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { Price: 0, // 当前价格 Time: configure.Now().Unix(), // 刷新时间 } - if len(v.Changeperiod) != 2 { - continue + if len(v.Changeperiod) == 2 { + goods.Period = comm.GetRandNum(v.Changeperiod[0], v.Changeperiod[1]) + goods.Price = v.Goodsprice + data.Goods[v.Id] = goods } - goods.Period = comm.GetRandNum(v.Changeperiod[0], v.Changeperiod[1]) - goods.Price = v.Goodsprice - data.Goods[v.Id] = goods } - } diff --git a/modules/modulebase.go b/modules/modulebase.go index 5ee7e2470..071dda54f 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -707,3 +707,45 @@ func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gamea } return } + +// 格式化资源 +func (this *ModuleBase) FormatRes(res []*cfg.Gameatn) (ret []*cfg.Gameatn) { + var ( + items map[string]int32 // 道具背包 批量处理 + attrs map[string]int32 // 属性 + ) + items = make(map[string]int32, 0) + attrs = make(map[string]int32, 0) + + for _, v := range res { + switch v.A { + case comm.AttrType: + attrs[v.T] += v.N + + case comm.ItemType: + items[v.T] += v.N + default: + this.Errorf("not found res type") // 找不到资源类型 + } + } + for k, v := range attrs { + if v >= 0 { + ret = append(ret, &cfg.Gameatn{ + A: "attr", + T: k, + N: v, + }) + } + + } + for k, v := range items { + if v >= 0 { + ret = append(ret, &cfg.Gameatn{ + A: "item", + T: k, + N: v, + }) + } + } + return +} diff --git a/modules/smithy/api_forgeequip.go b/modules/smithy/api_forgeequip.go index a08ac19f4..1ec89e9de 100644 --- a/modules/smithy/api_forgeequip.go +++ b/modules/smithy/api_forgeequip.go @@ -29,6 +29,7 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq needT int32 // 需要消耗的温度 maxT int32 atno []*pb.UserAtno + lava *cfg.Gameatn ) // 参数校验 if req.Count == 0 { // 传0 默认打造意见 @@ -93,17 +94,7 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq if _s != 0 { needT *= (1 - _s/1000) } - if req.Lava > 0 { // 熔岩打造 - exemption := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCos // 预计消耗温度 - gloabNum := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCosNum - if needT > req.Lava*gloabNum { - this.module.Errorf("ErrorCode_SmithyLackLava needT:%d,curT:%d,count :%d", needT, req.Count*gloabNum, req.Count) - code = pb.ErrorCode_SmithyLackLava // 缺少熔岩 - return - } - - costRes = append(costRes, exemption) - } else { + if req.Lava == 0 { // 检查炉温 是否够 if stove.Temperature < needT { code = pb.ErrorCode_SmithyNoTemperature // 炉温不够 直接返回 @@ -111,29 +102,45 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq } stove.Temperature -= needT // 消耗温度 update["temperature"] = stove.Temperature + } else { + exemption := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCos // 预计消耗温度 + gloabNum := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCosNum // 每个消耗的温度 + if gloabNum != 0 { + req.Lava = needT / gloabNum + if needT%gloabNum != 0 { + req.Lava += 1 + } + // 计算 + lava = &cfg.Gameatn{ + A: exemption.A, + T: exemption.T, + N: exemption.N * req.Lava, + } + if code = this.module.CheckRes(session, []*cfg.Gameatn{lava}); code != pb.ErrorCode_Success { + return + } + } } costRes = append(costRes, reelcfg.BasicCos...) subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) - // 异常处理 防止不消耗该道具 但是技能做了该道具的减免 - _costRes := make([]*cfg.Gameatn, len(costRes)) - for i, v := range costRes { - _costRes[i] = &cfg.Gameatn{ + + _costRes := make([]*cfg.Gameatn, 0) + for _, v := range costRes { + _costRes = append(_costRes, &cfg.Gameatn{ A: v.A, T: v.T, - N: v.N * req.Count, // 打造多件装备 - } - for _, v1 := range subAtn { - if _costRes[i].A == v1.A && _costRes[i].T == v1.T { - _costRes[i].N += v1.N * req.Count - } - } - if _costRes[i].N < 0 { - _costRes[i].N = 0 - } + N: v.N * req.Count, + }) + } + if req.Lava > 0 && lava != nil { // 熔岩打造 + _costRes = append(_costRes, lava) + } + if len(subAtn) > 0 { + _costRes = append(_costRes, subAtn...) } - if code = this.module.ConsumeRes(session, _costRes, true); code != pb.ErrorCode_Success { + if code = this.module.ConsumeRes(session, this.module.FormatRes(_costRes), true); code != pb.ErrorCode_Success { return } // 玩小游戏增加双倍产出校验 diff --git a/modules/smithy/model_stove.go b/modules/smithy/model_stove.go index 847bceac9..6b22b3ee1 100644 --- a/modules/smithy/model_stove.go +++ b/modules/smithy/model_stove.go @@ -110,12 +110,23 @@ func (this *modelStove) CheckForgeConsume(reelId int32, lv int32) (atn []*cfg.Ga var index int32 for index = 1; index <= lv; index++ { if cfgData := this.module.configure.GetSmithyProficileData(reelId, index); cfgData != nil { - if cfgData.Type == comm.SmithyReelType2 { - atn = append(atn, &cfg.Gameatn{ - A: "item", - T: strconv.Itoa(int(cfgData.Value1)), - N: cfgData.Value2, - }) + if cfgData.Type == comm.SmithyReelType2 && cfgData.Value2 != 0 { + bAdd := false + strT := strconv.Itoa(int(cfgData.Value1)) + for _, v := range atn { + if v.T == strT { + v.N += cfgData.Value2 + bAdd = true + break + } + } + if !bAdd { + atn = append(atn, &cfg.Gameatn{ + A: "item", + T: strT, + N: cfgData.Value2, + }) + } } } } diff --git a/pb/caravan_db.pb.go b/pb/caravan_db.pb.go index 80898f87e..ca3e37bae 100644 --- a/pb/caravan_db.pb.go +++ b/pb/caravan_db.pb.go @@ -104,7 +104,7 @@ type CityGoods struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Like []int32 `protobuf:"varint,1,rep,packed,name=like,proto3" json:"like"` // 习惯的货物 + Like []int32 `protobuf:"varint,1,rep,packed,name=like,proto3" json:"like"` // 喜欢的货物 Unlike []int32 `protobuf:"varint,2,rep,packed,name=unlike,proto3" json:"unlike"` // 不喜欢的货物 } @@ -169,6 +169,10 @@ type DBCaravan struct { Num int64 `protobuf:"varint,8,opt,name=num,proto3" json:"num"` // 虚拟货币数量 Profit int64 `protobuf:"varint,9,opt,name=profit,proto3" json:"profit"` // 虚拟货利润 Resettime int64 `protobuf:"varint,10,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间 + Curcity int32 `protobuf:"varint,11,opt,name=curcity,proto3" json:"curcity"` // 当前城市 + Task int32 `protobuf:"varint,12,opt,name=task,proto3" json:"task"` + Eventid int32 `protobuf:"varint,13,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID + Tasktime int32 `protobuf:"varint,14,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间 } func (x *DBCaravan) Reset() { @@ -266,6 +270,34 @@ func (x *DBCaravan) GetResettime() int64 { return 0 } +func (x *DBCaravan) GetCurcity() int32 { + if x != nil { + return x.Curcity + } + return 0 +} + +func (x *DBCaravan) GetTask() int32 { + if x != nil { + return x.Task + } + return 0 +} + +func (x *DBCaravan) GetEventid() int32 { + if x != nil { + return x.Eventid + } + return 0 +} + +func (x *DBCaravan) GetTasktime() int32 { + if x != nil { + return x.Tasktime + } + return 0 +} + var File_caravan_caravan_db_proto protoreflect.FileDescriptor var file_caravan_caravan_db_proto_rawDesc = []byte{ @@ -282,7 +314,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{ 0x79, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6b, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x75, 0x6e, 0x6c, 0x69, - 0x6b, 0x65, 0x22, 0xff, 0x02, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, + 0x6b, 0x65, 0x22, 0xe3, 0x03, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, @@ -297,17 +329,23 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{ 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x40, 0x0a, - 0x0a, 0x47, 0x6f, 0x6f, 0x64, 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, 0x1c, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, - 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, - 0x43, 0x0a, 0x09, 0x43, 0x69, 0x74, 0x79, 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, - 0x43, 0x69, 0x74, 0x79, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, + 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, + 0x65, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 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, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x1a, 0x43, 0x0a, 0x09, 0x43, 0x69, 0x74, 0x79, 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, 0x43, 0x69, 0x74, 0x79, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From ef4f779ef2f7ef45e02b5bcff62b565a332728ce Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 12 May 2023 19:59:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B7=91=E5=95=86=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/model_troll.go | 3 +- modules/caravan/module.go | 6 +- pb/caravan_db.pb.go | 299 ++++++++++++++++++++++----------- 3 files changed, 202 insertions(+), 106 deletions(-) diff --git a/modules/caravan/model_troll.go b/modules/caravan/model_troll.go index adad81c74..07781f989 100644 --- a/modules/caravan/model_troll.go +++ b/modules/caravan/model_troll.go @@ -34,8 +34,9 @@ func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err Id: primitive.NewObjectID().Hex(), Uid: uid, UseCount: 0, + Items: map[int32]*pb.BagInfo{}, Goods: map[int32]*pb.Goods{}, - City: map[int32]*pb.CityGoods{}, + City: map[int32]*pb.CityInfo{}, Lv: 0, Num: 0, Profit: 0, diff --git a/modules/caravan/module.go b/modules/caravan/module.go index b3a1f031c..3a7744451 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -49,11 +49,12 @@ func (this *Caravan) ModifyCaravanData(uid string, data map[string]interface{}) // 初始化城市信息 func (this *Caravan) InitCaravanCityData(uid string, data *pb.DBCaravan) { list := this.configure.GetAllCaravanCity() - data.City = make(map[int32]*pb.CityGoods, 0) + data.City = make(map[int32]*pb.CityInfo, 0) for _, v := range list { - city := &pb.CityGoods{ + city := &pb.CityInfo{ Like: []int32{}, Unlike: []int32{}, + Count: map[int32]int32{}, } if len(v.Special) > int(v.Citytypenum) { @@ -84,7 +85,6 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { data.Goods = make(map[int32]*pb.Goods, 0) for _, v := range items { goods := &pb.Goods{ - Count: 0, // 货物数量 Period: 0, // 变动周期 CurPeriod: 1, // 当前变动周期 Price: 0, // 当前价格 diff --git a/pb/caravan_db.pb.go b/pb/caravan_db.pb.go index ca3e37bae..de168fac2 100644 --- a/pb/caravan_db.pb.go +++ b/pb/caravan_db.pb.go @@ -25,11 +25,10 @@ type Goods struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count"` // 货物数量 - Period int32 `protobuf:"varint,2,opt,name=period,proto3" json:"period"` // 变动周期 - CurPeriod int32 `protobuf:"varint,3,opt,name=curPeriod,proto3" json:"curPeriod"` // 当前变动周期 - Price int32 `protobuf:"varint,4,opt,name=price,proto3" json:"price"` // 当前价格 - Time int64 `protobuf:"varint,5,opt,name=time,proto3" json:"time"` // 刷新时间 + Period int32 `protobuf:"varint,1,opt,name=period,proto3" json:"period"` // 变动周期 + CurPeriod int32 `protobuf:"varint,2,opt,name=curPeriod,proto3" json:"curPeriod"` // 当前变动周期 + Price int32 `protobuf:"varint,3,opt,name=price,proto3" json:"price"` // 当前价格 + Time int64 `protobuf:"varint,4,opt,name=time,proto3" json:"time"` // 刷新时间 } func (x *Goods) Reset() { @@ -64,13 +63,6 @@ func (*Goods) Descriptor() ([]byte, []int) { return file_caravan_caravan_db_proto_rawDescGZIP(), []int{0} } -func (x *Goods) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 -} - func (x *Goods) GetPeriod() int32 { if x != nil { return x.Period @@ -99,17 +91,18 @@ func (x *Goods) GetTime() int64 { return 0 } -type CityGoods struct { +type CityInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Like []int32 `protobuf:"varint,1,rep,packed,name=like,proto3" json:"like"` // 喜欢的货物 - Unlike []int32 `protobuf:"varint,2,rep,packed,name=unlike,proto3" json:"unlike"` // 不喜欢的货物 + Like []int32 `protobuf:"varint,1,rep,packed,name=like,proto3" json:"like"` // 喜欢的货物ID + Unlike []int32 `protobuf:"varint,2,rep,packed,name=unlike,proto3" json:"unlike"` // 不喜欢的货物ID + Count map[int32]int32 `protobuf:"bytes,3,rep,name=count,proto3" json:"count" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 货物对应的数量 } -func (x *CityGoods) Reset() { - *x = CityGoods{} +func (x *CityInfo) Reset() { + *x = CityInfo{} if protoimpl.UnsafeEnabled { mi := &file_caravan_caravan_db_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -117,13 +110,13 @@ func (x *CityGoods) Reset() { } } -func (x *CityGoods) String() string { +func (x *CityInfo) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CityGoods) ProtoMessage() {} +func (*CityInfo) ProtoMessage() {} -func (x *CityGoods) ProtoReflect() protoreflect.Message { +func (x *CityInfo) ProtoReflect() protoreflect.Message { mi := &file_caravan_caravan_db_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -135,50 +128,112 @@ func (x *CityGoods) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CityGoods.ProtoReflect.Descriptor instead. -func (*CityGoods) Descriptor() ([]byte, []int) { +// Deprecated: Use CityInfo.ProtoReflect.Descriptor instead. +func (*CityInfo) Descriptor() ([]byte, []int) { return file_caravan_caravan_db_proto_rawDescGZIP(), []int{1} } -func (x *CityGoods) GetLike() []int32 { +func (x *CityInfo) GetLike() []int32 { if x != nil { return x.Like } return nil } -func (x *CityGoods) GetUnlike() []int32 { +func (x *CityInfo) GetUnlike() []int32 { if x != nil { return x.Unlike } return nil } +func (x *CityInfo) GetCount() map[int32]int32 { + if x != nil { + return x.Count + } + return nil +} + +type BagInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count"` //数量 + Price int32 `protobuf:"varint,2,opt,name=price,proto3" json:"price"` //单价 +} + +func (x *BagInfo) Reset() { + *x = BagInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_caravan_caravan_db_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BagInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BagInfo) ProtoMessage() {} + +func (x *BagInfo) ProtoReflect() protoreflect.Message { + mi := &file_caravan_caravan_db_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BagInfo.ProtoReflect.Descriptor instead. +func (*BagInfo) Descriptor() ([]byte, []int) { + return file_caravan_caravan_db_proto_rawDescGZIP(), []int{2} +} + +func (x *BagInfo) GetCount() int32 { + if x != nil { + return x.Count + } + return 0 +} + +func (x *BagInfo) GetPrice() int32 { + if x != nil { + return x.Price + } + return 0 +} + type DBCaravan struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - UseCount int32 `protobuf:"varint,3,opt,name=useCount,proto3" json:"useCount"` // 当前背包使用的数量 - //map items = 4; // 背包数据 - Goods map[int32]*Goods `protobuf:"bytes,5,rep,name=goods,proto3" json:"goods" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID - City map[int32]*CityGoods `protobuf:"bytes,6,rep,name=city,proto3" json:"city" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 城市信息 - Lv int32 `protobuf:"varint,7,opt,name=lv,proto3" json:"lv"` // 商队等级 - Num int64 `protobuf:"varint,8,opt,name=num,proto3" json:"num"` // 虚拟货币数量 - Profit int64 `protobuf:"varint,9,opt,name=profit,proto3" json:"profit"` // 虚拟货利润 - Resettime int64 `protobuf:"varint,10,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间 - Curcity int32 `protobuf:"varint,11,opt,name=curcity,proto3" json:"curcity"` // 当前城市 - Task int32 `protobuf:"varint,12,opt,name=task,proto3" json:"task"` - Eventid int32 `protobuf:"varint,13,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID - Tasktime int32 `protobuf:"varint,14,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + UseCount int32 `protobuf:"varint,3,opt,name=useCount,proto3" json:"useCount" bson:"usecount"` //当前背包使用的数量 + Items map[int32]*BagInfo `protobuf:"bytes,4,rep,name=items,proto3" json:"items" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 背包数据 + Goods map[int32]*Goods `protobuf:"bytes,5,rep,name=goods,proto3" json:"goods" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 货物ID + City map[int32]*CityInfo `protobuf:"bytes,6,rep,name=city,proto3" json:"city" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // 城市信息 + Lv int32 `protobuf:"varint,7,opt,name=lv,proto3" json:"lv"` // 商队等级 + Num int64 `protobuf:"varint,8,opt,name=num,proto3" json:"num"` // 虚拟货币数量 + Profit int64 `protobuf:"varint,9,opt,name=profit,proto3" json:"profit"` // 虚拟货利润 + Resettime int64 `protobuf:"varint,10,opt,name=resettime,proto3" json:"resettime"` // 最后一次重置时间 + Curcity int32 `protobuf:"varint,11,opt,name=curcity,proto3" json:"curcity"` // 当前城市 + Task int32 `protobuf:"varint,12,opt,name=task,proto3" json:"task"` + Eventid int32 `protobuf:"varint,13,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID + Tasktime int32 `protobuf:"varint,14,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间 } func (x *DBCaravan) Reset() { *x = DBCaravan{} if protoimpl.UnsafeEnabled { - mi := &file_caravan_caravan_db_proto_msgTypes[2] + mi := &file_caravan_caravan_db_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -191,7 +246,7 @@ func (x *DBCaravan) String() string { func (*DBCaravan) ProtoMessage() {} func (x *DBCaravan) ProtoReflect() protoreflect.Message { - mi := &file_caravan_caravan_db_proto_msgTypes[2] + mi := &file_caravan_caravan_db_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -204,7 +259,7 @@ func (x *DBCaravan) ProtoReflect() protoreflect.Message { // Deprecated: Use DBCaravan.ProtoReflect.Descriptor instead. func (*DBCaravan) Descriptor() ([]byte, []int) { - return file_caravan_caravan_db_proto_rawDescGZIP(), []int{2} + return file_caravan_caravan_db_proto_rawDescGZIP(), []int{3} } func (x *DBCaravan) GetId() string { @@ -228,6 +283,13 @@ func (x *DBCaravan) GetUseCount() int32 { return 0 } +func (x *DBCaravan) GetItems() map[int32]*BagInfo { + if x != nil { + return x.Items + } + return nil +} + func (x *DBCaravan) GetGoods() map[int32]*Goods { if x != nil { return x.Goods @@ -235,7 +297,7 @@ func (x *DBCaravan) GetGoods() map[int32]*Goods { return nil } -func (x *DBCaravan) GetCity() map[int32]*CityGoods { +func (x *DBCaravan) GetCity() map[int32]*CityInfo { if x != nil { return x.City } @@ -302,50 +364,65 @@ var File_caravan_caravan_db_proto protoreflect.FileDescriptor var file_caravan_caravan_db_proto_rawDesc = []byte{ 0x0a, 0x18, 0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2f, 0x63, 0x61, 0x72, 0x61, 0x76, 0x61, - 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7d, 0x0a, 0x05, 0x47, 0x6f, - 0x6f, 0x64, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x65, 0x72, - 0x69, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x65, 0x72, 0x69, 0x6f, - 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x75, 0x72, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x75, 0x72, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, - 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, - 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x37, 0x0a, 0x09, 0x43, 0x69, 0x74, - 0x79, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x6c, 0x69, 0x6b, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, - 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x75, 0x6e, 0x6c, 0x69, - 0x6b, 0x65, 0x22, 0xe3, 0x03, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x75, 0x73, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, - 0x0a, 0x05, 0x67, 0x6f, 0x6f, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67, 0x6f, 0x6f, 0x64, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x63, - 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x43, 0x61, - 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x43, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, - 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, - 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, - 0x65, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 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, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x1a, 0x43, 0x0a, 0x09, 0x43, 0x69, 0x74, 0x79, 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, 0x43, 0x69, 0x74, 0x79, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x67, 0x0a, 0x05, 0x47, 0x6f, + 0x6f, 0x64, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, + 0x75, 0x72, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, + 0x63, 0x75, 0x72, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, + 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x22, 0x9c, 0x01, 0x0a, 0x08, 0x43, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, + 0x6c, 0x69, 0x6b, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, 0x6c, 0x69, 0x6b, 0x65, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x75, 0x6e, 0x6c, 0x69, 0x6b, 0x65, 0x12, 0x2a, 0x0a, 0x05, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x43, 0x69, + 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x38, 0x0a, 0x0a, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 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, 0x35, 0x0a, 0x07, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, + 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0xd3, 0x04, 0x0a, 0x09, 0x44, 0x42, + 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x75, 0x73, 0x65, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, + 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x12, 0x2b, 0x0a, 0x05, 0x67, 0x6f, 0x6f, 0x64, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x47, 0x6f, + 0x6f, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x67, 0x6f, 0x6f, 0x64, 0x73, 0x12, + 0x28, 0x0a, 0x04, 0x63, 0x69, 0x74, 0x79, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, + 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x2e, 0x43, 0x69, 0x74, 0x79, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x04, 0x63, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x70, + 0x72, 0x6f, 0x66, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x70, 0x72, 0x6f, + 0x66, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6d, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x63, 0x69, 0x74, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x61, 0x73, 0x6b, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x12, + 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, + 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, + 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 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, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, + 0x64, 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, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x42, 0x0a, 0x09, 0x43, + 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x69, 0x74, 0x79, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -360,24 +437,30 @@ func file_caravan_caravan_db_proto_rawDescGZIP() []byte { return file_caravan_caravan_db_proto_rawDescData } -var file_caravan_caravan_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_caravan_caravan_db_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_caravan_caravan_db_proto_goTypes = []interface{}{ (*Goods)(nil), // 0: Goods - (*CityGoods)(nil), // 1: CityGoods - (*DBCaravan)(nil), // 2: DBCaravan - nil, // 3: DBCaravan.GoodsEntry - nil, // 4: DBCaravan.CityEntry + (*CityInfo)(nil), // 1: CityInfo + (*BagInfo)(nil), // 2: BagInfo + (*DBCaravan)(nil), // 3: DBCaravan + nil, // 4: CityInfo.CountEntry + nil, // 5: DBCaravan.ItemsEntry + nil, // 6: DBCaravan.GoodsEntry + nil, // 7: DBCaravan.CityEntry } var file_caravan_caravan_db_proto_depIdxs = []int32{ - 3, // 0: DBCaravan.goods:type_name -> DBCaravan.GoodsEntry - 4, // 1: DBCaravan.city:type_name -> DBCaravan.CityEntry - 0, // 2: DBCaravan.GoodsEntry.value:type_name -> Goods - 1, // 3: DBCaravan.CityEntry.value:type_name -> CityGoods - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 4, // 0: CityInfo.count:type_name -> CityInfo.CountEntry + 5, // 1: DBCaravan.items:type_name -> DBCaravan.ItemsEntry + 6, // 2: DBCaravan.goods:type_name -> DBCaravan.GoodsEntry + 7, // 3: DBCaravan.city:type_name -> DBCaravan.CityEntry + 2, // 4: DBCaravan.ItemsEntry.value:type_name -> BagInfo + 0, // 5: DBCaravan.GoodsEntry.value:type_name -> Goods + 1, // 6: DBCaravan.CityEntry.value:type_name -> CityInfo + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_caravan_caravan_db_proto_init() } @@ -399,7 +482,7 @@ func file_caravan_caravan_db_proto_init() { } } file_caravan_caravan_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CityGoods); i { + switch v := v.(*CityInfo); i { case 0: return &v.state case 1: @@ -411,6 +494,18 @@ func file_caravan_caravan_db_proto_init() { } } file_caravan_caravan_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BagInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_caravan_caravan_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DBCaravan); i { case 0: return &v.state @@ -429,7 +524,7 @@ func file_caravan_caravan_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_caravan_caravan_db_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, From dbdc0f17ae244717ad2937352ea620a5dfa084cd Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 12 May 2023 20:49:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=B7=91=E5=95=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96+=E5=8D=8F=E8=AE=AE=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/api_getlist.go | 7 +++++++ modules/caravan/model_troll.go | 24 +++++++++------------ modules/caravan/module.go | 22 +++++++++++++------- pb/caravan_db.pb.go | 38 +++++++++++++++++++++------------- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/modules/caravan/api_getlist.go b/modules/caravan/api_getlist.go index 6cf8340ff..573df03dd 100644 --- a/modules/caravan/api_getlist.go +++ b/modules/caravan/api_getlist.go @@ -23,6 +23,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.CaravanGetListRe code = pb.ErrorCode_DBError return } + + if list.Id == "" { // 初始化门票和虚拟币 + if code = this.module.InitCaravanTicket(session, 1); code != pb.ErrorCode_Success { + return + } + } + resp.Data = list session.SendMsg(string(this.module.GetType()), "getlist", resp) return diff --git a/modules/caravan/model_troll.go b/modules/caravan/model_troll.go index 07781f989..79a02cc2e 100644 --- a/modules/caravan/model_troll.go +++ b/modules/caravan/model_troll.go @@ -31,25 +31,21 @@ func (this *modelCaravan) Init(service core.IService, module core.IModule, comp func (this *modelCaravan) getCaravanList(uid string) (result *pb.DBCaravan, err error) { result = &pb.DBCaravan{ - Id: primitive.NewObjectID().Hex(), - Uid: uid, - UseCount: 0, - Items: map[int32]*pb.BagInfo{}, - Goods: map[int32]*pb.Goods{}, - City: map[int32]*pb.CityInfo{}, - Lv: 0, - Num: 0, - Profit: 0, - Resettime: 0, - Curcity: 0, - Task: 0, - Eventid: 0, - Tasktime: 0, + Id: "", + Uid: uid, + UseCount: 0, + Items: map[int32]*pb.BagInfo{}, + Goods: map[int32]*pb.Goods{}, + City: map[int32]*pb.CityInfo{}, } if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err { // 创建一条数据 + result.Id = primitive.NewObjectID().Hex() result.Resettime = configure.Now().Unix() // 设置起始刷新时间 result.Lv = 1 + if conf := this.module.configure.GetCaravanLv(1); conf != nil { + result.Baglimit = conf.Bagtop + } this.module.InitCaravanCityData(uid, result) // 初始1级 this.module.InitCaravanItemData(uid, result) err = this.Add(uid, result) diff --git a/modules/caravan/module.go b/modules/caravan/module.go index 3a7744451..2c4c0e5a2 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" ) @@ -66,14 +67,7 @@ func (this *Caravan) InitCaravanCityData(uid string, data *pb.DBCaravan) { city.Like = append(city.Like, v.Special...) } - if len(v.Exspecial) > int(v.Exspecialnum) { - ids := utils.RandomNumbers(0, len(v.Exspecial), int(v.Exspecialnum)) - for _, id := range ids { - city.Like = append(city.Like, v.Exspecial[id]) - } - } else { - city.Unlike = append(city.Like, v.Exspecial...) - } + city.Unlike = append(city.Like, v.Exspecial...) data.City[v.Id] = city } @@ -97,3 +91,15 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { } } } + +// 初始化门票和虚拟币 +func (this *Caravan) InitCaravanTicket(session comm.IUserSession, lv int32) (code pb.ErrorCode) { + code = pb.ErrorCode_ConfigNoFound + if conf := this.modelCaravan.module.configure.GetCaravanLv(lv); conf != nil { + var res []*cfg.Gameatn + res = append(res, conf.Tickettop) + res = append(res, conf.Moneynumtop) + code = this.DispenseRes(session, res, true) // 推送门票和虚拟币资源 + } + return +} diff --git a/pb/caravan_db.pb.go b/pb/caravan_db.pb.go index de168fac2..62dc06e12 100644 --- a/pb/caravan_db.pb.go +++ b/pb/caravan_db.pb.go @@ -228,6 +228,7 @@ type DBCaravan struct { Task int32 `protobuf:"varint,12,opt,name=task,proto3" json:"task"` Eventid int32 `protobuf:"varint,13,opt,name=eventid,proto3" json:"eventid"` // 特殊事件ID Tasktime int32 `protobuf:"varint,14,opt,name=tasktime,proto3" json:"tasktime"` // 任务触发时间 + Baglimit int32 `protobuf:"varint,15,opt,name=baglimit,proto3" json:"baglimit"` // 背包上限 } func (x *DBCaravan) Reset() { @@ -360,6 +361,13 @@ func (x *DBCaravan) GetTasktime() int32 { return 0 } +func (x *DBCaravan) GetBaglimit() int32 { + if x != nil { + return x.Baglimit + } + return 0 +} + var File_caravan_caravan_db_proto protoreflect.FileDescriptor var file_caravan_caravan_db_proto_rawDesc = []byte{ @@ -384,7 +392,7 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{ 0x38, 0x01, 0x22, 0x35, 0x0a, 0x07, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0xd3, 0x04, 0x0a, 0x09, 0x44, 0x42, + 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0xef, 0x04, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, @@ -409,20 +417,22 @@ var file_caravan_caravan_db_proto_rawDesc = []byte{ 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x74, 0x61, 0x73, - 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, + 0x6b, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x67, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x61, 0x67, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x1a, 0x42, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 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, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x08, 0x2e, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, 0x64, 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, 0x1e, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x42, 0x61, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x40, 0x0a, 0x0a, 0x47, 0x6f, 0x6f, - 0x64, 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, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x42, 0x0a, 0x09, 0x43, - 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x69, 0x74, 0x79, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x06, 0x2e, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x42, 0x0a, 0x09, 0x43, 0x69, 0x74, 0x79, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (