From 6e65b33560d63461930a43170619401f7535f0e2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 14 Oct 2022 18:32:47 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A3=85=E5=A4=87?= =?UTF-8?q?=E5=87=BA=E5=94=AE=E7=AE=97=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_dreamlandboos.json | 26 +++++- bin/json/game_msgdistrib.json | 2 +- modules/equipment/api_sellI.go | 25 ++++-- modules/equipment/modelEquipment.go | 4 +- modules/moonfantasy/api_ask.go | 75 +++++++--------- modules/moonfantasy/api_battle.go | 7 +- modules/moonfantasy/api_getlist.go | 29 +++++-- modules/moonfantasy/api_receive.go | 4 +- modules/moonfantasy/api_trigger.go | 87 ------------------- modules/moonfantasy/modelDream.go | 36 ++++++-- modules/moonfantasy/modelUserMF.go | 2 +- pb/moonfantasy_db.pb.go | 74 ++++++++-------- .../structs/Game.DreamlandBoosData.go | 36 +++++++- sys/db/dbconn.go | 24 ++++- 14 files changed, 222 insertions(+), 209 deletions(-) delete mode 100644 modules/moonfantasy/api_trigger.go diff --git a/bin/json/game_dreamlandboos.json b/bin/json/game_dreamlandboos.json index a499e4a52..9d660002e 100644 --- a/bin/json/game_dreamlandboos.json +++ b/bin/json/game_dreamlandboos.json @@ -4,15 +4,33 @@ "pro": 30, "fightnum": 5, "challengenum": 40, - "prize": 1001, - "monsterformatid": 201011 + "prize": [ + { + "a": "item", + "t": "30001", + "n": 1 + } + ], + "monsterformatid": [ + 201011 + ], + "dreamland_limit": 3600 }, { "bossid": "35001", "pro": 30, "fightnum": 5, "challengenum": 30, - "prize": 1002, - "monsterformatid": 201012 + "prize": [ + { + "a": "item", + "t": "30001", + "n": 1 + } + ], + "monsterformatid": [ + 201012 + ], + "dreamland_limit": 3600 } ] \ No newline at end of file diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index 31eea6ba7..5341d1d15 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -37,7 +37,7 @@ }, { "msgid": "moonfantasy", - "open": true, + "open": false, "routrules": "~/worker", "describe": "月之秘境" } diff --git a/modules/equipment/api_sellI.go b/modules/equipment/api_sellI.go index 2594b571c..593259191 100644 --- a/modules/equipment/api_sellI.go +++ b/modules/equipment/api_sellI.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "math" "google.golang.org/protobuf/proto" ) @@ -22,7 +23,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( err error equipments []*pb.DB_Equipment confs []*cfg.GameEquipData - sale []*cfg.Gameatn + sale [][]*cfg.Gameatn ) if code = this.SellCheck(session, req); code != pb.ErrorCode_Success { return @@ -32,6 +33,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( return } confs = make([]*cfg.GameEquipData, len(equipments)) + sale = make([][]*cfg.Gameatn, len(equipments)) for i, v := range equipments { if v.HeroId != "" || v.Islock { code = pb.ErrorCode_EquipmentNoCanSell @@ -47,15 +49,22 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( code = pb.ErrorCode_EquipmentNoCanSell return } - } - - sale = make([]*cfg.Gameatn, 0) - for _, v := range confs { - for _, s := range v.Sale { - sale = append(sale, s) + sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale)) + for n, s := range confs[i].Sale { + _s := &cfg.Gameatn{ + A: s.A, + T: s.T, + N: s.N + int32(math.Floor(float64(s.N*(v.Lv-1))*float64(confs[i].Salecoef))), + } + sale[i][n] = _s } } - if code = this.module.DispenseRes(session, sale, true); code != pb.ErrorCode_Success { + + sales := make([]*cfg.Gameatn, 0) + for _, v := range sale { + sales = append(sales, v...) + } + if code = this.module.DispenseRes(session, sales, true); code != pb.ErrorCode_Success { return } if code = this.module.DelEquipments(session, req.EquipIds, true); code != pb.ErrorCode_Success { diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index 62aac4bc2..9be4367a5 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -43,7 +43,9 @@ func (this *modelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipme //查询用户装备数据 func (this *modelEquipmentComp) QueryUserEquipmentsByIds(uId string, ids []string) (equipments []*pb.DB_Equipment, err error) { equipments = []*pb.DB_Equipment{} - err = this.GetListObjs(uId, ids, &equipments) + if err = this.GetListObjs(uId, ids, &equipments); err != nil { + this.module.Errorf("err:%v", err) + } return } diff --git a/modules/moonfantasy/api_ask.go b/modules/moonfantasy/api_ask.go index cfae50ff6..1ce2fa592 100644 --- a/modules/moonfantasy/api_ask.go +++ b/modules/moonfantasy/api_ask.go @@ -4,8 +4,6 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/redis" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - "time" "google.golang.org/protobuf/proto" ) @@ -18,13 +16,13 @@ func (this *apiComp) AskCheck(session comm.IUserSession, req *pb.MoonfantasyAskR ///询问怪物是否可以挑战 func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (code pb.ErrorCode, data proto.Message) { var ( - globalconf *cfg.GameGlobalData - mdata *pb.DBMoonFantasy - lock *redis.RedisMutex - umfantasy *pb.DBUserMFantasy - user *pb.DBUser - cd pb.ErrorCode - err error + mdata *pb.DBMoonFantasy + lock *redis.RedisMutex + // umfantasy *pb.DBUserMFantasy + user *pb.DBUser + cd pb.ErrorCode + isjson bool + err error ) defer func() { session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd, Info: mdata}) @@ -51,46 +49,39 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) ( cd = pb.ErrorCode_MoonfantasyHasExpired return } - if len(mdata.Join) >= int(mdata.Numup) { - cd = pb.ErrorCode_MoonfantasyJoinUp - return - } - - globalconf = this.module.configure.GetGlobalConf() - - if time.Now().Sub(time.Unix(mdata.Ctime, 0)).Seconds() >= float64(globalconf.DreamlandLimit) { - this.module.modelDream.Del(mdata.Id) + if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期 cd = pb.ErrorCode_MoonfantasyHasExpired return } - if v, ok := mdata.Record[session.GetUserId()]; ok { - if v >= mdata.Unitmup { - cd = pb.ErrorCode_MoonfantasyDareUp - return - } - } - if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { - code = pb.ErrorCode_CacheReadError - return - } - umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) - this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ - "mfantasys": umfantasy.Mfantasys, - }) - for _, v := range mdata.Join { if v.Uid == session.GetUserId() { - return + isjson = true + break } } - if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { - this.module.Errorf("no found uer:%d", session.GetUserId()) - code = pb.ErrorCode_DBError - return + + if !isjson { + if len(mdata.Join) >= int(mdata.Numup) { + cd = pb.ErrorCode_MoonfantasyJoinUp + return + } + // if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { + // code = pb.ErrorCode_CacheReadError + // return + // } + // umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + // this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ + // "mfantasys": umfantasy.Mfantasys, + // }) + if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + this.module.Errorf("no found uer:%d", session.GetUserId()) + code = pb.ErrorCode_DBError + return + } + mdata.Join = append(mdata.Join, &pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}) + this.module.modelDream.Change(mdata.Id, map[string]interface{}{ + "join": mdata.Join, + }) } - mdata.Join = append(mdata.Join, &pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}) - this.module.modelDream.Change(mdata.Id, map[string]interface{}{ - "join": mdata.Join, - }) return } diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 9bf9a97a7..fda19da4b 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -66,7 +66,10 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle cd = pb.ErrorCode_MoonfantasyHasExpired return } - + if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期 + cd = pb.ErrorCode_MoonfantasyHasExpired + return + } for _, v := range mdata.Join { if v.Uid == session.GetUserId() { isjoin = true @@ -114,7 +117,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle Ptype: pb.PlayType_moonfantasy, Leadpos: req.Leadpos, Teamids: req.Teamids, - Mformat: []int32{boss.Monsterformatid}, + Mformat: boss.Monsterformatid, }) return } diff --git a/modules/moonfantasy/api_getlist.go b/modules/moonfantasy/api_getlist.go index f9385b44a..b2d006fa7 100644 --- a/modules/moonfantasy/api_getlist.go +++ b/modules/moonfantasy/api_getlist.go @@ -4,6 +4,8 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + "time" "google.golang.org/protobuf/proto" ) @@ -14,21 +16,34 @@ func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.Moonfantasy return } -///获取用户装备列表 +///获取用户秘境列表 func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode, data proto.Message) { var ( - err error - umfantasy *pb.DBUserMFantasy - mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0) + err error + globalconf *cfg.GameGlobalData + umfantasy *pb.DBUserMFantasy + mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0) ) if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil { code = pb.ErrorCode_CacheReadError return } - if len(umfantasy.Mfantasys) > 0 { - mfantasys, err = this.module.modelDream.querymfantasys(umfantasy.Mfantasys) + globalconf = this.module.configure.GetGlobalConf() + if time.Unix(umfantasy.LastTrigger, 0).Day() != time.Now().Day() { + umfantasy.TriggerNum = 0 + umfantasy.LastTrigger = time.Now().Unix() + umfantasy.BuyNum = 0 + if umfantasy.BattleNum < globalconf.DreamlandFightnum { + umfantasy.BattleNum = globalconf.DreamlandFightnum + } + this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ + "triggerNum": umfantasy.TriggerNum, + "lastTrigger": umfantasy.LastTrigger, + "buyNum": umfantasy.BuyNum, + "battleNum": umfantasy.BattleNum, + }) } - + mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId()) session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{ BattleNum: umfantasy.BattleNum, BuyNum: umfantasy.BuyNum, diff --git a/modules/moonfantasy/api_receive.go b/modules/moonfantasy/api_receive.go index 98849ee4d..28f159f89 100644 --- a/modules/moonfantasy/api_receive.go +++ b/modules/moonfantasy/api_receive.go @@ -20,7 +20,6 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.Moonfantasy func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( boss *cfg.GameDreamlandBoosData - award []*cfg.Gameatn = make([]*cfg.Gameatn, 0) iswin bool err error ) @@ -39,8 +38,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei code = pb.ErrorCode_MoonfantasyBattleNoWin return } - this.module.configure.GetDropReward(boss.Prize, award) - this.module.DispenseRes(session, award, true) + this.module.DispenseRes(session, boss.Prize, true) session.SendMsg(string(this.module.GetType()), "receive", &pb.MoonfantasyReceiveResp{Issucc: true}) return } diff --git a/modules/moonfantasy/api_trigger.go b/modules/moonfantasy/api_trigger.go deleted file mode 100644 index 8985ca918..000000000 --- a/modules/moonfantasy/api_trigger.go +++ /dev/null @@ -1,87 +0,0 @@ -package moonfantasy - -// //参数校验 -// func (this *apiComp) TriggerCheck(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode) { -// return -// } - -// ///获取本服聊天消息记录 -// func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode, data proto.Message) { -// var ( -// user *pb.DBUser -// umfantasy *pb.DBUserMFantasy -// globalconf *cfg.GameGlobalData -// uexpand *pb.DBUserExpand -// boss *cfg.GameDreamlandBoosData -// mdata *pb.DBMoonFantasy -// chat *pb.DBChat -// issucc bool -// err error -// ) - -// if code = this.TriggerCheck(session, req); code != pb.ErrorCode_Success { -// return -// } -// globalconf = this.module.configure.GetGlobalConf() -// n, _ := rand.Int(rand.Reader, big.NewInt(100)) -// if int32(n.Int64()) < globalconf.DreamlandPro { -// issucc = true -// } else { -// issucc = false -// } -// if issucc { -// if uexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { -// code = pb.ErrorCode_DBError -// this.module.Errorln(err) -// return -// } -// if time.Unix(uexpand.MoonfantasyLastTrigger, 0).Day() != time.Now().Day() { -// uexpand.MoonfantasyTriggerNum = 0 -// } - -// if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum { -// return -// } - -// if boss, err = this.module.configure.GetMonster(); err != nil { -// code = pb.ErrorCode_ConfigNoFound -// return -// } -// if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { -// this.module.Errorf("no found uer:%d", session.GetUserId()) -// code = pb.ErrorCode_DBError -// return -// } -// if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil { -// code = pb.ErrorCode_CacheReadError -// return -// } -// if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil { -// code = pb.ErrorCode_DBError -// return -// } -// umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) -// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ -// "mfantasys": umfantasy.Mfantasys, -// }) -// this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ -// "moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1, -// "moonfantasyLastTrigger": time.Now().Unix(), -// }) -// chat = &pb.DBChat{ -// Ctype: pb.ChatType_Moonfantasy, -// Suid: session.GetUserId(), -// Avatar: req.Avatar, -// Uname: req.Uname, -// Slv: req.Ulv, -// Stag: session.GetServiecTag(), -// Content: mdata.Monster, -// AppendStr: mdata.Id, -// } -// this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat) -// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster}) -// } else { -// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false}) -// } -// return -// } diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go index e9d124f7e..cf8027851 100644 --- a/modules/moonfantasy/modelDream.go +++ b/modules/moonfantasy/modelDream.go @@ -40,21 +40,29 @@ func (this *modelDreamComp) newDreamLock(mid string) (result *redis.RedisMutex, return this.module.modelDream.NewRedisMutex(fmt.Sprintf("%s-%s_lock", this.TableName, mid), 5) } -///添加月之秘境记录 +///查询月之秘境记录 func (this *modelDreamComp) querymfantasy(mid string) (result *pb.DBMoonFantasy, err error) { result = &pb.DBMoonFantasy{} - if err = this.Get(mid, result); err != nil && err != mongo.ErrNilDocument { + if err = this.GetListObj("", mid, result); err != nil && err != mongo.ErrNilDocument { this.module.Errorln(err) } return } ///插叙用户秘境列表 -func (this *modelDreamComp) querymfantasys(mids []string) (fantasys []*pb.DBMoonFantasy, err error) { - fantasys = make([]*pb.DBMoonFantasy, 0) - if err = this.Gets(mids, &fantasys); err != nil { +func (this *modelDreamComp) querymfantasys(uid string) (result []*pb.DBMoonFantasy, err error) { + fantasys := make([]*pb.DBMoonFantasy, 0) + if err = this.GetList("", &fantasys); err != nil { this.module.Errorf("err:%v", err) } + result = make([]*pb.DBMoonFantasy, 0, len(fantasys)) + for _, v := range fantasys { + for _, u := range v.Join { + if u.Uid == uid { + result = append(result, v) + } + } + } return } @@ -68,9 +76,10 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml Join: []*pb.UserInfo{user}, Numup: boss.Challengenum, Unitmup: boss.Fightnum, + Expir: time.Now().Add(time.Second * time.Duration(boss.DreamlandLimit)).Unix(), Record: make(map[string]int32), } - if err = this.Add(result.Id, result); err != nil { + if err = this.AddList("", result.Id, result); err != nil { this.module.Errorln(err) } return @@ -104,7 +113,7 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum { return } - umfantasy.TriggerNum++ + if boss, err = this.module.configure.GetMonster(); err != nil { this.module.Errorln(err) return @@ -117,9 +126,10 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}, boss); err != nil { return } - umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + // umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + umfantasy.TriggerNum++ this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ - "mfantasys": umfantasy.Mfantasys, + // "mfantasys": umfantasy.Mfantasys, "triggerNum": umfantasy.TriggerNum, "lastTrigger": umfantasy.LastTrigger, "buyNum": umfantasy.BuyNum, @@ -185,3 +195,11 @@ func (this *modelDreamComp) delaynoticeWorld(stag, mid string, chat *pb.DBChat) this.module.chat.SendWorldChat(_chat) }, mid, chat) } + +func (this *modelDreamComp) checkMFantasyExpiration(mf *pb.DBMoonFantasy) bool { + if time.Now().After(time.Unix(mf.Expir, 0)) { //已过期 + this.DelListlds("", mf.Id) + return true + } + return false +} diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go index 5af4293c5..5063e94b6 100644 --- a/modules/moonfantasy/modelUserMF.go +++ b/modules/moonfantasy/modelUserMF.go @@ -39,7 +39,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (fantasy *pb.DBUserMFanta if err == mgo.MongodbNil { fantasy.Id = primitive.NewObjectID().Hex() fantasy.Uid = uId - fantasy.Mfantasys = make([]string, 0) + // fantasy.Mfantasys = make([]string, 0) if err = this.Add(uId, fantasy); err != nil { this.module.Errorf("err:%v", err) } diff --git a/pb/moonfantasy_db.pb.go b/pb/moonfantasy_db.pb.go index 249128ca9..35e0859e4 100644 --- a/pb/moonfantasy_db.pb.go +++ b/pb/moonfantasy_db.pb.go @@ -104,7 +104,8 @@ type DBMoonFantasy struct { Join []*UserInfo `protobuf:"bytes,5,rep,name=join,proto3" json:"join"` //参与人数 Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限 Unitmup int32 `protobuf:"varint,7,opt,name=unitmup,proto3" json:"unitmup"` //单人可挑战次数 - Record map[string]int32 `protobuf:"bytes,8,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录 + Expir int64 `protobuf:"varint,8,opt,name=expir,proto3" json:"expir"` //过期时间 + Record map[string]int32 `protobuf:"bytes,9,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录 } func (x *DBMoonFantasy) Reset() { @@ -188,6 +189,13 @@ func (x *DBMoonFantasy) GetUnitmup() int32 { return 0 } +func (x *DBMoonFantasy) GetExpir() int64 { + if x != nil { + return x.Expir + } + return 0 +} + func (x *DBMoonFantasy) GetRecord() map[string]int32 { if x != nil { return x.Record @@ -201,13 +209,12 @@ type DBUserMFantasy struct { 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"` //用户id - Mfantasys []string `protobuf:"bytes,3,rep,name=mfantasys,proto3" json:"mfantasys"` //月之秘境列表 - TriggerNum int32 `protobuf:"varint,4,opt,name=triggerNum,proto3" json:"triggerNum" bson:"triggerNum"` // 月之秘境触发次数 - BattleNum int32 `protobuf:"varint,5,opt,name=battleNum,proto3" json:"battleNum" bson:"battleNum"` // 月之秘境挑战次数 - BuyNum int32 `protobuf:"varint,6,opt,name=buyNum,proto3" json:"buyNum" bson:"buyNum"` // 月之秘境挑战次数 - LastTrigger int64 `protobuf:"varint,7,opt,name=lastTrigger,proto3" json:"lastTrigger" bson:"lastTrigger"` // 月之秘境最后触发时间 + 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"` //用户id + TriggerNum int32 `protobuf:"varint,3,opt,name=triggerNum,proto3" json:"triggerNum" bson:"triggerNum"` // 月之秘境触发次数 + BattleNum int32 `protobuf:"varint,4,opt,name=battleNum,proto3" json:"battleNum" bson:"battleNum"` // 月之秘境挑战次数 + BuyNum int32 `protobuf:"varint,5,opt,name=buyNum,proto3" json:"buyNum" bson:"buyNum"` // 月之秘境挑战次数 + LastTrigger int64 `protobuf:"varint,6,opt,name=lastTrigger,proto3" json:"lastTrigger" bson:"lastTrigger"` // 月之秘境最后触发时间 } func (x *DBUserMFantasy) Reset() { @@ -256,13 +263,6 @@ func (x *DBUserMFantasy) GetUid() string { return "" } -func (x *DBUserMFantasy) GetMfantasys() []string { - if x != nil { - return x.Mfantasys - } - return nil -} - func (x *DBUserMFantasy) GetTriggerNum() int32 { if x != nil { return x.TriggerNum @@ -301,7 +301,7 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, - 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x9f, 0x02, 0x0a, + 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0xb5, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 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, @@ -313,27 +313,27 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70, 0x12, - 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2e, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 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, 0xc8, - 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, - 0x79, 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, 0x1c, 0x0a, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, - 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, - 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, - 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, - 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x14, 0x0a, 0x05, 0x65, 0x78, 0x70, 0x69, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x65, 0x78, 0x70, 0x69, 0x72, 0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, + 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 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, 0xaa, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 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, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x69, + 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, + 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x61, + 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, + 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x12, + 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, + 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/sys/configure/structs/Game.DreamlandBoosData.go b/sys/configure/structs/Game.DreamlandBoosData.go index ba2fdf07e..dd914bab2 100644 --- a/sys/configure/structs/Game.DreamlandBoosData.go +++ b/sys/configure/structs/Game.DreamlandBoosData.go @@ -15,8 +15,9 @@ type GameDreamlandBoosData struct { Pro int32 Fightnum int32 Challengenum int32 - Prize int32 - Monsterformatid int32 + Prize []*Gameatn + Monsterformatid []int32 + DreamlandLimit int32 } const TypeId_GameDreamlandBoosData = -1451313715 @@ -30,8 +31,35 @@ func (_v *GameDreamlandBoosData)Deserialize(_buf map[string]interface{}) (err er { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pro"].(float64); !_ok_ { err = errors.New("pro error"); return }; _v.Pro = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["fightnum"].(float64); !_ok_ { err = errors.New("fightnum error"); return }; _v.Fightnum = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["challengenum"].(float64); !_ok_ { err = errors.New("challengenum error"); return }; _v.Challengenum = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["prize"].(float64); !_ok_ { err = errors.New("prize error"); return }; _v.Prize = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monsterformatid"].(float64); !_ok_ { err = errors.New("monsterformatid error"); return }; _v.Monsterformatid = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["prize"].([]interface{}); !_ok_ { err = errors.New("prize error"); return } + + _v.Prize = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Prize = append(_v.Prize, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["monsterformatid"].([]interface{}); !_ok_ { err = errors.New("monsterformatid error"); return } + + _v.Monsterformatid = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Monsterformatid = append(_v.Monsterformatid, _list_v_) + } + } + + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["dreamland_limit"].(float64); !_ok_ { err = errors.New("dreamland_limit error"); return }; _v.DreamlandLimit = int32(_tempNum_) } return } diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index fa31e6c12..976929af4 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -89,9 +89,15 @@ type DBModel struct { } func (this *DBModel) ukey(uid string) string { + if uid == "" { + return fmt.Sprintf("%s:member", this.TableName) + } return fmt.Sprintf("%s:%s", this.TableName, uid) } func (this *DBModel) ukeylist(uid string, id string) string { + if uid == "" { + return fmt.Sprintf("%s:%s", this.TableName, id) + } return fmt.Sprintf("%s:%s-%s", this.TableName, uid, id) } func (this *DBModel) InsertModelLogs(table string, uID string, target interface{}) (err error) { @@ -516,8 +522,12 @@ func (this *DBModel) GetList(uid string, data interface{}) (err error) { } } if err == lgredis.RedisNil { + var f = bson.M{} + if uid != "" { + f = bson.M{"uid": uid} + } //query from mgo - if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil { + if c, err = this.DB.Find(core.SqlTable(this.TableName), f); err != nil { return err } else { if encoder, ok = codec.EncoderOf(sliceelemType, defconf).(codecore.IEncoderMapJson); !ok { @@ -794,8 +804,8 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er onfound = ids } - if err == lgredis.RedisNil { - if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": ids}}); err != nil { + if len(onfound) > 0 { + if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": onfound}}); err != nil { return err } else { if encoder, ok = codec.EncoderOf(sliceelemType, defconf).(codecore.IEncoderMapJson); !ok { @@ -818,6 +828,11 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er if tempdata, err = encoder.EncodeToMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetWriter()); err != nil { return } + for i, v := range onfound { + if v == _id { + onfound = append(onfound[0:i], onfound[i+1:]...) + } + } key := this.ukeylist(uid, _id) pipe.HMSetForMap(key, tempdata) keys[_id] = key @@ -829,6 +844,9 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er } } } + if len(onfound) > 0 { + err = fmt.Errorf("onfound:%v data!", onfound) + } if this.Expired > 0 { childs := make(map[string]struct{}, len(keys)) for _, v := range keys { From 7a85b1bd7d6633d8e06e0be03c80d326e70d5a01 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 14 Oct 2022 19:03:12 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8D=A1=E7=89=8C=E5=90=88=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_fusion.go | 81 ++++++++++++++ modules/hero/configure_comp.go | 19 ++++ pb/hero_msg.pb.go | 186 ++++++++++++++++++++++++++++----- 3 files changed, 259 insertions(+), 27 deletions(-) create mode 100644 modules/hero/api_fusion.go diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go new file mode 100644 index 000000000..e1b36edf1 --- /dev/null +++ b/modules/hero/api_fusion.go @@ -0,0 +1,81 @@ +package hero + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + "strconv" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) FusionCheck(session comm.IUserSession, req *pb.HeroFusionReq) (code pb.ErrorCode) { + if req.FuionId <= 0 { + code = pb.ErrorCode_ReqParameterError + } + return +} + +func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (code pb.ErrorCode, data proto.Message) { + var ( + totalCount int32 + mapHero map[string]int32 + _costMaphero map[string]*pb.DBHero + ChangeList []*pb.DBHero // 变化的英雄数据 + ) + ChangeList = make([]*pb.DBHero, 0) + _costMaphero = make(map[string]*pb.DBHero, 0) + mapHero = make(map[string]int32) + if code = this.FusionCheck(session, req); code != pb.ErrorCode_Success { + return + } + conf := this.module.configure.GetHeroFucionConfig(req.FuionId) + if conf == nil { + code = pb.ErrorCode_ConfigNoFound // 配置没找到 + return + } + for _, v := range req.Heros { + totalCount += v + } + if totalCount != int32(len(conf.Pointhero)) { // 校验数量 + code = pb.ErrorCode_ReqParameterError + return + } + for k, v := range req.Heros { + // 校验英雄是否存在 + _obj, c := this.module.GetHeroByObjID(session.GetUserId(), k) + if c != pb.ErrorCode_Success || _obj.SameCount < v { + code = pb.ErrorCode_HeroNoExist + } + mapHero[_obj.HeroID] = v + _costMaphero[k] = _obj + } + for _, v := range conf.Pointhero { + if v1, ok := mapHero[strconv.Itoa(int(v))]; !ok { + v1 -= v + } else { + code = pb.ErrorCode_ReqParameterError + return + } + } + for _, v := range mapHero { + if v != 0 { + code = pb.ErrorCode_ReqParameterError + return + } + } + for k, v := range _costMaphero { + code = this.module.DelCard(session.GetUserId(), v, mapHero[k]) + if code != pb.ErrorCode_Success { + return + } + ChangeList = append(ChangeList, _costMaphero[k]) + } + // 获得新卡 + newHero, err := this.module.modelHero.createHeroOverlying(session.GetUserId(), strconv.Itoa(int(conf.Hero)), 1) + if err != nil { + ChangeList = append(ChangeList, newHero) + } + session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList}) + return +} diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index 925c785c9..dfa58f484 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -25,6 +25,7 @@ const ( hero_drawcard = "game_drawcard.json" // 抽卡 hero_drawupdraw = "game_drawupdraw.json" // 抽卡概率调整 hero_drawcost = "game_drawcost.json" // 抽卡消耗 + hero_fusion = "game_herofusion.json" // 卡牌融合 ) ///配置管理组件 @@ -53,6 +54,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp game_skillatk: cfg.NewGameSkillAtk, hero_comatn: cfg.NewGameComAtn, hero_drawcard: cfg.NewGameDrawCard, + hero_fusion: cfg.NewGameHerofusion, }) this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0) @@ -380,3 +382,20 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat return } + +// 获取卡牌合成配置 +func (this *configureComp) GetHeroFucionConfig(id int32) (data *cfg.GameHerofusionData) { + + if v, err := this.GetConfigure(hero_fusion); err == nil { + if configure, ok := v.(*cfg.GameHerofusion); !ok { + err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v) + return + } else { + data = configure.Get(id) + } + } else { + err = fmt.Errorf("%T no is *cfg.GameHerofusionData", v) + } + + return +} diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 066a55286..459625d3b 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1686,6 +1686,100 @@ func (x *HeroDrawCardFloorResp) GetStar5() int32 { return 0 } +// 英雄融合 +type HeroFusionReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FuionId int32 `protobuf:"varint,1,opt,name=fuionId,proto3" json:"fuionId"` + Heros map[string]int32 `protobuf:"bytes,2,rep,name=heros,proto3" json:"heros" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key heroObjID value 数量 +} + +func (x *HeroFusionReq) Reset() { + *x = HeroFusionReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroFusionReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroFusionReq) ProtoMessage() {} + +func (x *HeroFusionReq) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[32] + 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 HeroFusionReq.ProtoReflect.Descriptor instead. +func (*HeroFusionReq) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{32} +} + +func (x *HeroFusionReq) GetFuionId() int32 { + if x != nil { + return x.FuionId + } + return 0 +} + +func (x *HeroFusionReq) GetHeros() map[string]int32 { + if x != nil { + return x.Heros + } + return nil +} + +type HeroFusionResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *HeroFusionResp) Reset() { + *x = HeroFusionResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroFusionResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroFusionResp) ProtoMessage() {} + +func (x *HeroFusionResp) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[33] + 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 HeroFusionResp.ProtoReflect.Descriptor instead. +func (*HeroFusionResp) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{33} +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1835,8 +1929,18 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x72, 0x64, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x34, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x34, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x35, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x35, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x35, 0x22, 0x94, 0x01, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, + 0x46, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x75, 0x69, + 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x66, 0x75, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x05, 0x68, 0x65, 0x72, 0x6f, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x46, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x71, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x68, + 0x65, 0x72, 0x6f, 0x73, 0x1a, 0x38, 0x0a, 0x0a, 0x48, 0x65, 0x72, 0x6f, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 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, 0x10, + 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x46, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1851,7 +1955,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { return file_hero_hero_msg_proto_rawDescData } -var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 34) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 37) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoResp)(nil), // 1: HeroInfoResp @@ -1885,35 +1989,39 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroChangePush)(nil), // 29: HeroChangePush (*HeroDrawCardFloorReq)(nil), // 30: HeroDrawCardFloorReq (*HeroDrawCardFloorResp)(nil), // 31: HeroDrawCardFloorResp - nil, // 32: HeroPropertyPush.PropertyEntry - nil, // 33: HeroPropertyPush.AddPropertyEntry - (*DBHero)(nil), // 34: DBHero + (*HeroFusionReq)(nil), // 32: HeroFusionReq + (*HeroFusionResp)(nil), // 33: HeroFusionResp + nil, // 34: HeroPropertyPush.PropertyEntry + nil, // 35: HeroPropertyPush.AddPropertyEntry + nil, // 36: HeroFusionReq.HerosEntry + (*DBHero)(nil), // 37: DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 34, // 0: HeroInfoResp.base:type_name -> DBHero - 34, // 1: HeroListResp.list:type_name -> DBHero + 37, // 0: HeroInfoResp.base:type_name -> DBHero + 37, // 1: HeroListResp.list:type_name -> DBHero 5, // 2: HeroStrengthenUplvReq.expCards:type_name -> MapStringInt32 - 34, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero + 37, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero 8, // 4: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 8, // 5: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData - 34, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero - 34, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero - 34, // 8: HeroResonanceResp.hero:type_name -> DBHero - 34, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero - 34, // 10: HeroResonanceResetResp.hero:type_name -> DBHero + 37, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero + 37, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero + 37, // 8: HeroResonanceResp.hero:type_name -> DBHero + 37, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero + 37, // 10: HeroResonanceResetResp.hero:type_name -> DBHero 17, // 11: HeroResonanceUseEnergyReq.energy:type_name -> EnergyData - 34, // 12: HeroResonanceUseEnergyResp.hero:type_name -> DBHero - 34, // 13: HeroAwakenResp.hero:type_name -> DBHero - 32, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry - 33, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry - 34, // 16: HeroLockResp.hero:type_name -> DBHero - 34, // 17: HeroGetSpecifiedResp.hero:type_name -> DBHero - 34, // 18: HeroChangePush.list:type_name -> DBHero - 19, // [19:19] is the sub-list for method output_type - 19, // [19:19] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 37, // 12: HeroResonanceUseEnergyResp.hero:type_name -> DBHero + 37, // 13: HeroAwakenResp.hero:type_name -> DBHero + 34, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry + 35, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry + 37, // 16: HeroLockResp.hero:type_name -> DBHero + 37, // 17: HeroGetSpecifiedResp.hero:type_name -> DBHero + 37, // 18: HeroChangePush.list:type_name -> DBHero + 36, // 19: HeroFusionReq.heros:type_name -> HeroFusionReq.HerosEntry + 20, // [20:20] is the sub-list for method output_type + 20, // [20:20] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_hero_hero_msg_proto_init() } @@ -2307,6 +2415,30 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroFusionReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hero_hero_msg_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroFusionResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2314,7 +2446,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 34, + NumMessages: 37, NumExtensions: 0, NumServices: 0, }, From f28acb2f29f478f34eb9c16fcd405b7955518c1b Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 17 Oct 2022 11:52:06 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0rpc=20worker=20=E7=AB=AF?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E6=8E=A5=E5=8F=A3=E5=BC=80=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/rpcx/rpcx.go | 44 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/lego/sys/rpcx/rpcx.go b/lego/sys/rpcx/rpcx.go index 5f8d27e2e..670977a69 100644 --- a/lego/sys/rpcx/rpcx.go +++ b/lego/sys/rpcx/rpcx.go @@ -2,6 +2,7 @@ package rpcx import ( "context" + "strings" "github.com/smallnest/rpcx/client" ) @@ -66,36 +67,65 @@ func (this *RPCX) UnregisterAll() (err error) { //同步调用 func (this *RPCX) Call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { - return this.client.Call(ctx, servicePath, serviceMethod, args, reply) + //先排查下 服务端是否存在连接对象 不存在 在使用客户端对象连接 + err = this.service.Call(ctx, servicePath, serviceMethod, args, reply) + if strings.Contains(err.Error(), "on found") { + return this.client.Call(ctx, servicePath, serviceMethod, args, reply) + } + return } //广播调用 func (this *RPCX) Broadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { - return this.client.Broadcast(ctx, servicePath, serviceMethod, args, reply) + err = this.service.Broadcast(ctx, servicePath, serviceMethod, args, reply) + if strings.Contains(err.Error(), "on found") { + return this.client.Broadcast(ctx, servicePath, serviceMethod, args, reply) + } + return } //异步调用 func (this *RPCX) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) { - return this.client.Go(ctx, servicePath, serviceMethod, args, reply, done) + call, err = this.service.Go(ctx, servicePath, serviceMethod, args, reply, done) + if strings.Contains(err.Error(), "on found") { + return this.client.Go(ctx, servicePath, serviceMethod, args, reply, done) + } + return } //跨服同步调用 func (this *RPCX) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { - return this.client.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply) + err = this.service.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply) + if strings.Contains(err.Error(), "on found") { + return this.client.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply) + } + return } //跨集群 广播 func (this *RPCX) AcrossClusterBroadcast(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { - err = this.client.AcrossClusterBroadcast(ctx, clusterTag, servicePath, serviceMethod, args, reply) + err = this.service.AcrossClusterBroadcast(ctx, clusterTag, servicePath, serviceMethod, args, reply) + if strings.Contains(err.Error(), "on found") { + return this.client.AcrossClusterBroadcast(ctx, clusterTag, servicePath, serviceMethod, args, reply) + } return } //跨服异步调用 func (this *RPCX) AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) { - return this.client.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done) + call, err = this.service.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done) + if strings.Contains(err.Error(), "on found") { + return this.client.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done) + } + return } //全集群广播 func (this *RPCX) ClusterBroadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { - return this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply) + + err = this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply) + if strings.Contains(err.Error(), "on found") { + return this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply) + } + return } From a28f4a539684ecdbd68ef7c5d1a2475ffc282a4b Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 17 Oct 2022 11:55:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwoker=20=E9=80=9A?= =?UTF-8?q?=E4=BF=A1bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/rpcx/rpcx.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lego/sys/rpcx/rpcx.go b/lego/sys/rpcx/rpcx.go index 670977a69..9efe81287 100644 --- a/lego/sys/rpcx/rpcx.go +++ b/lego/sys/rpcx/rpcx.go @@ -69,7 +69,7 @@ func (this *RPCX) UnregisterAll() (err error) { func (this *RPCX) Call(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { //先排查下 服务端是否存在连接对象 不存在 在使用客户端对象连接 err = this.service.Call(ctx, servicePath, serviceMethod, args, reply) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.Call(ctx, servicePath, serviceMethod, args, reply) } return @@ -78,7 +78,7 @@ func (this *RPCX) Call(ctx context.Context, servicePath string, serviceMethod st //广播调用 func (this *RPCX) Broadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { err = this.service.Broadcast(ctx, servicePath, serviceMethod, args, reply) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.Broadcast(ctx, servicePath, serviceMethod, args, reply) } return @@ -87,7 +87,7 @@ func (this *RPCX) Broadcast(ctx context.Context, servicePath string, serviceMeth //异步调用 func (this *RPCX) Go(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) { call, err = this.service.Go(ctx, servicePath, serviceMethod, args, reply, done) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.Go(ctx, servicePath, serviceMethod, args, reply, done) } return @@ -96,7 +96,7 @@ func (this *RPCX) Go(ctx context.Context, servicePath string, serviceMethod stri //跨服同步调用 func (this *RPCX) AcrossClusterCall(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { err = this.service.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.AcrossClusterCall(ctx, clusterTag, servicePath, serviceMethod, args, reply) } return @@ -105,7 +105,7 @@ func (this *RPCX) AcrossClusterCall(ctx context.Context, clusterTag string, serv //跨集群 广播 func (this *RPCX) AcrossClusterBroadcast(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { err = this.service.AcrossClusterBroadcast(ctx, clusterTag, servicePath, serviceMethod, args, reply) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.AcrossClusterBroadcast(ctx, clusterTag, servicePath, serviceMethod, args, reply) } return @@ -114,7 +114,7 @@ func (this *RPCX) AcrossClusterBroadcast(ctx context.Context, clusterTag string, //跨服异步调用 func (this *RPCX) AcrossClusterGo(ctx context.Context, clusterTag string, servicePath string, serviceMethod string, args interface{}, reply interface{}, done chan *client.Call) (call *client.Call, err error) { call, err = this.service.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.AcrossClusterGo(ctx, clusterTag, servicePath, serviceMethod, args, reply, done) } return @@ -124,7 +124,7 @@ func (this *RPCX) AcrossClusterGo(ctx context.Context, clusterTag string, servic func (this *RPCX) ClusterBroadcast(ctx context.Context, servicePath string, serviceMethod string, args interface{}, reply interface{}) (err error) { err = this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply) - if strings.Contains(err.Error(), "on found") { + if err != nil && strings.Contains(err.Error(), "on found") { return this.client.ClusterBroadcast(ctx, servicePath, serviceMethod, args, reply) } return From 9875ed8a2f65c0443ac58df375670f78da81b910 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 17 Oct 2022 14:16:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=90=88=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=85=8D=E7=BD=AE=E7=B1=BB=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_herofusion.json | 50 ++++++++++---------- modules/hero/api_fusion.go | 7 ++- sys/configure/structs/Game.HerofusionData.go | 12 ++--- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/bin/json/game_herofusion.json b/bin/json/game_herofusion.json index ae1cafb7f..f1b90c776 100644 --- a/bin/json/game_herofusion.json +++ b/bin/json/game_herofusion.json @@ -2,12 +2,12 @@ { "id": 1, "switch": 1, - "hero": 14007, + "hero": "14007", "pointhero": [ - 35001, - 35001, - 35001, - 35001 + "35001", + "35001", + "35001", + "35001" ], "awaken": -1, "start": -1 @@ -15,12 +15,12 @@ { "id": 2, "switch": 1, - "hero": 35001, + "hero": "35001", "pointhero": [ - 25001, - 25001, - 25001, - 25001 + "25001", + "25001", + "25001", + "25001" ], "awaken": -1, "start": -1 @@ -28,12 +28,12 @@ { "id": 3, "switch": 1, - "hero": 25001, + "hero": "25001", "pointhero": [ - 25004, - 25004, - 25004, - 25004 + "25004", + "25004", + "25004", + "25004" ], "awaken": -1, "start": -1 @@ -41,12 +41,12 @@ { "id": 4, "switch": 1, - "hero": 25004, + "hero": "25004", "pointhero": [ - 44005, - 44005, - 44005, - 44005 + "44005", + "44005", + "44005", + "44005" ], "awaken": -1, "start": -1 @@ -54,12 +54,12 @@ { "id": 5, "switch": 1, - "hero": 45003, + "hero": "45003", "pointhero": [ - 44005, - 44005, - 44005, - 44005 + "44005", + "44005", + "44005", + "44005" ], "awaken": -1, "start": -1 diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go index e1b36edf1..bac9e8a03 100644 --- a/modules/hero/api_fusion.go +++ b/modules/hero/api_fusion.go @@ -3,7 +3,6 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" - "strconv" "google.golang.org/protobuf/proto" ) @@ -51,8 +50,8 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c _costMaphero[k] = _obj } for _, v := range conf.Pointhero { - if v1, ok := mapHero[strconv.Itoa(int(v))]; !ok { - v1 -= v + if _, ok := mapHero[v]; !ok { + mapHero[v] -= 1 } else { code = pb.ErrorCode_ReqParameterError return @@ -72,7 +71,7 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c ChangeList = append(ChangeList, _costMaphero[k]) } // 获得新卡 - newHero, err := this.module.modelHero.createHeroOverlying(session.GetUserId(), strconv.Itoa(int(conf.Hero)), 1) + newHero, err := this.module.modelHero.createHeroOverlying(session.GetUserId(), conf.Hero, 1) if err != nil { ChangeList = append(ChangeList, newHero) } diff --git a/sys/configure/structs/Game.HerofusionData.go b/sys/configure/structs/Game.HerofusionData.go index 74641a9e7..eb481d465 100644 --- a/sys/configure/structs/Game.HerofusionData.go +++ b/sys/configure/structs/Game.HerofusionData.go @@ -13,8 +13,8 @@ import "errors" type GameHerofusionData struct { Id int32 Switch int32 - Hero int32 - Pointhero []int32 + Hero string + Pointhero []string Awaken int32 Start int32 } @@ -28,17 +28,17 @@ func (*GameHerofusionData) GetTypeId() int32 { func (_v *GameHerofusionData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["switch"].(float64); !_ok_ { err = errors.New("switch error"); return }; _v.Switch = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["hero"].(float64); !_ok_ { err = errors.New("hero error"); return }; _v.Hero = int32(_tempNum_) } + { var _ok_ bool; if _v.Hero, _ok_ = _buf["hero"].(string); !_ok_ { err = errors.New("hero error"); return } } { var _arr_ []interface{} var _ok_ bool if _arr_, _ok_ = _buf["pointhero"].([]interface{}); !_ok_ { err = errors.New("pointhero error"); return } - _v.Pointhero = make([]int32, 0, len(_arr_)) + _v.Pointhero = make([]string, 0, len(_arr_)) for _, _e_ := range _arr_ { - var _list_v_ int32 - { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + var _list_v_ string + { if _list_v_, _ok_ = _e_.(string); !_ok_ { err = errors.New("_list_v_ error"); return } } _v.Pointhero = append(_v.Pointhero, _list_v_) } }