2025-09-14 01:35:16 +08:00
|
|
|
|
package fight
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
|
|
|
|
|
import (
|
2025-10-27 01:11:31 +08:00
|
|
|
|
"blazing/common/utils"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
|
"blazing/logic/service/fight/action"
|
2025-09-04 02:00:57 +08:00
|
|
|
|
"blazing/logic/service/fight/info"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
"blazing/logic/service/fight/input"
|
2025-11-26 18:39:23 +08:00
|
|
|
|
"blazing/logic/service/player"
|
2025-10-27 01:11:31 +08:00
|
|
|
|
"blazing/modules/blazing/model"
|
2025-09-04 03:14:43 +08:00
|
|
|
|
"fmt"
|
2025-10-10 00:40:32 +08:00
|
|
|
|
"reflect"
|
2025-09-04 02:00:57 +08:00
|
|
|
|
|
2025-09-26 21:15:58 +00:00
|
|
|
|
"github.com/barkimedes/go-deepcopy"
|
2025-09-26 13:33:55 +08:00
|
|
|
|
"github.com/shopspring/decimal"
|
2025-09-04 02:00:57 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-09-08 02:51:21 +00:00
|
|
|
|
// 处理技能攻击逻辑
|
2025-11-10 02:29:00 +08:00
|
|
|
|
func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.SkillEntity) {
|
2025-11-11 06:23:59 +00:00
|
|
|
|
//oldpet := f.copypet(attacker.CurrentPet)
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2025-11-30 10:21:57 +00:00
|
|
|
|
a.AttackTimeC(attacker.GetProp(5, true)) //计算命中
|
|
|
|
|
|
|
2025-11-12 21:44:56 +08:00
|
|
|
|
defender.Exec(func(t input.Effect) bool { //计算闪避 ,然后修改对方命中),同时相当于计算属性无效这种
|
2025-11-11 05:54:24 +00:00
|
|
|
|
|
|
|
|
|
|
t.Ctx().SkillEntity = a
|
|
|
|
|
|
t.Skill_Hit_ex()
|
2025-09-14 16:56:31 +08:00
|
|
|
|
|
2025-09-24 18:53:54 +00:00
|
|
|
|
return true
|
2025-09-12 00:27:49 +08:00
|
|
|
|
})
|
2025-09-14 03:36:26 +08:00
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
var oldprop [2][6]int8
|
|
|
|
|
|
oldprop[0], oldprop[1] = attacker.Prop, defender.Prop //先复制能力提升
|
2025-11-12 21:44:56 +08:00
|
|
|
|
attacker.Exec(func(t input.Effect) bool {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
//计算变威力
|
|
|
|
|
|
t.Ctx().SkillEntity = a
|
|
|
|
|
|
t.Skill_Hit() //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
|
2025-09-26 21:15:58 +00:00
|
|
|
|
|
2025-10-05 00:29:22 +08:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
//技能命中+效果失效 这里就是修改效果命中为false
|
|
|
|
|
|
//技能miss+效果生效 这里属于强制改命中效果,但是正常来说,技能miss掉后效果也应该失效
|
|
|
|
|
|
//技能失效+效果失效
|
2025-10-22 00:25:38 +08:00
|
|
|
|
// 记录技能信息
|
2025-11-30 10:21:57 +00:00
|
|
|
|
//如果miss或者失效
|
|
|
|
|
|
|
|
|
|
|
|
attacker.AttackTime = a.AttackTime
|
2025-11-14 23:09:16 +08:00
|
|
|
|
attacker.SkillID = uint32(a.ID) //获取技能ID
|
2025-11-30 10:21:57 +00:00
|
|
|
|
if a.AttackTime != 0 { //如果命中
|
2025-11-11 01:10:26 +08:00
|
|
|
|
|
|
|
|
|
|
attacker.CalculateCrit(defender, a) //暴击计算
|
2025-11-12 01:19:24 +08:00
|
|
|
|
attacker.IsCritical = a.Crit
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-21 05:47:51 +00:00
|
|
|
|
attacker.SumDamage = attacker.CalculatePower(defender, a)
|
2025-11-03 04:16:30 +08:00
|
|
|
|
//睡眠受击消除
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
}
|
2025-11-30 10:21:57 +00:00
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
attacker.Prop, defender.Prop = oldprop[0], oldprop[1] //先复制能力提升
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
if attacker.IsCritical == 1 { //命中了才有暴击
|
|
|
|
|
|
//暴击破防
|
|
|
|
|
|
if a.Category() == info.Category.PHYSICAL && defender.Prop[1] > 0 {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
defender.Prop[1] = 0
|
|
|
|
|
|
} else if a.Category() == info.Category.SPECIAL && defender.Prop[3] > 0 {
|
|
|
|
|
|
defender.Prop[3] = 0
|
2025-09-26 02:09:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
|
//暴击翻倍
|
2025-11-21 05:47:51 +00:00
|
|
|
|
attacker.SumDamage = attacker.SumDamage.Mul(decimal.NewFromInt(2))
|
2025-11-20 05:57:29 +08:00
|
|
|
|
|
2025-10-05 00:29:22 +08:00
|
|
|
|
}
|
2025-11-30 10:21:57 +00:00
|
|
|
|
|
|
|
|
|
|
if !a.Side { //|| attacker.AttackTime == 0 {
|
|
|
|
|
|
|
|
|
|
|
|
//这时候将被覆盖的效果全部装回来enterturn
|
|
|
|
|
|
for _, e := range attacker.Effect_Lost {
|
|
|
|
|
|
if e.Duration() > 0 || e.Duration() == -1 {
|
|
|
|
|
|
e.Alive(true)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// attacker.AddEffects(attacker.EffectCache...) //命中再添加效果
|
|
|
|
|
|
for _, e := range attacker.EffectCache {
|
|
|
|
|
|
//这里实现应该参考本地技能是否命中,然后
|
|
|
|
|
|
e.Hit(true) //我方效果命中
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-05 00:29:22 +08:00
|
|
|
|
}
|
2025-09-08 01:23:12 +08:00
|
|
|
|
|
2025-10-05 00:29:22 +08:00
|
|
|
|
// 扣减防御方血量
|
2025-09-26 21:15:58 +00:00
|
|
|
|
attacker.Exec(func(t input.Effect) bool {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().SkillEntity = a
|
2025-09-26 21:15:58 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.OnSkill() //调用伤害计算
|
2025-09-26 21:15:58 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-11-12 13:44:21 +00:00
|
|
|
|
defender.Damage(attacker, &info.DamageZone{
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-11-21 05:47:51 +00:00
|
|
|
|
Damage: attacker.SumDamage,
|
2025-11-11 05:54:24 +00:00
|
|
|
|
},
|
|
|
|
|
|
)
|
2025-09-28 08:13:42 +00:00
|
|
|
|
//这里其实是受到致死伤害
|
|
|
|
|
|
//然后先触发死亡效果,消除所有buff
|
|
|
|
|
|
//然后触发回神效果
|
2025-09-08 02:51:21 +00:00
|
|
|
|
}
|
2025-10-10 00:40:32 +08:00
|
|
|
|
func IsNil(x interface{}) bool {
|
|
|
|
|
|
if x == nil {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
rv := reflect.ValueOf(x)
|
|
|
|
|
|
return rv.Kind() == reflect.Ptr && rv.IsNil()
|
|
|
|
|
|
}
|
2025-11-10 03:23:32 +08:00
|
|
|
|
func (f *FightC) copyskill(t *action.SelectSkillAction) *info.SkillEntity {
|
2025-11-10 01:53:28 +00:00
|
|
|
|
if t == nil {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
2025-11-10 03:23:32 +08:00
|
|
|
|
if t.SkillEntity == nil {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-26 20:56:03 +08:00
|
|
|
|
|
2025-11-10 03:23:32 +08:00
|
|
|
|
oldskill, _ := deepcopy.Anything(t.SkillEntity) //备份技能
|
|
|
|
|
|
oldskill.(*info.SkillEntity).Rand = f.rand //拷贝后随机数丢失
|
2025-11-10 02:29:00 +08:00
|
|
|
|
return oldskill.(*info.SkillEntity)
|
2025-10-26 20:56:03 +08:00
|
|
|
|
}
|
2025-09-10 22:59:10 +08:00
|
|
|
|
|
2025-09-14 04:48:38 +08:00
|
|
|
|
//回合有先手方和后手方,同时有攻击方和被攻击方
|
|
|
|
|
|
|
2025-09-30 18:32:15 +08:00
|
|
|
|
func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
2025-11-13 21:36:18 +08:00
|
|
|
|
//双方首发精灵登场时,依挑战方机制:房主方先判定,挑战方后判定
|
|
|
|
|
|
//双方非首发精灵登场时,根据切换先后判定(看手速)
|
|
|
|
|
|
// 神罗、圣华登场时魂免,“登场时xx”等效果
|
|
|
|
|
|
//阿枫的效果也在这里判断
|
2025-09-14 03:36:26 +08:00
|
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
ff.Exec(func(t input.Effect) bool { //回合开始前
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
|
//结算状态
|
|
|
|
|
|
t.Turn_Start(fattack, sattack)
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-11-13 21:36:18 +08:00
|
|
|
|
})
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-11-14 06:14:49 +08:00
|
|
|
|
if fattack != nil { //如果首技能是空的,说明都空过了
|
|
|
|
|
|
|
|
|
|
|
|
if fattack.GetPlayerID() == f.ownerID {
|
|
|
|
|
|
//是否miss都应该施加解析effect
|
|
|
|
|
|
f.Our.Parseskill(fattack) //解析到临时数据
|
|
|
|
|
|
|
|
|
|
|
|
f.Opp.Parseskill(sattack) //解析到临时数据
|
|
|
|
|
|
} else {
|
|
|
|
|
|
f.Opp.Parseskill(fattack)
|
|
|
|
|
|
f.Our.Parseskill(sattack)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-16 20:30:17 +00:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
ff.Exec(func(t input.Effect) bool { //回合开始前
|
2025-11-14 06:14:49 +08:00
|
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
|
//结算状态
|
|
|
|
|
|
t.Compare_Pre(fattack, sattack) //先结算技能的优先级
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-11-14 06:14:49 +08:00
|
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
|
ff.ResetAttackValue()
|
2025-11-14 06:14:49 +08:00
|
|
|
|
})
|
2025-11-16 20:30:17 +00:00
|
|
|
|
f.First, f.Second = f.Our, f.Opp
|
2025-09-30 18:32:15 +08:00
|
|
|
|
// 根据攻击方归属设置当前战斗的主/次攻击方属性
|
2025-10-29 15:50:48 +00:00
|
|
|
|
if fattack != nil {
|
2025-11-16 20:30:17 +00:00
|
|
|
|
if fattack.GetPlayerID() != f.ownerID {
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-10-29 15:50:48 +00:00
|
|
|
|
f.First, f.Second = f.Opp, f.Our // 攻击方为对方时,主攻击方是对方
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-10-29 15:50:48 +00:00
|
|
|
|
}
|
2025-09-30 18:32:15 +08:00
|
|
|
|
}
|
2025-10-29 15:50:48 +00:00
|
|
|
|
|
2025-11-08 00:47:45 +08:00
|
|
|
|
if fattack != nil && sattack != nil {
|
|
|
|
|
|
switch {
|
2025-10-10 00:44:45 +08:00
|
|
|
|
|
2025-11-08 00:47:45 +08:00
|
|
|
|
case fattack.SkillEntity.Priority < sattack.SkillEntity.Priority:
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-11-08 00:47:45 +08:00
|
|
|
|
fattack, sattack = sattack, fattack //互换先手权
|
|
|
|
|
|
f.First, f.Second = f.Second, f.First
|
|
|
|
|
|
case fattack.SkillEntity.Priority == sattack.SkillEntity.Priority:
|
2025-10-10 00:40:32 +08:00
|
|
|
|
|
2025-11-08 00:47:45 +08:00
|
|
|
|
if f.Second.GetProp(4, false) > f.First.GetProp(4, false) {
|
2025-10-10 00:40:32 +08:00
|
|
|
|
fattack, sattack = sattack, fattack //互换先手权
|
|
|
|
|
|
f.First, f.Second = f.Second, f.First
|
|
|
|
|
|
}
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-30 10:40:36 +00:00
|
|
|
|
var attacker, defender *input.Input
|
2025-10-15 14:24:46 +00:00
|
|
|
|
|
2025-09-14 03:36:26 +08:00
|
|
|
|
//开始回合操作
|
2025-09-10 01:35:08 +08:00
|
|
|
|
for i := 0; i < 2; i++ {
|
2025-11-10 02:29:00 +08:00
|
|
|
|
var oldskill *info.SkillEntity //原始技能
|
|
|
|
|
|
var currentskill *info.SkillEntity //当前技能
|
|
|
|
|
|
if i == 0 { //
|
2025-09-30 10:40:36 +00:00
|
|
|
|
attacker, defender = f.First, f.Second
|
2025-11-10 03:23:32 +08:00
|
|
|
|
oldskill = f.copyskill(fattack)
|
2025-09-30 10:40:36 +00:00
|
|
|
|
|
|
|
|
|
|
} else {
|
2025-09-10 01:35:08 +08:00
|
|
|
|
attacker, defender = f.Second, f.First
|
2025-11-10 03:23:32 +08:00
|
|
|
|
oldskill = f.copyskill(sattack)
|
2025-11-10 02:29:00 +08:00
|
|
|
|
|
2025-09-10 01:35:08 +08:00
|
|
|
|
}
|
2025-09-14 04:48:38 +08:00
|
|
|
|
|
2025-11-10 02:29:00 +08:00
|
|
|
|
currentskill = oldskill
|
2025-11-16 20:30:17 +00:00
|
|
|
|
defender.Exec(func(t input.Effect) bool { //这个是能否使用技能
|
|
|
|
|
|
//结算状态
|
|
|
|
|
|
//然后这里还可以处理自爆类
|
|
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
2025-11-22 00:44:42 +08:00
|
|
|
|
return t.Action_start_ex(fattack, sattack) //返回本身结算,如果false,说明不能使用技能了
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2025-11-16 20:30:17 +00:00
|
|
|
|
})
|
2025-11-12 21:44:56 +08:00
|
|
|
|
canuseskill := attacker.Exec(func(t input.Effect) bool { //这个是能否使用技能
|
2025-11-08 23:20:48 +08:00
|
|
|
|
//结算状态
|
|
|
|
|
|
//然后这里还可以处理自爆类
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
2025-11-22 00:44:42 +08:00
|
|
|
|
return t.Action_start(fattack, sattack) //返回本身结算,如果false,说明不能使用技能了
|
2025-09-28 01:58:42 +08:00
|
|
|
|
|
2025-11-08 23:20:48 +08:00
|
|
|
|
})
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2025-11-15 13:20:42 +08:00
|
|
|
|
canuse := canuseskill && //
|
|
|
|
|
|
action.CanUse(currentskill) && //pp还在
|
|
|
|
|
|
attacker.CurrentPet.Info.Hp > 0
|
|
|
|
|
|
|
|
|
|
|
|
if !canuse {
|
|
|
|
|
|
//根本没释放技能,这些效果全部失效
|
|
|
|
|
|
for _, e := range attacker.EffectCache {
|
|
|
|
|
|
e.Alive(false)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//这时候将被覆盖的效果全部装回来enterturn
|
|
|
|
|
|
for _, e := range attacker.Effect_Lost {
|
|
|
|
|
|
e.Alive(true)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-30 10:21:57 +00:00
|
|
|
|
} else {
|
2025-10-26 20:56:03 +08:00
|
|
|
|
|
|
|
|
|
|
f.processSkillAttack(attacker, defender, currentskill)
|
2025-11-11 06:23:59 +00:00
|
|
|
|
currentskill = oldskill //还原技能
|
2025-11-14 02:04:19 +08:00
|
|
|
|
// if oldskill != nil {
|
|
|
|
|
|
// fmt.Println("结束攻击_old", oldskill.Power)
|
|
|
|
|
|
// fmt.Println("结束攻击_new", currentskill.Power)
|
|
|
|
|
|
// }
|
2025-11-12 01:19:24 +08:00
|
|
|
|
|
2025-10-27 01:11:31 +08:00
|
|
|
|
_, skill, ok := utils.FindWithIndex(attacker.CurrentPet.Info.SkillList, func(item model.SkillInfo) bool {
|
|
|
|
|
|
return item.ID == currentskill.Info.ID
|
|
|
|
|
|
})
|
|
|
|
|
|
if ok {
|
|
|
|
|
|
|
|
|
|
|
|
skill.PP--
|
|
|
|
|
|
}
|
2025-09-10 02:11:16 +00:00
|
|
|
|
|
2025-09-10 02:16:47 +00:00
|
|
|
|
}
|
2025-11-30 10:21:57 +00:00
|
|
|
|
|
2025-11-22 22:57:32 +08:00
|
|
|
|
//0血不触发
|
|
|
|
|
|
if defender.CurrentPet.Info.Hp > 0 {
|
|
|
|
|
|
//技能使用后
|
|
|
|
|
|
defender.Exec(func(t input.Effect) bool {
|
|
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-11-22 22:57:32 +08:00
|
|
|
|
t.Skill_Use_ex()
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-11-22 22:57:32 +08:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-10-26 20:56:03 +08:00
|
|
|
|
//技能使用后
|
|
|
|
|
|
attacker.Exec(func(t input.Effect) bool { //技能使用后的我方效果
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Skill_Useed()
|
2025-10-26 20:56:03 +08:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-11-22 00:44:42 +08:00
|
|
|
|
defender.Exec(func(t input.Effect) bool {
|
|
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
2025-10-26 20:56:03 +08:00
|
|
|
|
|
2025-11-22 00:44:42 +08:00
|
|
|
|
t.Action_end_ex()
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//技能使用后
|
|
|
|
|
|
attacker.Exec(func(t input.Effect) bool { //技能使用后的我方效果
|
|
|
|
|
|
t.Ctx().SkillEntity = currentskill
|
|
|
|
|
|
|
|
|
|
|
|
t.Action_end()
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-09-10 01:35:08 +08:00
|
|
|
|
fmt.Println(i,
|
2025-10-10 00:40:32 +08:00
|
|
|
|
// "玩家技能:", oldskill.(*info.SkillEntity).ID,
|
2025-11-21 05:47:51 +00:00
|
|
|
|
"玩家技能伤害:", attacker.SumDamage,
|
2025-09-10 01:35:08 +08:00
|
|
|
|
"自身剩余血量:", attacker.CurrentPet.Info.Hp,
|
|
|
|
|
|
"对手剩余血量:", defender.CurrentPet.Info.Hp,
|
|
|
|
|
|
)
|
2025-11-08 23:20:48 +08:00
|
|
|
|
if attacker.CurrentPet.Info.Hp <= 0 {
|
|
|
|
|
|
if defender.CurrentPet.Info.Hp == 0 { //先手方死亡,触发反同归于尽
|
|
|
|
|
|
|
|
|
|
|
|
defender.CurrentPet.Info.Hp = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
if f.IsWin(defender, attacker.CurrentPet.Info.CatchTime) { //然后检查是否战斗结束
|
|
|
|
|
|
|
|
|
|
|
|
f.FightOverInfo.WinnerId = defender.UserID
|
|
|
|
|
|
|
|
|
|
|
|
f.closefight = true
|
2025-11-11 01:10:26 +08:00
|
|
|
|
// break
|
2025-12-01 01:45:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
|
|
|
|
|
|
if _, ok := defender.Player.(*player.AI_player); ok {
|
|
|
|
|
|
defender.GetAction(f.Our)
|
|
|
|
|
|
//panic("AI自动技能")
|
|
|
|
|
|
}
|
2025-11-26 18:39:23 +08:00
|
|
|
|
|
2025-12-01 01:45:19 +08:00
|
|
|
|
}
|
2025-11-26 18:39:23 +08:00
|
|
|
|
}
|
2025-12-01 01:45:19 +08:00
|
|
|
|
|
2025-11-14 23:09:16 +08:00
|
|
|
|
attacker.CanChange = true
|
|
|
|
|
|
break
|
2025-11-08 23:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-10 01:35:08 +08:00
|
|
|
|
if defender.CurrentPet.Info.Hp == 0 {
|
2025-11-08 23:20:48 +08:00
|
|
|
|
if attacker.CurrentPet.Info.Hp == 0 { //先手方死亡,触发反同归于尽
|
|
|
|
|
|
|
|
|
|
|
|
attacker.CurrentPet.Info.Hp = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-26 15:25:10 +08:00
|
|
|
|
defender.CanChange = true //被打死就可以切精灵了
|
|
|
|
|
|
// AI自动技能
|
|
|
|
|
|
|
2025-09-14 01:35:16 +08:00
|
|
|
|
if f.IsWin(attacker, defender.CurrentPet.Info.CatchTime) { //然后检查是否战斗结束
|
2025-09-10 01:35:08 +08:00
|
|
|
|
var WinnerId uint32
|
|
|
|
|
|
if i == 0 {
|
2025-09-21 14:56:37 +00:00
|
|
|
|
WinnerId = f.First.Player.GetInfo().UserID
|
2025-09-10 01:35:08 +08:00
|
|
|
|
} else {
|
2025-09-21 14:56:37 +00:00
|
|
|
|
WinnerId = f.Second.Player.GetInfo().UserID
|
2025-09-10 01:35:08 +08:00
|
|
|
|
}
|
2025-11-07 22:50:34 +08:00
|
|
|
|
f.FightOverInfo.WinnerId = WinnerId
|
2025-09-10 22:59:10 +08:00
|
|
|
|
|
2025-10-14 01:26:59 +08:00
|
|
|
|
f.closefight = true
|
2025-11-26 15:25:10 +08:00
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
|
2025-11-26 18:39:23 +08:00
|
|
|
|
if _, ok := defender.Player.(*player.AI_player); ok {
|
|
|
|
|
|
defender.GetAction(f.Our)
|
|
|
|
|
|
//panic("AI自动技能")
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-26 15:25:10 +08:00
|
|
|
|
}
|
2025-09-07 05:58:47 +08:00
|
|
|
|
}
|
2025-11-26 15:25:10 +08:00
|
|
|
|
break
|
2025-09-07 00:23:28 +08:00
|
|
|
|
}
|
2025-09-06 01:47:08 +08:00
|
|
|
|
|
2025-09-04 03:14:43 +08:00
|
|
|
|
}
|
2025-09-23 19:11:03 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
ff.GenSataus()
|
|
|
|
|
|
ff.Exec(func(t input.Effect) bool { //这个是能否使用技能
|
|
|
|
|
|
//结算状态
|
|
|
|
|
|
t.Turn_End() //返回本身结算,如果false,说明不能使用技能了
|
|
|
|
|
|
return true
|
2025-09-29 02:40:35 +08:00
|
|
|
|
})
|
2025-11-11 05:54:24 +00:00
|
|
|
|
ff.GenInfo()
|
2025-09-23 22:20:52 +00:00
|
|
|
|
})
|
2025-10-27 01:11:31 +08:00
|
|
|
|
|
2025-09-14 19:59:58 +08:00
|
|
|
|
ret := info.AttackValueS{
|
2025-11-10 08:25:40 +00:00
|
|
|
|
|
2025-09-14 19:59:58 +08:00
|
|
|
|
FAttack: *f.First.AttackValue,
|
|
|
|
|
|
SAttack: *f.Second.AttackValue,
|
|
|
|
|
|
}
|
2025-11-20 15:19:13 +08:00
|
|
|
|
//因为切完才能广播,所以必须和回合结束分开结算
|
2025-09-14 01:35:16 +08:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
2025-09-19 06:58:42 +00:00
|
|
|
|
for _, v := range f.Switch {
|
2025-10-21 22:14:30 +08:00
|
|
|
|
|
2025-11-20 15:19:13 +08:00
|
|
|
|
if ff.Player.GetInfo().UserID != v.Reason.UserId {
|
2025-11-19 16:11:02 +08:00
|
|
|
|
|
|
|
|
|
|
ff.Player.SendPackCmd(2407, &v.Reason)
|
2025-09-19 06:58:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-21 22:14:30 +08:00
|
|
|
|
|
2025-09-08 01:23:12 +08:00
|
|
|
|
})
|
2025-11-20 15:19:13 +08:00
|
|
|
|
f.Switch = []*action.ActiveSwitchAction{}
|
|
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
ff.Player.SendPackCmd(2505, &ret)
|
|
|
|
|
|
})
|
2025-09-04 03:14:43 +08:00
|
|
|
|
}
|