From 10415e821fa04a84a3d5b228f6fef4b04634ac9c Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 3 Mar 2023 22:30:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=E6=9C=80=E5=A4=9A=E8=BF=9E?= =?UTF-8?q?=E7=BB=AD=E5=87=BAA=E4=B8=AA=E7=9B=B8=E5=90=8C=E9=98=B5?= =?UTF-8?q?=E8=90=A5=E7=9A=84=E8=8B=B1=E9=9B=84=EF=BC=88=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E5=8D=A1=E6=B1=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_drawCard.go | 14 ++++-- modules/hero/model_record.go | 1 + modules/hero/module.go | 26 +++++++++++ pb/hero_db.pb.go | 90 +++++++++++++++++++++--------------- 4 files changed, 91 insertions(+), 40 deletions(-) diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index 0fa2f5cb4..c479a3eb9 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -281,17 +281,25 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq if v, ok := _data[int32(star)]; ok { if int32(len(v)) > randomIndex { + cardId := v[randomIndex].Id if star == 5 { // 抽出5星英雄后A次抽奖内不会再抽到5星英雄(普通卡池+阵营卡池) curDrawCount := drawCount - req.DrawCount if drawCount <= 10 { // 前10次不计算(连续抽卡最多连续出A个相同阵营的英雄) - szCards = append(szCards, v[randomIndex].Id) + szCards = append(szCards, cardId) continue } - newID := this.module.ContinuousRestriction(session.GetUserId(), v[randomIndex].Id, curDrawCount+int32(index+1), strPool[index]) + newID := this.module.ContinuousRestriction(session.GetUserId(), cardId, curDrawCount+int32(index+1), strPool[index]) szCards = append(szCards, newID) continue } - szCards = append(szCards, v[randomIndex].Id) + szCards = append(szCards, cardId) + // 普通卡池 最多连续出A个相同阵营的英雄 + if req.DrawType == 0 { + newId := this.module.DrawCardContinuousRestrictionCamp(cardId, heroRecord.Race, sz, v) + if cardId != newId { + szCards[len(szCards)-1] = newId + } + } } } } diff --git a/modules/hero/model_record.go b/modules/hero/model_record.go index 4c4f4c302..0caf230f3 100644 --- a/modules/hero/model_record.go +++ b/modules/hero/model_record.go @@ -31,6 +31,7 @@ func (this *ModelRecord) GetHeroRecord(uid string) (result *pb.DBHeroRecord, err result.Uid = uid result.Condition = map[string]int32{} result.Star5Hero = map[string]int32{} + result.Race = map[int32]int32{} result.Mtime = configure.Now().Unix() this.Add(uid, result) err = nil diff --git a/modules/hero/module.go b/modules/hero/module.go index 4445cf4a0..315e94f67 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -8,6 +8,7 @@ import ( "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "go_dreamfactory/utils" "math/big" @@ -855,3 +856,28 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid string, } return } + +//DrawCard_ContinuousRestriction_Camp +func (this *Hero) DrawCardContinuousRestrictionCamp(cardId string, race map[int32]int32, sz []int32, data []*cfg.GameDrawCardData) (card string) { + card = cardId + cfgDraw := this.configure.GetGlobalConf() // 读取抽卡配置文件 + if cfgDraw == nil || race == nil { + return + } + iMaxCount := cfgDraw.DrawCardContinuousRestrictionCamp + // 获取阵营 + if heroConf := this.configure.GetHeroConfig(cardId); heroConf != nil { + if v1, ok := race[heroConf.Race]; ok && v1 > iMaxCount { // 满足条件 再随机获取一个英雄 + for i := 0; i < 10; i++ { + randomIndex := this.modelHero.GetRandW(sz) + if int32(len(sz)) > randomIndex { + if v1, ok := race[heroConf.Race]; !ok && v1 <= iMaxCount { + card = data[randomIndex].Id + break + } + } + } + } + } + return card +} diff --git a/pb/hero_db.pb.go b/pb/hero_db.pb.go index bc6e5c1f4..82f41742a 100644 --- a/pb/hero_db.pb.go +++ b/pb/hero_db.pb.go @@ -365,6 +365,7 @@ type DBHeroRecord struct { Tenbuy int32 `protobuf:"varint,12,opt,name=tenbuy,proto3" json:"tenbuy"` // 十连购买次数 Inevitable int32 `protobuf:"varint,13,opt,name=inevitable,proto3" json:"inevitable"` //第2-30次抽奖必出一个5星英雄 Inevitable1 int32 `protobuf:"varint,14,opt,name=inevitable1,proto3" json:"inevitable1"` //第30-50次抽奖必出一个5星英雄 + Race map[int32]int32 `protobuf:"bytes,15,rep,name=race,proto3" json:"race" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key 阵营类型 value count } func (x *DBHeroRecord) Reset() { @@ -497,6 +498,13 @@ func (x *DBHeroRecord) GetInevitable1() int32 { return 0 } +func (x *DBHeroRecord) GetRace() map[int32]int32 { + if x != nil { + return x.Race + } + return nil +} + // 英雄天赋系统 type DBHeroTalent struct { state protoimpl.MessageState @@ -658,7 +666,7 @@ var file_hero_hero_db_proto_rawDesc = []byte{ 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 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, 0xb2, 0x04, 0x0a, 0x0c, 0x44, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x98, 0x05, 0x0a, 0x0c, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 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, 0x14, 0x0a, @@ -686,30 +694,36 @@ var file_hero_hero_db_proto_rawDesc = []byte{ 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x65, 0x76, 0x69, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6e, 0x65, 0x76, 0x69, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x31, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x69, 0x6e, 0x65, 0x76, 0x69, 0x74, 0x61, 0x62, - 0x6c, 0x65, 0x31, 0x1a, 0x3c, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 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, 0x1a, 0x3c, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x72, 0x35, 0x48, 0x65, 0x72, 0x6f, 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, - 0xb6, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, - 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, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x31, 0x0a, 0x06, 0x74, 0x61, - 0x6c, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x44, 0x42, 0x48, - 0x65, 0x72, 0x6f, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x1a, 0x39, 0x0a, - 0x0b, 0x54, 0x61, 0x6c, 0x65, 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, 0x2a, 0x2f, 0x0a, 0x08, 0x48, 0x65, 0x72, 0x6f, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x79, 0x70, 0x65, - 0x4e, 0x69, 0x6c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x79, 0x70, - 0x65, 0x4b, 0x6f, 0x6e, 0x67, 0x46, 0x75, 0x10, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x65, 0x31, 0x12, 0x2b, 0x0a, 0x04, 0x72, 0x61, 0x63, 0x65, 0x18, 0x0f, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x2e, 0x52, 0x61, 0x63, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x72, 0x61, 0x63, 0x65, + 0x1a, 0x3c, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 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, 0x1a, 0x3c, + 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x72, 0x35, 0x48, 0x65, 0x72, 0x6f, 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, 0x1a, 0x37, 0x0a, 0x09, + 0x52, 0x61, 0x63, 0x65, 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, 0xb6, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, + 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 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, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, + 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, + 0x12, 0x31, 0x0a, 0x06, 0x74, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x2e, + 0x54, 0x61, 0x6c, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x61, 0x6c, + 0x65, 0x6e, 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x54, 0x61, 0x6c, 0x65, 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, 0x2a, 0x2f, + 0x0a, 0x08, 0x48, 0x65, 0x72, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x65, + 0x72, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x69, 0x6c, 0x10, 0x00, 0x12, 0x12, 0x0a, 0x0e, 0x48, + 0x65, 0x72, 0x6f, 0x54, 0x79, 0x70, 0x65, 0x4b, 0x6f, 0x6e, 0x67, 0x46, 0x75, 0x10, 0x01, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -725,7 +739,7 @@ func file_hero_hero_db_proto_rawDescGZIP() []byte { } var file_hero_hero_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_hero_hero_db_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_hero_hero_db_proto_goTypes = []interface{}{ (HeroType)(0), // 0: HeroType (*DBHero)(nil), // 1: DBHero @@ -738,26 +752,28 @@ var file_hero_hero_db_proto_goTypes = []interface{}{ nil, // 8: DBHero.HoroscopePropertyEntry nil, // 9: DBHeroRecord.ConditionEntry nil, // 10: DBHeroRecord.Star5HeroEntry - nil, // 11: DBHeroTalent.TalentEntry - (*SkillData)(nil), // 12: SkillData + nil, // 11: DBHeroRecord.RaceEntry + nil, // 12: DBHeroTalent.TalentEntry + (*SkillData)(nil), // 13: SkillData } var file_hero_hero_db_proto_depIdxs = []int32{ - 12, // 0: DBHero.normalSkill:type_name -> SkillData + 13, // 0: DBHero.normalSkill:type_name -> SkillData 4, // 1: DBHero.property:type_name -> DBHero.PropertyEntry 5, // 2: DBHero.addProperty:type_name -> DBHero.AddPropertyEntry 6, // 3: DBHero.juexProperty:type_name -> DBHero.JuexPropertyEntry 0, // 4: DBHero.status:type_name -> HeroType 7, // 5: DBHero.talentProperty:type_name -> DBHero.TalentPropertyEntry - 12, // 6: DBHero.equipSkill:type_name -> SkillData + 13, // 6: DBHero.equipSkill:type_name -> SkillData 8, // 7: DBHero.horoscopeProperty:type_name -> DBHero.HoroscopePropertyEntry 9, // 8: DBHeroRecord.condition:type_name -> DBHeroRecord.ConditionEntry 10, // 9: DBHeroRecord.star5Hero:type_name -> DBHeroRecord.Star5HeroEntry - 11, // 10: DBHeroTalent.talent:type_name -> DBHeroTalent.TalentEntry - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 11, // 10: DBHeroRecord.race:type_name -> DBHeroRecord.RaceEntry + 12, // 11: DBHeroTalent.talent:type_name -> DBHeroTalent.TalentEntry + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_hero_hero_db_proto_init() } @@ -810,7 +826,7 @@ func file_hero_hero_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_db_proto_rawDesc, NumEnums: 1, - NumMessages: 11, + NumMessages: 12, NumExtensions: 0, NumServices: 0, },