diff --git a/bin/json/game_heroskill.json b/bin/json/game_heroskill.json
new file mode 100644
index 000000000..cc001e791
--- /dev/null
+++ b/bin/json/game_heroskill.json
@@ -0,0 +1,62 @@
+[
+ {
+ "star": 1,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ },
+ {
+ "star": 2,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ },
+ {
+ "star": 3,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ },
+ {
+ "star": 4,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ },
+ {
+ "star": 5,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ },
+ {
+ "star": 6,
+ "needgold": [
+ {
+ "a": "attr",
+ "t": "glod",
+ "n": 10000
+ }
+ ]
+ }
+]
\ No newline at end of file
diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go
index d9834ebe6..1b6bc19d9 100644
--- a/modules/hero/api_awaken.go
+++ b/modules/hero/api_awaken.go
@@ -125,12 +125,9 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
- resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, cfg.Star)
- if resonConfig != nil && resonConfig.Maxnum == _hero.ResonateNum {
- if _hero.Lv == _hero.Star*comm.HeroStarLvRatio {
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
- }
+ if _hero.Lv == _hero.Star*comm.HeroStarLvRatio {
+ this.module.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
+ this.module.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
}
}
}
diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go
deleted file mode 100644
index dbcd45254..000000000
--- a/modules/hero/api_resonance.go
+++ /dev/null
@@ -1,180 +0,0 @@
-package hero
-
-import (
- "go_dreamfactory/comm"
- "go_dreamfactory/pb"
- cfg "go_dreamfactory/sys/configure/structs"
- "go_dreamfactory/utils"
-
- "google.golang.org/protobuf/proto"
-)
-
-//参数校验
-func (this *apiComp) ResonanceCheck(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode) {
- if req.HeroObjID == "" || len(req.CostObjID) == 0 {
- code = pb.ErrorCode_ReqParameterError
- return
- }
-
- return
-}
-
-/// 英雄共鸣
-func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceReq) (code pb.ErrorCode, data proto.Message) {
- var (
- szCostHero map[string]int32 // k 卡牌配置id v 数量
- _hero *pb.DBHero
- ChangeList []*pb.DBHero // 变化的英雄数据
- _costMaphero map[string]*pb.DBHero
- count int32 // 共鸣升级次数
- )
- ChangeList = make([]*pb.DBHero, 0)
- szCostHero = make(map[string]int32, 0)
- _costMaphero = make(map[string]*pb.DBHero, 0)
- code = this.ResonanceCheck(session, req) // check
- if code != pb.ErrorCode_Success {
- return
- }
-
- _hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
- if code != pb.ErrorCode_Success {
- return
- }
- //获取原始星级
- conf := this.module.configure.GetHeroConfig(_hero.HeroID)
- if conf == nil {
- code = pb.ErrorCode_ConfigNoFound
- return
- }
- // 共鸣次数判断
- resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, conf.Star)
- if resonConfig == nil {
- code = pb.ErrorCode_ConfigNoFound
- return
- }
-
- for _, k := range req.CostObjID {
- _costHero, c := this.module.GetHeroByObjID(session.GetUserId(), k) // 查询消耗卡是否存在
- if c != pb.ErrorCode_Success {
- code = c // 英雄被锁不能消耗
- return
- }
- if _costHero.Block {
- code = pb.ErrorCode_HeroIsLock
- }
- _costMaphero[k] = _costHero
- szCostHero[_costHero.HeroID] += 1
- }
- // 一次升级多级
- for _, v := range resonConfig.Heroneed {
- for k, v1 := range szCostHero {
- if k == v.T {
- if v1%v.N == 0 {
- if count == 0 {
- count = v1 / v.N
- }
- if count != v1/v.N {
- code = pb.ErrorCode_ReqParameterError
- return
- }
- } else {
- code = pb.ErrorCode_ReqParameterError
- return
- }
- }
- }
- }
- if count == 0 {
- code = pb.ErrorCode_ReqParameterError
- return
- }
- if resonConfig.Maxnum < _hero.ResonateNum+count {
- code = pb.ErrorCode_HeroMaxResonate // 共鸣次数已满
- return
- }
- for k, v := range _costMaphero {
- code = this.module.DelCard(session.GetUserId(), v, szCostHero[v.HeroID])
- if code != pb.ErrorCode_Success {
- return
- }
- ChangeList = append(ChangeList, _costMaphero[k])
- }
- sz := make([]*cfg.Gameatn, 0) // 计算升级多次的消耗
- for _, v := range resonConfig.Need {
- sz = append(sz, &cfg.Gameatn{
- A: v.A,
- T: v.T,
- N: v.N * count,
- })
- }
- code = this.module.ConsumeRes(session, sz, true)
- if code != pb.ErrorCode_Success {
- return
- }
-
- for k := range _costMaphero {
- if k == _hero.Id {
- _hero.SameCount = _costMaphero[k].SameCount
- break
- }
- }
- if _hero.SameCount == 0 {
- code = pb.ErrorCode_ReqParameterError
- return
- }
- if _hero.SameCount > 1 {
- _hero.SameCount -= 1
- newHero := this.module.modelHero.CloneNewHero(session.GetUserId(), _hero)
- ChangeList = append(ChangeList, newHero)
- }
- _hero.SameCount = 1
- _hero.ResonateNum += count
- _hero.DistributionResonate += resonConfig.Energy * count
- _hero.IsOverlying = false
- _heroMap := map[string]interface{}{
- "resonateNum": _hero.ResonateNum,
- "distributionResonate": _hero.DistributionResonate,
- "isOverlying": false,
- "sameCount": 1,
- "horoscopeProperty": _hero.HoroscopeProperty,
- }
- err := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
- if err != nil {
- this.module.Errorf("update hero skill failed:%v", err)
- code = pb.ErrorCode_DBError
- return
- }
- // 返还对应初始星级的卡
- ChangeList = append(ChangeList, _hero)
- session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList})
- this.module.DispenseRes(session, resonConfig.Prize, true)
- session.SendMsg(string(this.module.GetType()), Resonance, &pb.HeroResonanceResp{Hero: _hero})
-
- //英雄共鸣 【玩家名称】已将【英雄名称】共鸣至满级!
- if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil {
- this.chat.SendSysChatToWorld(comm.ChatSystem10, nil, _hero.ResonateNum, 0, user.Name, _hero.HeroID)
- } else {
- this.module.Errorf("no found userdata uid:%s", session.GetUserId())
- }
- // 任务相关
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1)
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype127, _hero.Star, utils.ToInt32(_hero.HeroID), _hero.ResonateNum) //A星英雄共鸣N级
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype40, 1, 1)
- cfg := this.module.configure.GetHeroConfig(_hero.HeroID)
- if cfg != nil {
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype126, cfg.Race, _hero.ResonateNum)
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.ResonateNum)
- //xx英雄满级、共鸣、觉醒至最高状态
- nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
- if nextAwaken == nil { // 达到满级觉醒
- resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, cfg.Star)
- if resonConfig != nil && resonConfig.Maxnum == _hero.ResonateNum { // 共鸣满
- if _hero.Lv == _hero.Star*comm.HeroStarLvRatio {
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
- this.module.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
- }
- }
- }
- }
- return
-}
diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go
deleted file mode 100644
index 078b752e9..000000000
--- a/modules/hero/api_resonanceReset.go
+++ /dev/null
@@ -1,87 +0,0 @@
-package hero
-
-import (
- "go_dreamfactory/comm"
- "go_dreamfactory/pb"
-
- "google.golang.org/protobuf/proto"
-)
-
-//参数校验
-func (this *apiComp) ResonanceResetCheck(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode) {
- if req.HeroObjID == "" {
- code = pb.ErrorCode_ReqParameterError
- return
- }
-
- return
-}
-
-/// 英雄共鸣
-func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroResonanceResetReq) (code pb.ErrorCode, data proto.Message) {
- var (
- _hero *pb.DBHero
- )
- code = this.ResonanceResetCheck(session, req) // check
- if code != pb.ErrorCode_Success {
- return
- }
-
- _hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
- if code != pb.ErrorCode_Success {
- code = pb.ErrorCode_HeroNoExist
- return
- }
-
- if _hero.ResonateNum <= 0 { // 没有共鸣 不允许重置
- code = pb.ErrorCode_HeroNoResonate
- return
- }
-
- // 共鸣次数判断
- //获取原始星级
- conf := this.module.configure.GetHeroConfig(_hero.HeroID)
- if conf == nil {
- code = pb.ErrorCode_ConfigNoFound
- return
- }
- resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, conf.Star)
- if resonConfig == nil {
- code = pb.ErrorCode_ConfigNoFound
- return
- }
-
- if _hero.ResonateNum*resonConfig.Energy == _hero.DistributionResonate {
- code = pb.ErrorCode_HeroNotNeedResonate // 已经是重置状态
- return
- }
-
- _costConfig, err1 := this.module.configure.GetHeroResonanceRestConfig()
- if err1 != nil {
- code = pb.ErrorCode_ConfigNoFound // 没找到配置消耗
- return
- }
- // 消耗校验
- code = this.module.ConsumeRes(session, _costConfig.Var, true)
- if code != pb.ErrorCode_Success {
- return
- }
- _hero.EnergyProperty = make(map[string]int32, 0)
- _hero.Energy = make(map[string]int32)
- _hero.DistributionResonate = _hero.ResonateNum * resonConfig.Energy
- _heroMap := map[string]interface{}{
- "distributionResonate": _hero.DistributionResonate,
- "energy": _hero.Energy,
- "isOverlying": false,
- "energyProperty": _hero.EnergyProperty,
- }
-
- 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
- return
- }
- session.SendMsg(string(this.module.GetType()), ResonanceReset, &pb.HeroResonanceResetResp{Hero: _hero, Energy: _hero.ResonateNum})
- return
-}
diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go
deleted file mode 100644
index 9e483e905..000000000
--- a/modules/hero/api_resonanceSelect.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package hero
-
-import (
- "go_dreamfactory/comm"
- "go_dreamfactory/pb"
-
- "google.golang.org/protobuf/proto"
-)
-
-//参数校验
-func (this *apiComp) ResonanceUseEnergyCheck(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode) {
- if len(req.HeroObjID) == 0 || len(req.Energy) == 0 {
- code = pb.ErrorCode_ReqParameterError
- return
- }
-
- return
-}
-
-func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroResonanceUseEnergyReq) (code pb.ErrorCode, data proto.Message) {
- var (
- _hero *pb.DBHero
- totalEnergy int32
- )
- code = this.ResonanceUseEnergyCheck(session, req) // check
- if code != pb.ErrorCode_Success {
- return
- }
-
- _hero, code = this.module.GetHeroByObjID(session.GetUserId(), req.HeroObjID) // 查询目标卡是否存在
- if code != pb.ErrorCode_Success {
- return
- }
- for _, v := range req.Energy {
- totalEnergy += v.UseEnergy
- }
-
- if _hero.DistributionResonate < totalEnergy { // 能量点数不够
- code = pb.ErrorCode_HeroNoEnergy
- return
- }
- for _, v := range req.Energy {
- if v.UseEnergy > 0 {
- _hero.Energy[v.UseType] += v.UseEnergy
- }
- }
- _hero.DistributionResonate -= totalEnergy
- _heroMap := map[string]interface{}{
- "distributionResonate": _hero.DistributionResonate, // 减没有分配的能量
- "energy": _hero.Energy,
- "isOverlying": false,
- }
-
- 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)
- return
- }
- conf := this.module.configure.GetHeroConfig(_hero.HeroID)
- // 计算属性
- this.module.modelHero.setEnergyProperty(_hero, conf.Star)
- session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero})
- return
-}
diff --git a/modules/hero/api_strengthenUpSkill.go b/modules/hero/api_strengthenUpSkill.go
index fbcaf9180..bf58b673c 100644
--- a/modules/hero/api_strengthenUpSkill.go
+++ b/modules/hero/api_strengthenUpSkill.go
@@ -3,6 +3,7 @@ package hero
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
+ cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto"
@@ -21,9 +22,10 @@ func (this *apiComp) StrengthenUpSkillCheck(session comm.IUserSession, req *pb.H
/// 英雄技能升级
func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroStrengthenUpSkillReq) (code pb.ErrorCode, data proto.Message) {
var (
- upSkillPos int32 // 升级的技能位置
- _hero *pb.DBHero // 操作的英雄
- costGold int64 // 金币消耗
+ upSkillPos int32 // 升级的技能位置
+ _hero *pb.DBHero // 操作的英雄
+ cost []*cfg.Gameatn // 技能升级消耗
+ lvUpCount int32 // 技能升级的次数
)
code = this.StrengthenUpSkillCheck(session, req) // check
@@ -40,53 +42,36 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
code = pb.ErrorCode_HeroNoExist
return
}
+ for _, v1 := range req.Item {
+ bFind := false
+ for _, v := range heroCfg.Heroskillup {
+ if v == v1 {
+ bFind = true
+ lvUpCount++ // 升级次数
+ break
+ }
+ }
+ if !bFind {
+ code = pb.ErrorCode_ReqParameterError
+ return
+ }
+ cost = append(cost, &cfg.Gameatn{
+ A: "item",
+ T: v1,
+ N: 1,
+ })
+ }
+ // 消耗获取
+ for i := 0; i < int(lvUpCount); i++ {
+ if atn := this.module.configure.GetHeroSkillCost(heroCfg.Star); len(atn) > 0 {
+ cost = append(cost, atn...)
+ }
+ }
- for _, v := range heroCfg.Heroskillup {
- if v.T ==
- }
- for _, v := range req.CostCardObj { // 数组转 map
- mapCostHero[v]++
- }
- for k, v := range mapCostHero {
- costHero, c := this.module.GetHeroByObjID(session.GetUserId(), k) // 查询消耗卡是否存在
- if c != pb.ErrorCode_Success {
- code = c
- return
- }
- if costHero.Block { // 锁定的卡不允许被消耗
- code = pb.ErrorCode_HeroIsLock
- return
- }
- if costHero.SameCount < v { // 数量校验
- code = pb.ErrorCode_HeroNoEnough
- return
- }
- tmp := this.module.configure.GetHeroConfig(costHero.HeroID) // 星级校验
- if tmp.Color != heroCfg.Color {
- code = pb.ErrorCode_HeroColorErr
- return
- }
- if tmp.Type != comm.CardTypeSkill { // 查看是不是升级卡
- code = pb.ErrorCode_HeroTypeErr
- return
- }
- expConf := this.module.configure.GetHeroExp(costHero.HeroID) // 消耗多少金币
- if expConf != nil {
- costGold += int64(expConf.Needgold * v)
- lvUpCount += expConf.Skilllevelup * v
- } else {
- lvUpCount += v // 计算技能升级次数
- }
-
- mapCostObj[k] = costHero
- }
- // 检查金币消耗
- curGold := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), comm.ResGold)
- if curGold < costGold { // 金币不足
- code = pb.ErrorCode_GoldNoEnough
+ // 检查消耗
+ if code = this.module.CheckRes(session, cost); code != pb.ErrorCode_Success {
return
}
-
for i := 0; i < int(lvUpCount); i++ { // 升级技能
szIndex := make([]int32, 0)
sz := make([]int32, 0)
@@ -111,19 +96,14 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
_hero.NormalSkill[szIndex[upSkillPos]].SkillLv += 1
}
- code = this.module.ModuleUser.AddAttributeValue(session, comm.ResGold, -int32(costGold), true)
- if code != pb.ErrorCode_Success { // 金币不足
- code = pb.ErrorCode_GoldNoEnough
+ if code = this.module.ConsumeRes(session, cost, true); code != pb.ErrorCode_Success {
return
}
_heroMap := map[string]interface{}{
"normalSkill": _hero.NormalSkill,
- "isOverlying": false,
- "sameCount": 1,
"horoscopeProperty": _hero.HoroscopeProperty,
}
- _hero.SameCount = 1
err1 := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
if err1 != nil {
this.module.Errorf("update hero skill failed:%v", err1)
diff --git a/modules/hero/api_strengthenUpStar.go b/modules/hero/api_strengthenUpStar.go
index 4329ffd9d..09530340b 100644
--- a/modules/hero/api_strengthenUpStar.go
+++ b/modules/hero/api_strengthenUpStar.go
@@ -11,7 +11,7 @@ import (
//参数校验
func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode) {
- if req.HeroObjID == "" || len(req.HeroRace) == 0 {
+ if req.HeroObjID == "" {
code = pb.ErrorCode_ReqParameterError
}
@@ -21,25 +21,9 @@ func (this *apiComp) StrengthenUpStarCheck(session comm.IUserSession, req *pb.He
/// 英雄升星
func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStrengthenUpStarReq) (code pb.ErrorCode, data proto.Message) {
var (
- starConf *cfg.GameHeroStarupData // 配置表目标升星英雄信息
- costNeedHeroCount int32 // 消耗指定英雄的数量
- costRaceHeroCount int32 // 消耗种族英雄的数量
- _hero *pb.DBHero // 目标英雄
- tagHero *pb.DBHero // 消耗指定英雄
- mapCostHero map[string]int32 // 所有消耗英雄分类
- chanegCard []*pb.DBHero // 变化的英雄数据
- CostHeroObj map[string]*pb.DBHero // 所有消耗英雄分类
+ starConf *cfg.GameHeroStarupData // 配置表目标升星英雄信息
+ _hero *pb.DBHero // 目标英雄
)
- mapCostHero = make(map[string]int32, 0)
- CostHeroObj = make(map[string]*pb.DBHero, 0)
- for _, v := range req.Hero {
- mapCostHero[v.CostCardObj] += v.Amount
- costNeedHeroCount += v.Amount
- }
- for _, v := range req.HeroRace {
- mapCostHero[v.CostCardObj] += v.Amount
- costRaceHeroCount += v.Amount
- }
code = this.StrengthenUpStarCheck(session, req) // check
if code != pb.ErrorCode_Success {
@@ -63,111 +47,34 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
return
}
- // 优先校验数量对不对
- if starConf.Needheronum != costNeedHeroCount || starConf.Needracenum != costRaceHeroCount {
- code = pb.ErrorCode_ReqParameterError
- return
- }
- costNeedHeroCount = 0
- costRaceHeroCount = 0
- // 遍历所有消耗英雄
- for k, v := range mapCostHero {
- if tagHero, code = this.module.GetHeroByObjID(session.GetUserId(), k); code != pb.ErrorCode_Success { // 没有这个英雄
- return
- } else {
- if tagHero.Block { // 锁定的卡不允许被消耗
- code = pb.ErrorCode_HeroIsLock
- return
- }
- if tagHero.SameCount < v { // 校验数量
- code = pb.ErrorCode_ReqParameterError
- return
- }
-
- if tagHero.HeroID == starConf.Needhero && tagHero.Star == starConf.Needherostar && tagHero.SameCount >= starConf.Needheronum {
- costNeedHeroCount += v
- }
-
- for _, value := range starConf.Needrace { // 阵营校验
- // 获取配置表英雄阵营
- cfg := this.module.configure.GetHeroConfig(tagHero.HeroID)
- if cfg != nil {
- if cfg.Race == value {
- costRaceHeroCount += v
- }
- }
- }
- }
- CostHeroObj[k] = tagHero
- }
-
- if starConf.Needheronum > costNeedHeroCount || starConf.Needracenum > costRaceHeroCount {
- code = pb.ErrorCode_ReqParameterError
+ if code = this.module.ConsumeRes(session, starConf.Needrace, true); code != pb.ErrorCode_Success {
return
}
- // 金币消耗判断
- curGold := this.module.ModuleUser.QueryAttributeValue(session.GetUserId(), comm.ResGold)
- if curGold < int64(starConf.Gold) { // 金币不足
- code = pb.ErrorCode_GoldNoEnough
- return
- }
-
- // 消耗道具
- code = this.module.ModuleUser.AddAttributeValue(session, comm.ResGold, -starConf.Gold, true) // 减少金币
- if code != pb.ErrorCode_Success {
- this.module.Errorf("cost gold failed ,count = %d", starConf.Gold)
- code = pb.ErrorCode_GoldNoEnough
- return
- }
- for k, v := range mapCostHero {
- code = this.module.DelCard(session.GetUserId(), CostHeroObj[k], v)
- if code != pb.ErrorCode_Success {
- this.module.Errorf("del hero err card:%s,count = %d", k, v)
- this.module.ModuleUser.AddAttributeValue(session, comm.ResGold, starConf.Gold, true) // 回退金币
- return
- }
- chanegCard = append(chanegCard, CostHeroObj[k])
- }
// 加对应的天赋点数
if len(starConf.Starup) > 0 {
if code = this.module.DispenseRes(session, starConf.Starup, true); code != pb.ErrorCode_Success { // 加天赋点{
this.module.Errorf("DispenseRes err:uid:%s,res:%v", session.GetUserId(), starConf.Starup)
}
}
- if _hero.SameCount > 1 { //有堆叠的情况
- // 克隆一个新的
- _hero.SameCount -= 1
- newHero := this.module.modelHero.CloneNewHero(session.GetUserId(), _hero)
- chanegCard = append(chanegCard, newHero)
- }
_hero.Star += 1
- _hero.SameCount = 1
+ this.module.modelHero.PropertyCompute(_hero) // 重新计算属性
_heroMap := map[string]interface{}{
"star": _hero.Star,
- "sameCount": 1,
- "isOverlying": false,
+ "talentProperty": _hero.TalentProperty,
+ "juexProperty": _hero.JuexProperty,
"horoscopeProperty": _hero.HoroscopeProperty,
}
- if heroConf != nil && heroConf.Type == comm.CardTypeStar { // 升星卡升星 修改heroid
- hid := this.module.configure.GetHeroSpriteStar(_hero.HeroID)
- if hid != "" {
- _hero.HeroID = hid
- _heroMap["heroID"] = _hero.HeroID
- }
- }
// 保存数据
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
if err != nil {
code = pb.ErrorCode_DBError
- this.module.Errorf("update hero skill failed:%v", err)
+ this.module.Errorf("update hero star failed:%v", err)
}
this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性
- chanegCard = append(chanegCard, _hero)
- session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: chanegCard})
session.SendMsg(string(this.module.GetType()), StrengthenUpStar, &pb.HeroStrengthenUpStarResp{Hero: _hero})
//英雄升星 【玩家名称】已将【英雄名称】培养至6星!
diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go
index ce90b35cc..1e1bfd404 100644
--- a/modules/hero/configure_comp.go
+++ b/modules/hero/configure_comp.go
@@ -12,27 +12,28 @@ import (
)
const (
- equip_suit = "game_equipsuit.json" //装备套装表
- new_hero = "game_hero.json" //英雄
- hero_stargrow = "game_herostargrow.json" //英雄品质系数
- hero_levelgrow = "game_herolevelgrow.json" //英雄成长系数
- hero_starup = "game_herostarup.json" // 升星
- hero_levelup = "game_herolevelup.json" //英雄等级基础属性
- hero_exp = "game_heroexp.json" // 升级
- hero_skillup = "game_heroskilllevel.json" // 英雄技能升级
- game_skillatk = "game_skillatk.json" // 英雄技能
- hero_resonance = "game_heroresonance.json" // 英雄共鸣
- hero_comatn = "game_comatn.json" // 英雄共鸣重置
- hero_awaken = "game_heroawaken.json" // 英雄觉醒
- hero_drawcard = "game_drawcard.json" // 抽卡
- hero_drawupdraw = "game_drawupdraw.json" // 抽卡概率调整
- hero_drawcost = "game_drawcost.json" // 抽卡消耗
- hero_fusion = "game_herofusion.json" // 卡牌融合
- hero_starupsp = "game_herostarupsp.json" // 精灵升星
- hero_talentskill = "game_talentskill.json" // 天赋
- hero_talent = "game_herotalent.json" // 天赋详细数据
- hero_itembox = "game_itembox.json" // 天赋详细数据
+ equip_suit = "game_equipsuit.json" //装备套装表
+ new_hero = "game_hero.json" //英雄
+ hero_stargrow = "game_herostargrow.json" //英雄品质系数
+ hero_levelgrow = "game_herolevelgrow.json" //英雄成长系数
+ hero_starup = "game_herostarup.json" // 升星
+ hero_levelup = "game_herolevelup.json" //英雄等级基础属性
+ hero_exp = "game_heroexp.json" // 升级
+ hero_skillup = "game_heroskilllevel.json" // 英雄技能升级
+ game_skillatk = "game_skillatk.json" // 英雄技能
+ //hero_resonance = "game_heroresonance.json" // 英雄共鸣
+ //hero_comatn = "game_comatn.json" // 英雄共鸣重置
+ hero_awaken = "game_heroawaken.json" // 英雄觉醒
+ hero_drawcard = "game_drawcard.json" // 抽卡
+ hero_drawupdraw = "game_drawupdraw.json" // 抽卡概率调整
+ hero_drawcost = "game_drawcost.json" // 抽卡消耗
+ hero_fusion = "game_herofusion.json" // 卡牌融合
+ hero_starupsp = "game_herostarupsp.json" // 精灵升星
+ hero_talentskill = "game_talentskill.json" // 天赋
+ hero_talent = "game_herotalent.json" // 天赋详细数据
+ hero_itembox = "game_itembox.json" // 天赋详细数据
game_shopitem = "game_shopitem.json"
+ hero_skill = "game_heroskill.json"
)
///配置管理组件
@@ -40,10 +41,10 @@ type configureComp struct {
modules.MCompConfigure
drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级
//map["base_pool1"]map[3]*cfg.Game_drawCardData
- awakenMap map[int64]*cfg.GameHeroAwakenData
- resonanceMap map[int64]*cfg.GameHeroResonanceData
- starMap map[int64]*cfg.GameHeroStarupData
- module *Hero
+ awakenMap map[int64]*cfg.GameHeroAwakenData
+
+ starMap map[int64]*cfg.GameHeroStarupData
+ module *Hero
}
//组件初始化接口
@@ -52,15 +53,15 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Hero)
err = this.LoadMultiConfigure(map[string]interface{}{
- equip_suit: cfg.NewGameEquipSuit,
- new_hero: cfg.NewGameHero,
- hero_stargrow: cfg.NewGameHeroStargrow,
- hero_levelgrow: cfg.NewGameHeroLevelgrow,
- hero_levelup: cfg.NewGameHeroLevelup,
- hero_exp: cfg.NewGameHeroExp,
- hero_skillup: cfg.NewGameHeroSkillLevel,
- game_skillatk: cfg.NewGameSkillAtk,
- hero_comatn: cfg.NewGameComAtn,
+ equip_suit: cfg.NewGameEquipSuit,
+ new_hero: cfg.NewGameHero,
+ hero_stargrow: cfg.NewGameHeroStargrow,
+ hero_levelgrow: cfg.NewGameHeroLevelgrow,
+ hero_levelup: cfg.NewGameHeroLevelup,
+ hero_exp: cfg.NewGameHeroExp,
+ hero_skillup: cfg.NewGameHeroSkillLevel,
+ game_skillatk: cfg.NewGameSkillAtk,
+ //hero_comatn: cfg.NewGameComAtn,
hero_drawcard: cfg.NewGameDrawCard,
hero_fusion: cfg.NewGameHerofusion,
hero_starupsp: cfg.NewGameHeroStarupSp,
@@ -68,6 +69,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
hero_talent: cfg.NewGameHeroTalent,
hero_itembox: cfg.NewGameItemBox,
game_shopitem: cfg.NewGameShopitem,
+ hero_skill: cfg.NewGameHeroSkill,
})
this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0)
configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, this.SetHeroDrawConfig)
@@ -85,21 +87,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
}
})
- // 共鸣
- this.resonanceMap = make(map[int64]*cfg.GameHeroResonanceData, 0)
- configure.RegisterConfigure(hero_resonance, cfg.NewGameHeroResonance, func() {
- if v, err := this.GetConfigure(hero_resonance); err == nil {
- if _configure, ok := v.(*cfg.GameHeroResonance); ok {
- for _, v := range _configure.GetDataList() {
- this.resonanceMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Star)] = v
- }
- return
- }
- } else {
- err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
- }
- })
// 升星
this.starMap = make(map[int64]*cfg.GameHeroStarupData, 0)
configure.RegisterConfigure(hero_starup, cfg.NewGameHeroStarup, func() {
@@ -135,11 +123,6 @@ func (this *configureComp) GetHeroMaxStar(hid string, curStar int32) int32 {
return star
}
-// 通过英雄配置ID获取共鸣配置信息
-func (this *configureComp) GetHeroResonanceConfig(hid string, star int32) *cfg.GameHeroResonanceData {
- return this.resonanceMap[int64(utils.ToInt32(hid)<<8)+int64(star)]
-}
-
func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData {
return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)]
}
@@ -387,20 +370,6 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
return 0
}
-func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnData, err error) {
- var (
- v interface{}
- )
- if v, err = this.GetConfigure(hero_comatn); err == nil {
- if configure, ok := v.(*cfg.GameComAtn); ok {
- data = configure.Get("hero_reset")
- return
- }
- }
- this.module.Errorf("cfg.GameComAtnData GetHeroResonanceRestConfig:id = hero_reset")
- return
-}
-
// 获取卡牌合成配置
func (this *configureComp) GetHeroFucionConfig(cid string) (data *cfg.GameHerofusionData) {
@@ -527,3 +496,15 @@ func (this *configureComp) GetEquipsuit(id int32) (configure *cfg.GameEquipSuitD
}
return
}
+
+func (this *configureComp) GetHeroSkillCost(star int32) (cost []*cfg.Gameatn) {
+
+ if v, err := this.GetConfigure(hero_skill); err == nil {
+ if configure, ok := v.(*cfg.GameHeroSkill); ok {
+ return configure.Get(star).Needgold
+ }
+ } else {
+ err = fmt.Errorf("%T no is *cfg.GameHeroExp", v)
+ }
+ return
+}
diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go
index 0cac89ee2..daa54e1b6 100644
--- a/modules/hero/model_hero.go
+++ b/modules/hero/model_hero.go
@@ -318,30 +318,6 @@ func (this *ModelHero) setJuexingProperty(hero *pb.DBHero, key string, value int
}
}
-// 设置共鸣能量点数属性
-func (this *ModelHero) setEnergyProperty(hero *pb.DBHero, star int32) {
-
- resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, star)
- if resonConfig == nil {
- return
- }
- EnergyProperty := make(map[string]int32) //副属性
- for k, v := range hero.Energy {
- if k == comm.ResonanceHpPro {
- EnergyProperty[comm.Hp] += int32(math.Floor(float64(resonConfig.Hppro*v) / 1000 * float64(hero.Property[comm.Hp])))
- } else if k == comm.ResonanceAtkPro {
- EnergyProperty[comm.Atk] += int32(math.Floor(float64(resonConfig.Atkpro*v) / 1000 * float64(hero.Property[comm.Atk])))
- } else if k == comm.ResonanceDefPro {
- EnergyProperty[comm.Def] += int32(math.Floor(float64(resonConfig.Defpro*v) / 1000 * float64(hero.Property[comm.Def])))
- }
- }
- _heroMap := make(map[string]interface{}, 0)
- _heroMap["enegryProperty"] = EnergyProperty
- if err := this.ChangeList(hero.Uid, hero.Id, _heroMap); err != nil {
- this.moduleHero.Errorf("mergeenegryProperty err %v", err)
- }
-}
-
// 设置装备属性
func (this *ModelHero) setEquipProperty(hero *pb.DBHero, equip []*pb.DB_Equipment) {
@@ -655,12 +631,9 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex
//xx英雄满级、共鸣、觉醒至最高状态
nextAwaken := this.moduleHero.configure.GetHeroAwakenConfig(hero.HeroID, hero.JuexingLv+1)
if nextAwaken == nil { // 达到满级觉醒
- resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, cfg.Star)
- if resonConfig != nil && resonConfig.Maxnum == hero.ResonateNum { // 共鸣满
- if hero.Lv == hero.Star*comm.HeroStarLvRatio {
- this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
- this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
- }
+ if hero.Lv == hero.Star*comm.HeroStarLvRatio {
+ this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype37, 1, cfg.Color)
+ this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype38, 1)
}
}
}
diff --git a/sys/configure/structs/Game.HeroSkill.go b/sys/configure/structs/Game.HeroSkill.go
new file mode 100644
index 000000000..471c45431
--- /dev/null
+++ b/sys/configure/structs/Game.HeroSkill.go
@@ -0,0 +1,42 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+package cfg
+
+type GameHeroSkill struct {
+ _dataMap map[int32]*GameHeroSkillData
+ _dataList []*GameHeroSkillData
+}
+
+func NewGameHeroSkill(_buf []map[string]interface{}) (*GameHeroSkill, error) {
+ _dataList := make([]*GameHeroSkillData, 0, len(_buf))
+ dataMap := make(map[int32]*GameHeroSkillData)
+ for _, _ele_ := range _buf {
+ if _v, err2 := DeserializeGameHeroSkillData(_ele_); err2 != nil {
+ return nil, err2
+ } else {
+ _dataList = append(_dataList, _v)
+ dataMap[_v.Star] = _v
+ }
+ }
+ return &GameHeroSkill{_dataList:_dataList, _dataMap:dataMap}, nil
+}
+
+func (table *GameHeroSkill) GetDataMap() map[int32]*GameHeroSkillData {
+ return table._dataMap
+}
+
+func (table *GameHeroSkill) GetDataList() []*GameHeroSkillData {
+ return table._dataList
+}
+
+func (table *GameHeroSkill) Get(key int32) *GameHeroSkillData {
+ return table._dataMap[key]
+}
+
+
diff --git a/sys/configure/structs/game.comAtnData.go b/sys/configure/structs/Game.HeroSkillData.go
similarity index 54%
rename from sys/configure/structs/game.comAtnData.go
rename to sys/configure/structs/Game.HeroSkillData.go
index d5e7f2084..9682d2c8a 100644
--- a/sys/configure/structs/game.comAtnData.go
+++ b/sys/configure/structs/Game.HeroSkillData.go
@@ -10,38 +10,38 @@ package cfg
import "errors"
-type GameComAtnData struct {
- Index string
- Var []*Gameatn
+type GameHeroSkillData struct {
+ Star int32
+ Needgold []*Gameatn
}
-const TypeId_GameComAtnData = -2026469472
+const TypeId_GameHeroSkillData = 1863510469
-func (*GameComAtnData) GetTypeId() int32 {
- return -2026469472
+func (*GameHeroSkillData) GetTypeId() int32 {
+ return 1863510469
}
-func (_v *GameComAtnData)Deserialize(_buf map[string]interface{}) (err error) {
- { var _ok_ bool; if _v.Index, _ok_ = _buf["index"].(string); !_ok_ { err = errors.New("index error"); return } }
+func (_v *GameHeroSkillData)Deserialize(_buf map[string]interface{}) (err error) {
+ { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
- if _arr_, _ok_ = _buf["var"].([]interface{}); !_ok_ { err = errors.New("var error"); return }
+ if _arr_, _ok_ = _buf["needgold"].([]interface{}); !_ok_ { err = errors.New("needgold error"); return }
- _v.Var = make([]*Gameatn, 0, len(_arr_))
+ _v.Needgold = 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.Var = append(_v.Var, _list_v_)
+ _v.Needgold = append(_v.Needgold, _list_v_)
}
}
return
}
-func DeserializeGameComAtnData(_buf map[string]interface{}) (*GameComAtnData, error) {
- v := &GameComAtnData{}
+func DeserializeGameHeroSkillData(_buf map[string]interface{}) (*GameHeroSkillData, error) {
+ v := &GameHeroSkillData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go
index 121842864..08f904c55 100644
--- a/sys/configure/structs/Tables.go
+++ b/sys/configure/structs/Tables.go
@@ -21,6 +21,7 @@ type Tables struct {
HeroStargrow *GameHeroStargrow
HeroLevelgrow *GameHeroLevelgrow
HeroStarup *GameHeroStarup
+ HeroSkill *GameHeroSkill
HeroExp *GameHeroExp
HeroLevelup *GameHeroLevelup
Equip *GameEquip
@@ -225,6 +226,12 @@ func NewTables(loader JsonLoader) (*Tables, error) {
if tables.HeroStarup, err = NewGameHeroStarup(buf) ; err != nil {
return nil, err
}
+ if buf, err = loader("game_heroskill") ; err != nil {
+ return nil, err
+ }
+ if tables.HeroSkill, err = NewGameHeroSkill(buf) ; err != nil {
+ return nil, err
+ }
if buf, err = loader("game_heroexp") ; err != nil {
return nil, err
}
diff --git a/sys/configure/structs/game.comAtn.go b/sys/configure/structs/game.comAtn.go
deleted file mode 100644
index 7317c611f..000000000
--- a/sys/configure/structs/game.comAtn.go
+++ /dev/null
@@ -1,42 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-package cfg
-
-type GameComAtn struct {
- _dataMap map[string]*GameComAtnData
- _dataList []*GameComAtnData
-}
-
-func NewGameComAtn(_buf []map[string]interface{}) (*GameComAtn, error) {
- _dataList := make([]*GameComAtnData, 0, len(_buf))
- dataMap := make(map[string]*GameComAtnData)
- for _, _ele_ := range _buf {
- if _v, err2 := DeserializeGameComAtnData(_ele_); err2 != nil {
- return nil, err2
- } else {
- _dataList = append(_dataList, _v)
- dataMap[_v.Index] = _v
- }
- }
- return &GameComAtn{_dataList:_dataList, _dataMap:dataMap}, nil
-}
-
-func (table *GameComAtn) GetDataMap() map[string]*GameComAtnData {
- return table._dataMap
-}
-
-func (table *GameComAtn) GetDataList() []*GameComAtnData {
- return table._dataList
-}
-
-func (table *GameComAtn) Get(key string) *GameComAtnData {
- return table._dataMap[key]
-}
-
-