This commit is contained in:
meixiongfeng 2023-05-12 19:15:23 +08:00
parent f814ed19ce
commit 1949c0e4ea
6 changed files with 168 additions and 73 deletions

View File

@ -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 {
// 创建一条数据

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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
}
// 玩小游戏增加双倍产出校验

View File

@ -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,
})
}
}
}
}

View File

@ -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 (