feat: 实现每日签到功能并优化战斗和道具逻辑
This commit is contained in:
@@ -24,6 +24,26 @@ import (
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
func consumeLimitedPetEffects(pet *model.PetInfo) {
|
||||
if pet == nil || len(pet.EffectInfo) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
next := pet.EffectInfo[:0]
|
||||
for _, eff := range pet.EffectInfo {
|
||||
if eff.Status == 2 {
|
||||
if eff.LeftCount > 0 {
|
||||
eff.LeftCount--
|
||||
}
|
||||
if eff.LeftCount == 0 {
|
||||
continue
|
||||
}
|
||||
}
|
||||
next = append(next, eff)
|
||||
}
|
||||
pet.EffectInfo = next
|
||||
}
|
||||
|
||||
func (f *FightC) battleLoop() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||
@@ -69,26 +89,28 @@ func (f *FightC) battleLoop() {
|
||||
tt.Alive(false) //将所有属性变化失效掉
|
||||
return true
|
||||
})
|
||||
if f.Info.Mode != info.BattleMode.PET_MELEE { //不是乱斗,传回血量
|
||||
for i := 0; i < len(ff.AllPet); i++ {
|
||||
for j := 0; j < len(ff.Player.GetInfo().PetList); j++ {
|
||||
if ff.Player.GetInfo().PetList[j].CatchTime == ff.AllPet[i].Info.CatchTime {
|
||||
|
||||
if ff.UserID == f.WinnerId {
|
||||
currentPet := ff.CurrentPet()
|
||||
if currentPet != nil && currentPet.Info.CatchTime == ff.Player.GetInfo().PetList[j].CatchTime {
|
||||
f.Winpet = &ff.Player.GetInfo().PetList[j]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ff.Player.GetInfo().PetList[j].Hp = utils.Min(ff.Player.GetInfo().PetList[j].MaxHp, ff.AllPet[i].Info.Hp)
|
||||
ff.Player.GetInfo().PetList[j].SkillList = ff.AllPet[i].Info.SkillList
|
||||
}
|
||||
|
||||
for i := 0; i < len(ff.AllPet); i++ {
|
||||
consumeLimitedPetEffects(&ff.AllPet[i].Info)
|
||||
for j := 0; j < len(ff.Player.GetInfo().PetList); j++ {
|
||||
if ff.Player.GetInfo().PetList[j].CatchTime != ff.AllPet[i].Info.CatchTime {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
ff.Player.GetInfo().PetList[j].EffectInfo = ff.AllPet[i].Info.EffectInfo
|
||||
if f.Info.Mode == info.BattleMode.PET_MELEE {
|
||||
continue
|
||||
}
|
||||
|
||||
if ff.UserID == f.WinnerId {
|
||||
currentPet := ff.CurrentPet()
|
||||
if currentPet != nil && currentPet.Info.CatchTime == ff.Player.GetInfo().PetList[j].CatchTime {
|
||||
f.Winpet = &ff.Player.GetInfo().PetList[j]
|
||||
}
|
||||
}
|
||||
|
||||
ff.Player.GetInfo().PetList[j].Hp = utils.Min(ff.Player.GetInfo().PetList[j].MaxHp, ff.AllPet[i].Info.Hp)
|
||||
ff.Player.GetInfo().PetList[j].SkillList = ff.AllPet[i].Info.SkillList
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user