This commit is contained in:
liwei1dao 2022-07-25 17:36:34 +08:00
commit 53076796e5
17 changed files with 1888 additions and 464296 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (config
return return
} else { } else {
if configure, ok = v.(*cfg.Game_equip).GetDataMap()[equipmentId]; !ok { if configure, ok = v.(*cfg.Game_equip).GetDataMap()[equipmentId]; !ok {
err = fmt.Errorf("EquipmentConfigure not found:%d ", equipmentId) err = fmt.Errorf("EquipmentConfigure not found:%s ", equipmentId)
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
return return
} }

View File

@ -75,7 +75,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
"isOverlying": false, "isOverlying": false,
} }
// 保存数据 // 保存数据
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err1 != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)
@ -94,7 +94,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
"isOverlying": false, "isOverlying": false,
} }
// 保存数据 // 保存数据
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err1 != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)

View File

@ -33,6 +33,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
config5Count int32 // 配置表中5星保底次数 config5Count int32 // 配置表中5星保底次数
race int32 race int32
upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加 upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加
cardW map[string]int32 // 当前卡牌对应的权重
) )
upDraw = make([]*cfg.Game_drawUpdrawData, 0) upDraw = make([]*cfg.Game_drawUpdrawData, 0)
szCards = make([]string, 0) szCards = make([]string, 0)
@ -77,7 +78,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
code = pb.ErrorCode_DrawCardTypeNotFound // 抽卡类型不匹配 code = pb.ErrorCode_DrawCardTypeNotFound // 抽卡类型不匹配
return return
} }
// 权重赋值
for _, v := range _conf {
cardW[v.Id] += v.Weight
}
_costConf, err := this.module.configure.GetDrawCostConfigByID(req.DrawType) // 抽卡消耗 _costConf, err := this.module.configure.GetDrawCostConfigByID(req.DrawType) // 抽卡消耗
if err != nil { if err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
@ -99,8 +103,20 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
} }
drawTimes = _costConf.Count // 抽卡次数 drawTimes = _costConf.Count // 抽卡次数
for _, v := range _conf { for k, v := range cardW { // k是heroid v 权重
totalWeight += int64(v.Weight) // 统计所有权重
for _, v1 := range upDraw {
for _, v2 := range v1.UpHero {
if v2 == k {
cardW[k] += v
}
}
// }
// if !updraw {
// totalWeight += int64(v.Weight) // 统计所有权重
// }
}
} }
drawTimes = 1 drawTimes = 1

View File

@ -36,7 +36,7 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.HeroLockReq) (code
"block": _hero.Block, "block": _hero.Block,
} }
// 保存数据 // 保存数据
err := this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
log.Errorf("update hero skill failed:%v", err) log.Errorf("update hero skill failed:%v", err)

View File

@ -105,7 +105,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
"distributionResonate": _hero.DistributionResonate, "distributionResonate": _hero.DistributionResonate,
"isOverlying": false, "isOverlying": false,
} }
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil { if err1 != nil {
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

@ -75,7 +75,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
"isOverlying": false, "isOverlying": false,
} }
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil { if err1 != nil {
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

@ -43,7 +43,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
"isOverlying": false, "isOverlying": false,
} }
err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 err1 := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil { if err1 != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)

View File

@ -36,7 +36,7 @@ func (this *apiComp) GetSpecified(session comm.IUserSession, req *pb.HeroGetSpec
"isOverlying": false, "isOverlying": false,
} }
// 保存数据 // 保存数据
err1 := this.module.modelHero.modifyHeroData(session.GetUserId(), hero.Id, _heroMap) err1 := this.module.modelHero.ChangeList(session.GetUserId(), hero.Id, _heroMap)
if err1 != nil { if err1 != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
log.Errorf("GetSpecified failed:%v", err) log.Errorf("GetSpecified failed:%v", err)

View File

@ -118,7 +118,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
"normalSkill": _hero.NormalSkill, "normalSkill": _hero.NormalSkill,
"isOverlying": false, "isOverlying": false,
} }
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息 err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil { if err1 != nil {
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

@ -163,7 +163,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
// 触发星级任务 // 触发星级任务
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroStar, &pb.TaskParam{First: _hero.Star}) this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroStar, &pb.TaskParam{First: _hero.Star})
// 保存数据 // 保存数据
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap) err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err1 != nil { if err1 != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
this.module.Errorf("update hero skill failed:%v", err1) this.module.Errorf("update hero skill failed:%v", err1)

View File

@ -139,7 +139,8 @@ func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count i
data := map[string]interface{}{ data := map[string]interface{}{
"sameCount": h.SameCount, //叠加数 "sameCount": h.SameCount, //叠加数
} }
if err := this.modifyHeroData(uid, h.Id, data); err != nil {
if err := this.ChangeList(uid, h.Id, data); err != nil {
return nil, err return nil, err
} }
} }
@ -178,7 +179,7 @@ func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...string) error {
data := map[string]interface{}{ data := map[string]interface{}{
"sameCount": h.SameCount, //叠加数 "sameCount": h.SameCount, //叠加数
} }
if err := this.modifyHeroData(uid, h.Id, data); err != nil { if err := this.ChangeList(uid, h.Id, data); err != nil {
return err return err
} }
} else { } else {
@ -232,19 +233,19 @@ func (this *ModelHero) consumeHeroCard(uid string, hero *pb.DBHero, count int32)
update := map[string]interface{}{ update := map[string]interface{}{
"sameCount": hero.SameCount, "sameCount": hero.SameCount,
} }
err = this.modifyHeroData(uid, hero.Id, update) err = this.ChangeList(uid, hero.Id, update)
} }
this.moduleHero.Debugf("删除一张卡牌uid:%s,卡牌ID:%s", uid, hero.Id) this.moduleHero.Debugf("删除一张卡牌uid:%s,卡牌ID:%s", uid, hero.Id)
return return
} }
//更新英雄数据 //更新英雄数据
func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interface{}) error { // func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interface{}) error {
if len(data) == 0 { // if len(data) == 0 {
return fmt.Errorf("params len is 0") // return fmt.Errorf("params len is 0")
} // }
return this.moduleHero.modelHero.ChangeList(uid, heroId, data) // return this.moduleHero.modelHero.ChangeList(uid, heroId, data)
} // }
//获取玩家的英雄列表 //获取玩家的英雄列表
func (this *ModelHero) getHeroList(uid string) []*pb.DBHero { func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
@ -258,7 +259,7 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
// 设置装备属性 // 设置装备属性
func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipment) { func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipment) {
property := make(map[string]int32) //主属性 //property := make(map[string]int32) //主属性
addProperty := make(map[string]int32) //副属性 addProperty := make(map[string]int32) //副属性
for i, v := range equip { for i, v := range equip {
if v == nil { if v == nil {
@ -266,15 +267,15 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
} }
hero.EquipID[i] = v.Id hero.EquipID[i] = v.Id
//主属性 //主属性
property[v.MainEntry.AttrName] = v.MainEntry.Value //property[v.MainEntry.AttrName] = v.MainEntry.Value
//附加属性 //附加属性
for _, v := range v.AdverbEntry { for _, v := range v.AdverbEntry {
addProperty[v.AttrName] = v.Value addProperty[v.AttrName] += v.Value
} }
} }
this.mergeMainProperty(hero.Uid, hero, property) //this.mergeMainProperty(hero.Uid, hero, property)
this.mergeAddProperty(hero.Uid, hero.Uid, addProperty) this.mergeAddProperty(hero.Uid, hero, addProperty)
} }
//设置装备 //设置装备
@ -296,7 +297,7 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
update["isoverlying"] = false update["isoverlying"] = false
update["sameCount"] = 1 update["sameCount"] = 1
if err = this.modifyHeroData(hero.Uid, hero.Id, update); err != nil { if err = this.ChangeList(hero.Uid, hero.Id, update); err != nil {
this.moduleHero.Errorf("%v", err) this.moduleHero.Errorf("%v", err)
return return
} }
@ -312,13 +313,13 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
update1["isoverlying"] = true update1["isoverlying"] = true
newHero.IsOverlying = true newHero.IsOverlying = true
newHero.SameCount = curSameCount newHero.SameCount = curSameCount
this.modifyHeroData(newHero.Uid, newHero.Id, update1) this.ChangeList(newHero.Uid, newHero.Id, update1)
} else { } else {
update["equipID"] = hero.EquipID update["equipID"] = hero.EquipID
update["isoverlying"] = false update["isoverlying"] = false
update["suiteId"] = hero.SuiteId update["suiteId"] = hero.SuiteId
update["suiteExtId"] = hero.SuiteExtId update["suiteExtId"] = hero.SuiteExtId
this.modifyHeroData(hero.Uid, hero.Id, update) this.ChangeList(hero.Uid, hero.Id, update)
} }
// 打印 // 打印
for _, v := range hero.EquipID { for _, v := range hero.EquipID {
@ -328,40 +329,28 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
} }
//合并属性即属性值累加 //合并属性即属性值累加
func (this *ModelHero) mergeMainProperty(uid string, hero *pb.DBHero, data map[string]int32) { func (this *ModelHero) mergeMainProperty(uid string, hero *pb.DBHero, data map[string]int32) (err error) {
if hero == nil { hero.Property = data
return if err = this.ChangeList(uid, hero.Id, map[string]interface{}{
} "property": data,
}); err != nil {
hero.Property[comm.Hp] += data[comm.Hp]
hero.Property[comm.Atk] += data[comm.Atk]
hero.Property[comm.Def] += data[comm.Def]
update := map[string]interface{}{
comm.Hp: hero.Property[comm.Hp],
comm.Atk: hero.Property[comm.Atk],
comm.Def: hero.Property[comm.Def],
}
if err := this.modifyHeroData(uid, hero.Id, update); err != nil {
this.moduleHero.Errorf("mergeMainProperty err %v", err) this.moduleHero.Errorf("mergeMainProperty err %v", err)
} }
return
} }
//合并附加属性 //合并附加属性
func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int32) { func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[string]int32) {
hero := this.getOneHero(uid, heroId) //hero := this.getOneHero(uid, heroId)
if hero == nil { if hero == nil {
return return
} }
hero.AddProperty[comm.HpPro] += data[comm.HpPro] hero.AddProperty = data
hero.AddProperty[comm.AtkPro] += data[comm.AtkPro]
hero.AddProperty[comm.DefPro] += data[comm.DefPro] if err := this.ChangeList(uid, hero.Id, map[string]interface{}{
update := map[string]interface{}{ "addProperty": data,
comm.HpPro: hero.AddProperty[comm.HpPro], }); err != nil {
comm.AtkPro: hero.AddProperty[comm.AtkPro],
comm.DefPro: hero.AddProperty[comm.DefPro],
}
if err := this.modifyHeroData(uid, heroId, update); err != nil {
this.moduleHero.Errorf("mergeAddProperty err %v", err) this.moduleHero.Errorf("mergeAddProperty err %v", err)
} }
} }

View File

@ -161,9 +161,9 @@ func (this *Hero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *p
//data := make(map[string]int32, 0) //data := make(map[string]int32, 0)
preConfig := this.configure.GetHeroLv(hero.Lv) preConfig := this.configure.GetHeroLv(hero.Lv)
nowConfig := this.configure.GetHeroLv(curLv) nowConfig := this.configure.GetHeroLv(curLv)
update["hp"] = int32(nowConfig.Hp - preConfig.Hp) update[comm.Hp] = int32(nowConfig.Hp - preConfig.Hp)
update["atk"] = int32(nowConfig.Atk - preConfig.Atk) update[comm.Atk] = int32(nowConfig.Atk - preConfig.Atk)
update["def"] = int32(nowConfig.Def - preConfig.Def) update[comm.Def] = int32(nowConfig.Def - preConfig.Def)
//this.modelHero.mergeMainProperty(uid, hero.Id, data) //this.modelHero.mergeMainProperty(uid, hero.Id, data)
} }
@ -177,7 +177,7 @@ func (this *Hero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *p
"sameCount": curCount, "sameCount": curCount,
} }
newhero.SameCount = curCount newhero.SameCount = curCount
if err := this.modelHero.modifyHeroData(uid, newhero.Id, update); err != nil { if err := this.modelHero.ChangeList(uid, newhero.Id, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }
} }
@ -192,7 +192,7 @@ func (this *Hero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *p
hero.IsOverlying = false hero.IsOverlying = false
hero.SameCount = 1 hero.SameCount = 1
if err := this.modelHero.modifyHeroData(uid, hero.Id, update); err != nil { if err := this.modelHero.ChangeList(uid, hero.Id, update); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }
} else { } else {

View File

@ -65,7 +65,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
return return
} }
if con.Route == 1 { if con.Route == 1 {
if con.Previoustage != curChapter.MainlineId { // 前置关卡校验 if curChapter.MainlineId == 0 { // 表示第一小关
} else if con.Previoustage != curChapter.MainlineId { // 前置关卡校验
// 分支关卡也校验一下 // 分支关卡也校验一下
for _, v := range curChapter.BranchID { for _, v := range curChapter.BranchID {
if v == con.Previoustage { if v == con.Previoustage {
@ -107,13 +109,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
if len(newChaptConfig.Episode) <= 0 { if len(newChaptConfig.Episode) <= 0 {
return return
} }
mainLineID := newChaptConfig.Episode[0] //mainLineID := newChaptConfig.Episode[0]
// 如果本章节打完 则创建新的章节 // 如果本章节打完 则创建新的章节
if chaptConfig.Episode[len(chaptConfig.Episode)-1] == int32(req.MainlineId) { if chaptConfig.Episode[len(chaptConfig.Episode)-1] == int32(req.MainlineId) {
_data := &pb.DBMainline{} _data := &pb.DBMainline{}
_data.Id = primitive.NewObjectID().Hex() _data.Id = primitive.NewObjectID().Hex()
_data.ChapterId = curChapter.ChapterId + 1 _data.ChapterId = curChapter.ChapterId + 1
_data.MainlineId = mainLineID _data.MainlineId = 0 // 第二章数据默认0
_mData := make(map[string]interface{}, 0) _mData := make(map[string]interface{}, 0)
_data.Uid = session.GetUserId() _data.Uid = session.GetUserId()
_mData[_data.Id] = _data _mData[_data.Id] = _data