feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
95 lines
1.9 KiB
Go
95 lines
1.9 KiB
Go
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, ev uint32, natureCorrect float64) uint32 {
|
||
|
||
base1 := float64((float64(base)*2+float64(ev)/4.0+float64(c.Dv))*(float64(c.Level)/100.0) + 5)
|
||
return uint32(float64(base1) * natureCorrect)
|
||
}
|
||
|
||
// 计算生成面板,只允许第一次生成超过100,比如boss,不允许额外超过
|
||
func (p *PetInfo) CalculatePetPane(frist bool) {
|
||
if !frist {
|
||
|
||
if p.Level > 100 {
|
||
|
||
oldlveel := p.Level
|
||
p.Level = 100
|
||
defer func() {
|
||
p.Level = oldlveel
|
||
}()
|
||
}
|
||
|
||
}
|
||
naxml := xmlres.NatureRootMap[int(p.Nature)]
|
||
petxml := xmlres.PetMAP[int(p.ID)]
|
||
// 计算各项属性
|
||
p.MaxHp = p.calculatePetHPPanelSize(
|
||
uint32(petxml.HP),
|
||
p.Dv,
|
||
p.Level,
|
||
p.Ev[0],
|
||
)
|
||
p.Hp = p.MaxHp
|
||
// * 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.Ev[1],
|
||
naxml.AttackCorrect,
|
||
)
|
||
|
||
p.Prop[1] = p.calculatePetPanelSize(
|
||
uint32(petxml.Def),
|
||
|
||
p.Ev[2],
|
||
naxml.DefenseCorrect,
|
||
)
|
||
|
||
p.Prop[2] = p.calculatePetPanelSize(
|
||
uint32(petxml.SpAtk),
|
||
|
||
p.Ev[3],
|
||
naxml.SaCorrect,
|
||
)
|
||
|
||
p.Prop[3] = p.calculatePetPanelSize(
|
||
uint32(petxml.SpDef),
|
||
|
||
p.Ev[4],
|
||
naxml.SdCorrect,
|
||
)
|
||
|
||
p.Prop[4] = p.calculatePetPanelSize(
|
||
uint32(petxml.Spd),
|
||
|
||
p.Ev[5],
|
||
naxml.SpeedCorrect,
|
||
)
|
||
|
||
}
|