refactor(fight): 重构战斗模块
- 移除未使用的结构体和接口 - 优化战斗准备和邀请逻辑 - 调整玩家和怪物信息的处理方式 - 更新战斗相关的数据结构 - 重构战斗模式和邀请相关代码
This commit is contained in:
@@ -22,6 +22,16 @@ type Pet struct {
|
||||
Data string `gorm:"type:text;not null;comment:'精灵全部数据'" json:"data"`
|
||||
}
|
||||
|
||||
func LastFourElements[T any](s []T) []T {
|
||||
n := len(s)
|
||||
if n <= 4 {
|
||||
// 切片长度小于等于4时,返回整个切片
|
||||
return s
|
||||
}
|
||||
// 切片长度大于4时,返回最后4个元素(从n-4索引到末尾)
|
||||
return s[n-4:]
|
||||
}
|
||||
|
||||
// * @param petTypeId 精灵类型ID
|
||||
// * @param individualValue 个体值
|
||||
// * @param natureId 性格ID
|
||||
@@ -29,19 +39,19 @@ type Pet struct {
|
||||
// * @param isShiny 是否为闪光
|
||||
// * @param level 等级
|
||||
// * @return 生成的精灵实体
|
||||
func GenPetInfo(id, individual, natureId, abilityTypeEnum, shinyid, level uint32) *PetInfo {
|
||||
func GenPetInfo(id, dv, natureId, abilityTypeEnum, shinyid, level uint32) *PetInfo {
|
||||
|
||||
p := &PetInfo{ID: id,
|
||||
Shiny: shinyid, //闪光
|
||||
Nature: natureId, //性格
|
||||
Dv: individual,
|
||||
Dv: dv,
|
||||
EffectInfo: make([]PetEffectInfo, 0),
|
||||
CatchTime: uint32(time.Now().Unix()),
|
||||
Level: level} //等级
|
||||
|
||||
p.EffectInfo = append(p.EffectInfo, PetEffectInfo{ItemID: abilityTypeEnum})
|
||||
petxml := xmlres.PetMAP[int(id)]
|
||||
naxml := xmlres.NatureRootMap[int(natureId)]
|
||||
petxml := xmlres.PetMAP[int(id)]
|
||||
tttt := make([]uint32, 0)
|
||||
for _, v := range petxml.LearnableMoves.Moves {
|
||||
if p.Level >= uint32(v.LearningLv) {
|
||||
@@ -50,6 +60,7 @@ func GenPetInfo(id, individual, natureId, abilityTypeEnum, shinyid, level uint32
|
||||
}
|
||||
|
||||
}
|
||||
tttt = LastFourElements(tttt) //获取最后四个技能,如果不足,那就取全部技能
|
||||
for i := 0; i < len(tttt); i++ {
|
||||
p.SkillList[i].ID = tttt[i]
|
||||
p.SkillList[i].Pp = uint32(xmlres.SkillMap[int(tttt[i])].MaxPP)
|
||||
|
||||
Reference in New Issue
Block a user