Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into liwei
This commit is contained in:
commit
53076796e5
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
@ -62,7 +62,7 @@ func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (config
|
||||
return
|
||||
} else {
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
"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 {
|
||||
code = pb.ErrorCode_DBError
|
||||
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,
|
||||
}
|
||||
// 保存数据
|
||||
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap)
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
|
@ -33,6 +33,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
config5Count int32 // 配置表中5星保底次数
|
||||
race int32
|
||||
upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加
|
||||
cardW map[string]int32 // 当前卡牌对应的权重
|
||||
)
|
||||
upDraw = make([]*cfg.Game_drawUpdrawData, 0)
|
||||
szCards = make([]string, 0)
|
||||
@ -77,7 +78,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
code = pb.ErrorCode_DrawCardTypeNotFound // 抽卡类型不匹配
|
||||
return
|
||||
}
|
||||
|
||||
// 权重赋值
|
||||
for _, v := range _conf {
|
||||
cardW[v.Id] += v.Weight
|
||||
}
|
||||
_costConf, err := this.module.configure.GetDrawCostConfigByID(req.DrawType) // 抽卡消耗
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
@ -99,8 +103,20 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
}
|
||||
|
||||
drawTimes = _costConf.Count // 抽卡次数
|
||||
for _, v := range _conf {
|
||||
totalWeight += int64(v.Weight) // 统计所有权重
|
||||
for k, v := range cardW { // k是heroid v 权重
|
||||
|
||||
for _, v1 := range upDraw {
|
||||
for _, v2 := range v1.UpHero {
|
||||
if v2 == k {
|
||||
cardW[k] += v
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
// if !updraw {
|
||||
// totalWeight += int64(v.Weight) // 统计所有权重
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
drawTimes = 1
|
||||
|
@ -36,7 +36,7 @@ func (this *apiComp) Lock(session comm.IUserSession, req *pb.HeroLockReq) (code
|
||||
"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 {
|
||||
code = pb.ErrorCode_DBError
|
||||
log.Errorf("update hero skill failed:%v", err)
|
||||
|
@ -105,7 +105,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
"distributionResonate": _hero.DistributionResonate,
|
||||
"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 {
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -75,7 +75,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
|
||||
"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 {
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -43,7 +43,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR
|
||||
"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 {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
|
@ -36,7 +36,7 @@ func (this *apiComp) GetSpecified(session comm.IUserSession, req *pb.HeroGetSpec
|
||||
"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 {
|
||||
code = pb.ErrorCode_DBError
|
||||
log.Errorf("GetSpecified failed:%v", err)
|
||||
|
@ -118,7 +118,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
"normalSkill": _hero.NormalSkill,
|
||||
"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 {
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
code = pb.ErrorCode_DBError
|
||||
|
@ -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})
|
||||
// 保存数据
|
||||
err1 = this.module.modelHero.modifyHeroData(session.GetUserId(), _hero.Id, _heroMap)
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
|
@ -139,7 +139,8 @@ func (this *ModelHero) createHeroOverlying(uid string, heroCfgId string, count i
|
||||
data := map[string]interface{}{
|
||||
"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
|
||||
}
|
||||
}
|
||||
@ -178,7 +179,7 @@ func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...string) error {
|
||||
data := map[string]interface{}{
|
||||
"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
|
||||
}
|
||||
} else {
|
||||
@ -232,19 +233,19 @@ func (this *ModelHero) consumeHeroCard(uid string, hero *pb.DBHero, count int32)
|
||||
update := map[string]interface{}{
|
||||
"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)
|
||||
return
|
||||
}
|
||||
|
||||
//更新英雄数据
|
||||
func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interface{}) error {
|
||||
if len(data) == 0 {
|
||||
return fmt.Errorf("params len is 0")
|
||||
}
|
||||
return this.moduleHero.modelHero.ChangeList(uid, heroId, data)
|
||||
}
|
||||
// func (this *ModelHero) modifyHeroData(uid, heroId string, data map[string]interface{}) error {
|
||||
// if len(data) == 0 {
|
||||
// return fmt.Errorf("params len is 0")
|
||||
// }
|
||||
// return this.moduleHero.modelHero.ChangeList(uid, heroId, data)
|
||||
// }
|
||||
|
||||
//获取玩家的英雄列表
|
||||
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) {
|
||||
property := make(map[string]int32) //主属性
|
||||
//property := make(map[string]int32) //主属性
|
||||
addProperty := make(map[string]int32) //副属性
|
||||
for i, v := range equip {
|
||||
if v == nil {
|
||||
@ -266,15 +267,15 @@ func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipmen
|
||||
}
|
||||
hero.EquipID[i] = v.Id
|
||||
//主属性
|
||||
property[v.MainEntry.AttrName] = v.MainEntry.Value
|
||||
//property[v.MainEntry.AttrName] = v.MainEntry.Value
|
||||
//附加属性
|
||||
for _, v := range v.AdverbEntry {
|
||||
addProperty[v.AttrName] = v.Value
|
||||
addProperty[v.AttrName] += v.Value
|
||||
}
|
||||
}
|
||||
|
||||
this.mergeMainProperty(hero.Uid, hero, property)
|
||||
this.mergeAddProperty(hero.Uid, hero.Uid, addProperty)
|
||||
//this.mergeMainProperty(hero.Uid, hero, property)
|
||||
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["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)
|
||||
return
|
||||
}
|
||||
@ -312,13 +313,13 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
|
||||
update1["isoverlying"] = true
|
||||
newHero.IsOverlying = true
|
||||
newHero.SameCount = curSameCount
|
||||
this.modifyHeroData(newHero.Uid, newHero.Id, update1)
|
||||
this.ChangeList(newHero.Uid, newHero.Id, update1)
|
||||
} else {
|
||||
update["equipID"] = hero.EquipID
|
||||
update["isoverlying"] = false
|
||||
update["suiteId"] = hero.SuiteId
|
||||
update["suiteExtId"] = hero.SuiteExtId
|
||||
this.modifyHeroData(hero.Uid, hero.Id, update)
|
||||
this.ChangeList(hero.Uid, hero.Id, update)
|
||||
}
|
||||
// 打印
|
||||
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 {
|
||||
return
|
||||
}
|
||||
|
||||
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 {
|
||||
hero.Property = data
|
||||
if err = this.ChangeList(uid, hero.Id, map[string]interface{}{
|
||||
"property": data,
|
||||
}); err != nil {
|
||||
this.moduleHero.Errorf("mergeMainProperty err %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//合并附加属性
|
||||
func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int32) {
|
||||
hero := this.getOneHero(uid, heroId)
|
||||
func (this *ModelHero) mergeAddProperty(uid string, hero *pb.DBHero, data map[string]int32) {
|
||||
//hero := this.getOneHero(uid, heroId)
|
||||
if hero == nil {
|
||||
return
|
||||
}
|
||||
hero.AddProperty[comm.HpPro] += data[comm.HpPro]
|
||||
hero.AddProperty[comm.AtkPro] += data[comm.AtkPro]
|
||||
hero.AddProperty[comm.DefPro] += data[comm.DefPro]
|
||||
update := map[string]interface{}{
|
||||
comm.HpPro: hero.AddProperty[comm.HpPro],
|
||||
comm.AtkPro: hero.AddProperty[comm.AtkPro],
|
||||
comm.DefPro: hero.AddProperty[comm.DefPro],
|
||||
}
|
||||
if err := this.modifyHeroData(uid, heroId, update); err != nil {
|
||||
hero.AddProperty = data
|
||||
|
||||
if err := this.ChangeList(uid, hero.Id, map[string]interface{}{
|
||||
"addProperty": data,
|
||||
}); err != nil {
|
||||
this.moduleHero.Errorf("mergeAddProperty err %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ func (this *Hero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *p
|
||||
//data := make(map[string]int32, 0)
|
||||
preConfig := this.configure.GetHeroLv(hero.Lv)
|
||||
nowConfig := this.configure.GetHeroLv(curLv)
|
||||
update["hp"] = int32(nowConfig.Hp - preConfig.Hp)
|
||||
update["atk"] = int32(nowConfig.Atk - preConfig.Atk)
|
||||
update["def"] = int32(nowConfig.Def - preConfig.Def)
|
||||
update[comm.Hp] = int32(nowConfig.Hp - preConfig.Hp)
|
||||
update[comm.Atk] = int32(nowConfig.Atk - preConfig.Atk)
|
||||
update[comm.Def] = int32(nowConfig.Def - preConfig.Def)
|
||||
//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,
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ func (this *Hero) AddCardExp(uid string, hero *pb.DBHero, exp int32) (newhero *p
|
||||
hero.IsOverlying = false
|
||||
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
|
||||
}
|
||||
} else {
|
||||
|
@ -65,7 +65,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
return
|
||||
}
|
||||
if con.Route == 1 {
|
||||
if con.Previoustage != curChapter.MainlineId { // 前置关卡校验
|
||||
if curChapter.MainlineId == 0 { // 表示第一小关
|
||||
|
||||
} else if con.Previoustage != curChapter.MainlineId { // 前置关卡校验
|
||||
// 分支关卡也校验一下
|
||||
for _, v := range curChapter.BranchID {
|
||||
if v == con.Previoustage {
|
||||
@ -107,13 +109,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
if len(newChaptConfig.Episode) <= 0 {
|
||||
return
|
||||
}
|
||||
mainLineID := newChaptConfig.Episode[0]
|
||||
//mainLineID := newChaptConfig.Episode[0]
|
||||
// 如果本章节打完 则创建新的章节
|
||||
if chaptConfig.Episode[len(chaptConfig.Episode)-1] == int32(req.MainlineId) {
|
||||
_data := &pb.DBMainline{}
|
||||
_data.Id = primitive.NewObjectID().Hex()
|
||||
_data.ChapterId = curChapter.ChapterId + 1
|
||||
_data.MainlineId = mainLineID
|
||||
_data.MainlineId = 0 // 第二章数据默认0
|
||||
_mData := make(map[string]interface{}, 0)
|
||||
_data.Uid = session.GetUserId()
|
||||
_mData[_data.Id] = _data
|
||||
|
Loading…
Reference in New Issue
Block a user