| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- package hero
- import (
- "f1-game/internal/constant"
- "f1-game/internal/data"
- "f1-game/internal/enum"
- "f1-game/internal/extend/math"
- "f1-game/internal/types"
- "f1-game/nodes/game/internal/db"
- dbHero "f1-game/nodes/game/internal/db/data/hero"
- clog "github.com/cherry-game/cherry/logger"
- )
- type attrsFunc func(playerID int64, heroEntity *dbHero.Hero, attrs *types.Attrs)
- var attrsFuncList = []attrsFunc{
- heroAttrs,
- equipAttrs,
- skillAttrs,
- }
- // 英雄
- func heroAttrs(playerID int64, hero *dbHero.Hero, attrs *types.Attrs) {
- heroRow, found := data.Hero.GetByID(hero.HeroID)
- if !found {
- return
- }
- // 英雄初始(基础值)
- attrs.Add(enum.Attr_HP, heroRow.InitHealth)
- attrs.Add(enum.Attr_MaxHP, heroRow.InitHealth)
- attrs.Add(enum.Attr_MinAttack, heroRow.InitAttack)
- attrs.Add(enum.Attr_MaxAttack, heroRow.InitAttack)
- attrs.Add(enum.Attr_MinDefense, heroRow.InitDefense)
- attrs.Add(enum.Attr_MaxDefense, heroRow.InitDefense)
- attrs.Add(enum.Attr_AttackSpeed, heroRow.InitAttackSpeed)
- attrs.Add(enum.Attr_Speed, heroRow.InitSpeed)
- // TODO 初始攻击距离没加
- playerTable, _ := db.GetPlayerTable(playerID)
- // 等级成长 策划填的是万分比
- if playerTable.Lord.Level > 1 {
- frac := int64(playerTable.Lord.Level - 1)
- // 成长增加生命值
- growHPAdd := heroRow.HealthGrow * frac / constant.RatioBase
- attrs.Add(enum.Attr_HP, growHPAdd)
- attrs.Add(enum.Attr_MaxHP, growHPAdd)
- // 成长增加攻击力
- growAddAttack := heroRow.AttackGrow * frac / constant.RatioBase
- attrs.Add(enum.Attr_MinAttack, growAddAttack)
- attrs.Add(enum.Attr_MaxAttack, growAddAttack)
- // 成长增加防御力
- growAddDefense := heroRow.DefenseGrow * frac / constant.RatioBase
- attrs.Add(enum.Attr_MinDefense, growAddDefense)
- attrs.Add(enum.Attr_MaxDefense, growAddDefense)
- }
- // 星级成长
- if hero.Star > 0 {
- heroStarAttrRow, ok := data.HeroStarAttrs.GetByHeroIDStar(hero.HeroID, hero.Star)
- if ok {
- attrs.Add(enum.Attr_HP, heroStarAttrRow.Health)
- attrs.Add(enum.Attr_MaxHP, heroStarAttrRow.Health)
- attrs.Add(enum.Attr_MinAttack, heroStarAttrRow.Attack)
- attrs.Add(enum.Attr_MaxAttack, heroStarAttrRow.Attack)
- attrs.Add(enum.Attr_MinDefense, heroStarAttrRow.Defense)
- attrs.Add(enum.Attr_MaxDefense, heroStarAttrRow.Defense)
- } else {
- clog.Warnf("[HeroStarAttrs] config not exists: heroID=%d, star=%d", hero.HeroID, hero.Star)
- }
- }
- }
- // 装备增加属性
- func equipAttrs(playerID int64, hero *dbHero.Hero, attrs *types.Attrs) {
- if hero.EquipGUIDList.Size() <= 0 {
- return
- }
- equipTable := db.GetEquipTable(playerID)
- for _, equipGUID := range hero.EquipGUIDList {
- equip, found := equipTable.Equips.Get(equipGUID)
- if !found {
- clog.Warnf("[playerID=%d] HeroEquipAttrs equip not exists: equipGUID=%d", playerID, equipGUID)
- continue
- }
- if equip.WearHeroGUID != hero.GUID {
- continue
- }
- // 添加基础属性
- for attrID, attr := range equip.BaseAttrs {
- attrs.Add(attrID, attr)
- }
- // 添加装备附加属性值
- for _, attr := range equip.ExtraAttrs {
- attrs.Add(attr.Key, attr.Value)
- }
- // 添加装备等级属性
- equipRow, found := data.Equip.GetByID(equip.EquipID)
- if !found {
- clog.Warnf("[playerID=%d] HeroEquipAttrs equip config not exists: equipID=%d", playerID, equip.EquipID)
- continue
- }
- equipLevelRow, found := data.EquipLevel.GetByQualityLevel(equipRow.Quality, equip.Level)
- if !found {
- clog.Warnf("[playerID=%d] HeroEquipAttrs equip level config not exists: equipID=%d, level=%d", playerID, equip.EquipID, equip.Level)
- continue
- }
- // 装备强化等级增加基础属性
- for attrID, attr := range equip.BaseAttrs {
- addAttrValue := math.Round[float64, int64](float64(attr*equipLevelRow.BaseAttrAddPer) / constant.RatioBase)
- attrs.Add(attrID, addAttrValue)
- }
- // TODO 确定装备专属技能是否会增加额外的属性
- }
- }
- // TODO 技能 当前英雄技能没有增加属性
- func skillAttrs(_ int64, hero *dbHero.Hero, attrs *types.Attrs) {
- }
- // 阵型羁绊加成
- func lineupFetterAttrs(playerID int64, hero *dbHero.Hero, attrs *types.Attrs, lineupID int32) {
- var (
- teamTable = db.GetLineupTable(playerID)
- )
- lineups, found := teamTable.LineupMap.GetLineups(constant.Adventure_Type)
- if !found {
- return
- }
- lineup, found := lineups.GetLineup(lineupID)
- if !found {
- return
- }
- fetterIDs := lineup.FetterIDs
- if fetterIDs.Size() < 1 {
- return
- }
- for fetterID := range fetterIDs {
- fetterRow, found := data.HeroFetter.GetByID(fetterID)
- if !found {
- clog.Warnf("[lineupFetterAttrs] fetter not found, heroID:%d, fetterID: %d", hero.HeroID, fetterID)
- continue
- }
- // 当前羁绊不存在该英雄,则跳过
- if !fetterRow.HeroIDs.Contains(hero.HeroID) {
- continue
- }
- curAttrs := fetterRow.GetAttrs()
- for attrId, attrValue := range curAttrs {
- attrs.Add(attrId, attrValue)
- }
- }
- }
|