Files
bl/modules/blazing/model/petinfo.go
昔念 038bd0ce0c ```text
build(go): 升级 gf/v2 框架至 v2.7.0

统一将 common、login 和 mysql driver 中的 github.com/gogf/gf/v2 依赖版本从 v2.6.3 更新到 v2.7.0。

feat(logic): 优化道具服务逻辑与数据结构

- 修改 Item 结构体,去除 Data 字段,新增 ItemId 和 ItemCnt 字段以提高可读性和查询效率。
- 调整 Item 相关方法实现,包括 Item(), AddItem(), SubItem() 和 CheakItem() 方法,支持直接按范围获取及增减物品
2025-11-02 18:56:16 +08:00

87 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import "blazing/common/data/xmlres"
// 实现获取等级范围内可学习的技能
func (p *PetInfo) GetLevelRangeCanLearningSkills(from, to uint32) []uint32 {
var skills []uint32
for _, skillIDs := range xmlres.PetMAP[int(p.ID)].LearnableMoves.Moves {
if skillIDs.LearningLv >= from && skillIDs.LearningLv <= to {
skills = append(skills, skillIDs.ID)
}
}
return skills
}
// 计算HP面板值无性格修正
func (c *PetInfo) calculatePetHPPanelSize(base, dv, level, ev uint32) uint32 {
return uint32((float64(base)*2+float64(ev)/4.0+float64(dv))*(float64(level)/100.0) + float64(level) + 10)
}
// 计算其他属性面板值(带性格修正)
func (c *PetInfo) calculatePetPanelSize(base, dv, level, ev uint32, natureCorrect float64) uint32 {
base1 := float64((float64(base)*2+float64(ev)/4.0+float64(dv))*(float64(level)/100.0) + 5)
return uint32(float64(base1) * natureCorrect)
}
// 计算生成面板
func (p *PetInfo) CalculatePetPane() {
naxml := xmlres.NatureRootMap[int(p.Nature)]
petxml := xmlres.PetMAP[int(p.ID)]
// 计算各项属性
hp := p.calculatePetHPPanelSize(
uint32(petxml.HP),
p.Dv,
p.Level,
p.Ev[0],
)
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
p.Prop[0] = p.calculatePetPanelSize(
uint32(petxml.Atk),
p.Dv,
p.Level,
p.Ev[1],
naxml.AttackCorrect,
)
p.Prop[1] = p.calculatePetPanelSize(
uint32(petxml.Def),
p.Dv,
p.Level,
p.Ev[2],
naxml.DefenseCorrect,
)
p.Prop[2] = p.calculatePetPanelSize(
uint32(petxml.SpAtk),
p.Dv,
p.Level,
p.Ev[3],
naxml.SaCorrect,
)
p.Prop[3] = p.calculatePetPanelSize(
uint32(petxml.SpDef),
p.Dv,
p.Level,
p.Ev[4],
naxml.SdCorrect,
)
p.Prop[4] = p.calculatePetPanelSize(
uint32(petxml.Spd),
p.Dv,
p.Level,
p.Ev[5],
naxml.SpeedCorrect,
)
// 设置计算结果
p.MaxHp = hp
}