2025-11-01 18:36:21 +08:00
|
|
|
|
package fight
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
2025-11-08 16:38:41 +08:00
|
|
|
|
"blazing/common/data/xmlres"
|
2026-01-26 14:12:12 +00:00
|
|
|
|
"blazing/common/socket/errorcode"
|
2025-12-18 10:57:59 +00:00
|
|
|
|
"blazing/common/utils"
|
2025-11-15 23:02:46 +00:00
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
"context"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
"blazing/logic/service/common"
|
|
|
|
|
|
"blazing/logic/service/fight/action"
|
|
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
|
"blazing/logic/service/fight/input"
|
|
|
|
|
|
"blazing/logic/service/player"
|
2025-11-11 05:54:24 +00:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
"fmt"
|
|
|
|
|
|
"time"
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-12-05 00:24:02 +08:00
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
2025-11-08 16:38:41 +08:00
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2025-11-01 18:36:21 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func (f *FightC) battleLoop() {
|
2026-01-26 14:12:12 +00:00
|
|
|
|
defer func() {
|
|
|
|
|
|
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
|
|
|
|
|
// 1. 打印错误信息
|
2026-02-02 01:01:01 +08:00
|
|
|
|
var ctx = context.Background()
|
2026-02-02 18:32:41 +08:00
|
|
|
|
cool.Logger.Error(ctx, f.ownerID, err)
|
2026-01-26 14:12:12 +00:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
if p, ok := ff.Player.(*player.Player); ok {
|
|
|
|
|
|
head := common.NewTomeeHeader(1001, p.Info.UserID)
|
|
|
|
|
|
|
|
|
|
|
|
head.Result = uint32(errorcode.ErrorCodes.ErrSystemBusyTryLater)
|
|
|
|
|
|
|
|
|
|
|
|
p.SendPack(head.Pack(nil))
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}()
|
2025-12-16 02:50:10 +08:00
|
|
|
|
f.actionChan = make(chan action.BattleActionI, 10)
|
2025-11-15 23:02:46 +00:00
|
|
|
|
//fmt.Println("战斗开始精灵", f.Our.Player.GetInfo().PetList[0].CatchTime)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
|
|
|
|
|
|
ourID := f.Our.Player.GetInfo().UserID
|
|
|
|
|
|
oppID := f.Opp.Player.GetInfo().UserID
|
2025-12-16 02:50:10 +08:00
|
|
|
|
//fmt.Println("开始收集玩家动作", waitr)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
|
2025-11-12 01:19:24 +08:00
|
|
|
|
for !f.closefight {
|
2025-11-01 18:36:21 +08:00
|
|
|
|
|
|
|
|
|
|
f.Round++
|
|
|
|
|
|
|
|
|
|
|
|
actions := f.collectPlayerActions(ourID, oppID)
|
2025-11-11 01:10:26 +08:00
|
|
|
|
if f.closefight {
|
|
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
2025-11-11 11:45:09 +00:00
|
|
|
|
f.resolveRound(actions[ourID], actions[oppID])
|
|
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
2025-11-11 01:10:26 +08:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
|
2025-11-15 00:15:09 +08:00
|
|
|
|
//todo 将血量和技能pp传回enterturn
|
|
|
|
|
|
ff.Exec(func(tt input.Effect) bool {
|
|
|
|
|
|
tt.OnBattleEnd()
|
|
|
|
|
|
tt.Alive(false) //将所有属性变化失效掉
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-11-15 23:02:46 +00:00
|
|
|
|
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 {
|
|
|
|
|
|
|
2025-11-22 22:57:32 +08:00
|
|
|
|
if ff.UserID == f.WinnerId {
|
|
|
|
|
|
if ff.CurrentPet.Info.CatchTime == ff.Player.GetInfo().PetList[j].CatchTime {
|
|
|
|
|
|
f.Winpet = &ff.Player.GetInfo().PetList[j]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
2025-12-26 03:51:24 +08:00
|
|
|
|
ff.Player.GetInfo().PetList[j].Hp = utils.Min(ff.Player.GetInfo().PetList[j].MaxHp, ff.AllPet[i].Info.Hp)
|
2025-11-15 23:02:46 +00:00
|
|
|
|
ff.Player.GetInfo().PetList[j].SkillList = ff.AllPet[i].Info.SkillList
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-20 21:37:37 +08:00
|
|
|
|
|
2025-11-23 00:06:14 +08:00
|
|
|
|
})
|
2026-01-03 02:18:31 +08:00
|
|
|
|
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
|
2026-01-31 19:10:36 +08:00
|
|
|
|
|
2026-01-03 02:18:31 +08:00
|
|
|
|
if f.Reason == info.BattleOverReason.Cacthok {
|
|
|
|
|
|
f.WinnerId = f.ownerID
|
2026-01-25 03:40:29 +08:00
|
|
|
|
f.Opp.Player.GetInfo().PetList[0].EffectInfo = nil //清空特性信息
|
2026-01-03 02:18:31 +08:00
|
|
|
|
f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.Player.GetInfo().PetList[0])
|
|
|
|
|
|
|
|
|
|
|
|
f.Our.Player.SendPackCmd(2409, &info.CatchMonsterOutboundInfo{
|
|
|
|
|
|
CatchTime: uint32(f.Opp.Player.GetInfo().PetList[0].CatchTime),
|
|
|
|
|
|
PetId: uint32(f.Opp.CurrentPet.ID),
|
|
|
|
|
|
})
|
2026-01-31 19:10:36 +08:00
|
|
|
|
|
|
|
|
|
|
defer f.Our.Player.(*player.Player).Service.Done.UpdatePet(f.Opp.Player.GetInfo().PetList[0], 0, 1)
|
2026-01-03 02:18:31 +08:00
|
|
|
|
//f.Reason = 0 //清空
|
|
|
|
|
|
}
|
|
|
|
|
|
if f.Reason == 0 {
|
2026-01-31 19:10:36 +08:00
|
|
|
|
|
|
|
|
|
|
defer f.Our.Player.(*player.Player).Service.Done.UpdatePet(f.Opp.Player.GetInfo().PetList[0], 1, 0)
|
2025-12-03 22:05:28 +08:00
|
|
|
|
|
2026-01-03 02:18:31 +08:00
|
|
|
|
}
|
2026-01-20 02:25:02 +08:00
|
|
|
|
f.Our.Player.(*player.Player).GenMonster()
|
2025-12-03 22:05:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-01 01:45:19 +08:00
|
|
|
|
//大乱斗,给个延迟
|
|
|
|
|
|
//<-time.After(1000)
|
2025-11-23 00:06:14 +08:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
2025-12-01 01:45:19 +08:00
|
|
|
|
|
2025-11-19 16:11:02 +08:00
|
|
|
|
ff.Player.SendPackCmd(2506, &f.FightOverInfo)
|
|
|
|
|
|
|
2025-11-18 22:16:55 +00:00
|
|
|
|
ff.Player.QuitFight()
|
|
|
|
|
|
|
2025-11-18 20:52:04 +00:00
|
|
|
|
//待退出玩家战斗状态
|
2025-11-11 01:10:26 +08:00
|
|
|
|
})
|
2025-11-15 00:15:09 +08:00
|
|
|
|
|
2026-01-03 02:18:31 +08:00
|
|
|
|
//f.Reason = info.BattleOverReason.PlayerCaptureSuccess
|
|
|
|
|
|
//f.WinnerId = 0 //捕捉成功不算胜利
|
|
|
|
|
|
if f.callback != nil {
|
|
|
|
|
|
|
|
|
|
|
|
f.callback(f.FightOverInfo) //先执行回调,再执行返回信息,在回调内修改战斗判断
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
2025-11-12 01:19:24 +08:00
|
|
|
|
close(f.over)
|
2025-11-12 21:44:56 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 收集玩家动作(含超时判定)
|
|
|
|
|
|
func (f *FightC) collectPlayerActions(ourID, oppID uint32) map[uint32]action.BattleActionI {
|
|
|
|
|
|
actions := make(map[uint32]action.BattleActionI)
|
|
|
|
|
|
|
2026-02-05 23:44:07 +08:00
|
|
|
|
waitr := time.Duration(f.waittime)*time.Millisecond*10 + 30*time.Second
|
2025-12-16 02:50:10 +08:00
|
|
|
|
|
2025-11-13 05:05:05 +08:00
|
|
|
|
timeout := time.After(waitr)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
for len(actions) < 2 {
|
2025-11-13 05:05:05 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
select {
|
2025-11-11 11:45:09 +00:00
|
|
|
|
case <-f.quit:
|
|
|
|
|
|
f.closefight = true
|
|
|
|
|
|
return actions
|
|
|
|
|
|
|
2025-11-10 02:29:00 +08:00
|
|
|
|
case paction, ok := <-f.actionChan:
|
2025-11-13 05:05:05 +08:00
|
|
|
|
if !ok {
|
2025-11-11 11:45:09 +00:00
|
|
|
|
f.closefight = true
|
2025-11-01 18:36:21 +08:00
|
|
|
|
return actions
|
|
|
|
|
|
}
|
|
|
|
|
|
if paction == nil {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pid := paction.GetPlayerID()
|
2026-02-07 01:12:46 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
if pid != ourID && pid != oppID {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
2026-02-07 00:18:14 +08:00
|
|
|
|
// if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC && pid != 0 {
|
|
|
|
|
|
// f.Opp.GetAction()
|
2026-01-07 02:30:21 +08:00
|
|
|
|
|
2026-02-07 00:18:14 +08:00
|
|
|
|
// }
|
2025-12-10 16:42:23 +00:00
|
|
|
|
selfinput := f.GetInputByAction(paction, false)
|
2025-12-10 16:03:45 +00:00
|
|
|
|
if ret, ok := paction.(*action.ActiveSwitchAction); ok {
|
2026-02-07 01:12:46 +08:00
|
|
|
|
// println("玩家执行切换精灵动作:", pid, ret.Cid)
|
2025-12-11 13:31:20 +08:00
|
|
|
|
//正常结束可以切换,以及死切后还能再切一次
|
2025-12-10 16:42:23 +00:00
|
|
|
|
if selfinput.CanChange == 0 {
|
|
|
|
|
|
if selfinput.CurrentPet.Info.Hp > 0 { //非死亡切换
|
|
|
|
|
|
selfinput.CanChange = 1
|
2025-12-25 20:49:54 +08:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
|
|
|
|
|
|
ff.Exec(func(t input.Effect) bool {
|
|
|
|
|
|
|
|
|
|
|
|
t.SwitchOut(selfinput)
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2025-12-10 16:42:23 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
selfinput.CanChange = 2
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-25 20:49:54 +08:00
|
|
|
|
// oldpet := selfinput.CurrentPet
|
|
|
|
|
|
// InitAttackValue := *selfinput.AttackValue
|
2025-12-11 12:16:32 +08:00
|
|
|
|
selfinput.CurrentPet, ret.Reason = selfinput.GetPet(ret.Cid)
|
2026-02-05 23:44:07 +08:00
|
|
|
|
|
2025-12-11 12:16:32 +08:00
|
|
|
|
selfinput.Player.SendPackCmd(2407, &ret.Reason)
|
2025-12-18 23:57:17 +08:00
|
|
|
|
|
2025-12-10 16:03:45 +00:00
|
|
|
|
f.Switch[selfinput.UserID] = ret
|
|
|
|
|
|
|
|
|
|
|
|
selfinput.InitAttackValue() //切换精灵消除能力提升
|
|
|
|
|
|
//这时候精灵已经切换过了,可以直接给新精灵加效果
|
|
|
|
|
|
|
|
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
|
|
|
|
|
|
|
|
|
|
|
ff.Exec(func(t input.Effect) bool {
|
|
|
|
|
|
|
2025-12-25 20:49:54 +08:00
|
|
|
|
t.SwitchIn(selfinput)
|
2025-12-10 16:03:45 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
2025-12-11 13:31:20 +08:00
|
|
|
|
if selfinput.CanChange == 2 {
|
2025-12-16 02:50:10 +08:00
|
|
|
|
|
2025-12-11 13:31:20 +08:00
|
|
|
|
selfinput.CanChange = 0
|
2025-12-16 07:42:45 +00:00
|
|
|
|
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC && pid == 0 {
|
|
|
|
|
|
f.Switch = make(map[uint32]*action.ActiveSwitchAction)
|
|
|
|
|
|
f.Our.Player.SendPackCmd(2407, &ret.Reason)
|
2026-02-07 01:12:46 +08:00
|
|
|
|
//println("AI出手死切")
|
|
|
|
|
|
f.Opp.GetAction() //boss出手后获取出招
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
2025-12-16 07:42:45 +00:00
|
|
|
|
}
|
2025-12-11 13:31:20 +08:00
|
|
|
|
continue
|
|
|
|
|
|
}
|
2026-02-05 23:44:07 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
continue
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
2025-12-01 23:31:48 +08:00
|
|
|
|
|
2025-12-10 16:42:23 +00:00
|
|
|
|
} else {
|
2026-02-07 01:12:46 +08:00
|
|
|
|
println("玩家执行释放技能动作:", pid, paction.(*action.SelectSkillAction).Info.ID)
|
2025-12-10 16:42:23 +00:00
|
|
|
|
if selfinput.CurrentPet.Info.Hp <= 0 { //0血执行非切换动作
|
|
|
|
|
|
//todo 记录异常操作
|
2026-02-07 01:12:46 +08:00
|
|
|
|
println("玩家执行了异常操作,当前精灵血量为0,不能执行非切换动作", pid)
|
2025-12-10 16:42:23 +00:00
|
|
|
|
continue
|
|
|
|
|
|
}
|
|
|
|
|
|
if selfinput.CanChange == 1 { //非被动死亡情况下,不能执行额外动作,0允许切,2是死亡,可以额外动作
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
2026-02-02 12:36:43 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
actions[pid] = paction
|
2025-11-03 03:59:59 +08:00
|
|
|
|
//fmt.Println("玩家执行动作:", pid, paction.Priority())
|
2025-11-01 18:36:21 +08:00
|
|
|
|
|
|
|
|
|
|
case <-timeout:
|
|
|
|
|
|
f.handleTimeout(ourID, oppID, actions)
|
|
|
|
|
|
return actions
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return actions
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 超时处理逻辑
|
|
|
|
|
|
func (f *FightC) handleTimeout(ourID, oppID uint32, actions map[uint32]action.BattleActionI) {
|
|
|
|
|
|
for _, pid := range []uint32{ourID, oppID} {
|
|
|
|
|
|
if _, exists := actions[pid]; exists {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
2025-11-11 11:45:09 +00:00
|
|
|
|
|
|
|
|
|
|
f.Reason = info.BattleOverReason.PlayerOVerTime
|
|
|
|
|
|
f.closefight = true
|
|
|
|
|
|
//对方赢
|
2025-12-10 18:37:32 +00:00
|
|
|
|
if f.Info.Status == info.BattleMode.FIGHT_WITH_NPC {
|
2026-02-03 20:20:13 +08:00
|
|
|
|
f.WinnerId = 0
|
2025-12-10 18:37:32 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-11 11:45:09 +00:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 根据动作类型执行一回合结算
|
|
|
|
|
|
func (f *FightC) resolveRound(p1Action, p2Action action.BattleActionI) {
|
|
|
|
|
|
if p1Action == nil || p2Action == nil {
|
2025-12-25 12:14:04 +08:00
|
|
|
|
cool.Logger.Debug(context.Background(), "某方未选择动作,自动跳过结算")
|
2025-11-01 18:36:21 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 动作优先级排序
|
|
|
|
|
|
b1, b2 := f.Compare(p1Action, p2Action)
|
|
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
switch actionType := b1.(type) {
|
2025-11-01 18:36:21 +08:00
|
|
|
|
case *action.ActiveSwitchAction:
|
2026-01-03 01:35:32 +08:00
|
|
|
|
f.handleActiveSwitchAction(actionType, b2)
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
case *action.UseItemAction:
|
|
|
|
|
|
f.handleUseItemAction(actionType, b2)
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
default:
|
|
|
|
|
|
f.handleSkillActions(b1, b2)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-01 18:36:21 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
// handleActiveSwitchAction 处理主动切换精灵动作
|
|
|
|
|
|
func (f *FightC) handleActiveSwitchAction(switchAction *action.ActiveSwitchAction, otherAction action.BattleActionI) {
|
|
|
|
|
|
|
|
|
|
|
|
if skillAction, ok := otherAction.(*action.SelectSkillAction); ok {
|
|
|
|
|
|
if skillAction.SkillEntity != nil && skillAction.CD != nil {
|
|
|
|
|
|
f.waittime = *skillAction.CD
|
2025-11-13 21:36:18 +08:00
|
|
|
|
}
|
2026-01-03 01:35:32 +08:00
|
|
|
|
f.enterturn(skillAction, nil)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
f.enterturn(nil, nil)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-25 18:25:52 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
// handleUseItemAction 处理使用道具动作
|
|
|
|
|
|
func (f *FightC) handleUseItemAction(itemAction *action.UseItemAction, otherAction action.BattleActionI) {
|
|
|
|
|
|
f.handleItemAction(itemAction)
|
2026-01-03 02:18:31 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
input := f.GetInputByAction(itemAction, false)
|
|
|
|
|
|
if input.CurrentPet.Info.Hp <= 0 {
|
|
|
|
|
|
input.CurrentPet.Info.Hp = 1
|
|
|
|
|
|
}
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
if skillAction, ok := otherAction.(*action.SelectSkillAction); ok {
|
|
|
|
|
|
if skillAction.SkillEntity != nil && skillAction.CD != nil {
|
|
|
|
|
|
f.waittime = *skillAction.CD
|
2025-11-08 16:38:41 +08:00
|
|
|
|
}
|
2026-01-03 01:35:32 +08:00
|
|
|
|
f.enterturn(skillAction, nil)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if otherItemAction, ok := otherAction.(*action.UseItemAction); ok {
|
|
|
|
|
|
f.handleItemAction(otherItemAction)
|
|
|
|
|
|
}
|
|
|
|
|
|
f.enterturn(nil, nil)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 使用道具的逻辑封装
|
2025-11-08 16:38:41 +08:00
|
|
|
|
func (f *FightC) handleItemAction(a *action.UseItemAction) {
|
|
|
|
|
|
|
|
|
|
|
|
item, ok := xmlres.ItemsMAP[int(a.ItemID)]
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-01-20 02:25:02 +08:00
|
|
|
|
r := f.GetInputByAction(a, false).Player.(*player.Player).Service.Item.CheakItem(uint32(a.ItemID))
|
2025-11-25 12:29:50 +08:00
|
|
|
|
if r < 1 {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-12-16 06:54:27 +00:00
|
|
|
|
f.GetInputByAction(a, false).Player.(*player.Player).Service.Item.UPDATE(a.ItemID, -1)
|
2025-11-20 21:37:37 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
switch {
|
2025-11-08 16:38:41 +08:00
|
|
|
|
case gconv.Int(item.Bonus) != 0:
|
2025-11-19 16:11:02 +08:00
|
|
|
|
|
2025-11-21 02:40:27 +08:00
|
|
|
|
if f.Opp.CanCapture > 0 { //可以捕捉
|
|
|
|
|
|
f.Opp.CurrentPet.CatchRate = f.Opp.CanCapture
|
2025-12-03 22:05:28 +08:00
|
|
|
|
ok, _ := f.Our.Capture(f.Opp.CurrentPet, a.ItemID, -1)
|
2025-11-19 16:11:02 +08:00
|
|
|
|
our := f.Our.Player.(*player.Player)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
if ok {
|
2025-12-03 22:05:28 +08:00
|
|
|
|
f.Reason = info.BattleOverReason.Cacthok
|
2025-11-01 18:36:21 +08:00
|
|
|
|
f.closefight = true
|
|
|
|
|
|
} else {
|
2025-11-20 21:37:37 +08:00
|
|
|
|
our.SendPack(common.NewTomeeHeader(2409, f.ownerID).Pack(&info.CatchMonsterOutboundInfo{}))
|
2025-11-19 16:11:02 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-08 16:38:41 +08:00
|
|
|
|
case gconv.Int(item.HP) != 0:
|
|
|
|
|
|
addhp := item.HP
|
|
|
|
|
|
f.GetInputByAction(a, false).Exec(func(rr input.Effect) bool {
|
|
|
|
|
|
rr.Heal_Pre(a, &addhp)
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-05 00:24:02 +08:00
|
|
|
|
f.GetInputByAction(a, false).Heal(f.GetInputByAction(a, false), a, alpacadecimal.NewFromInt(int64(addhp)))
|
2025-11-08 16:38:41 +08:00
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
2025-11-19 16:11:02 +08:00
|
|
|
|
ff.Player.SendPackCmd(2406, &info.UsePetIteminfo{
|
2025-11-08 16:38:41 +08:00
|
|
|
|
UserID: f.GetInputByAction(a, false).UserID,
|
|
|
|
|
|
ChangeHp: int32(addhp),
|
|
|
|
|
|
ItemID: uint32(item.ID),
|
|
|
|
|
|
UserHp: uint32(f.GetInputByAction(a, false).CurrentPet.Info.Hp),
|
|
|
|
|
|
})
|
2025-11-19 16:11:02 +08:00
|
|
|
|
|
2025-11-08 16:38:41 +08:00
|
|
|
|
})
|
|
|
|
|
|
case gconv.Int(item.PP) != 0:
|
|
|
|
|
|
f.GetInputByAction(a, false).HealPP(item.PP)
|
|
|
|
|
|
f.Broadcast(func(ff *input.Input) {
|
2025-11-19 16:11:02 +08:00
|
|
|
|
ff.Player.SendPackCmd(2406, &info.UsePetIteminfo{
|
2025-11-08 16:38:41 +08:00
|
|
|
|
UserID: f.GetInputByAction(a, false).UserID,
|
|
|
|
|
|
|
|
|
|
|
|
ItemID: uint32(item.ID),
|
|
|
|
|
|
UserHp: uint32(f.GetInputByAction(a, false).CurrentPet.Info.Hp),
|
|
|
|
|
|
})
|
2025-11-19 16:11:02 +08:00
|
|
|
|
|
2025-11-08 16:38:41 +08:00
|
|
|
|
})
|
2025-11-08 00:47:45 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
default:
|
|
|
|
|
|
|
2025-11-08 16:38:41 +08:00
|
|
|
|
fmt.Println(a.ItemID, "ItemID 不在指定范围内")
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 双方都是技能时的结算逻辑
|
|
|
|
|
|
func (f *FightC) handleSkillActions(a1, a2 action.BattleActionI) {
|
|
|
|
|
|
s1, _ := a1.(*action.SelectSkillAction)
|
|
|
|
|
|
s2, _ := a2.(*action.SelectSkillAction)
|
|
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
|
|
case s1 == nil || s1.SkillEntity == nil:
|
2025-11-26 18:39:23 +08:00
|
|
|
|
if s2.SkillEntity != nil {
|
|
|
|
|
|
if s2.CD != nil {
|
|
|
|
|
|
f.waittime = *s2.CD
|
|
|
|
|
|
}
|
2025-11-15 16:27:59 +08:00
|
|
|
|
}
|
2025-11-26 18:39:23 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
f.enterturn(s2, nil)
|
2025-11-26 18:39:23 +08:00
|
|
|
|
// fmt.Println("1 空过 2玩家执行技能:", s2.PlayerID, s2.Info.ID)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
case s2 == nil || s2.SkillEntity == nil:
|
2025-11-26 18:39:23 +08:00
|
|
|
|
if s1.SkillEntity != nil {
|
|
|
|
|
|
if s1.CD != nil {
|
|
|
|
|
|
f.waittime = *s1.CD
|
|
|
|
|
|
}
|
2025-11-15 16:27:59 +08:00
|
|
|
|
}
|
2025-11-01 18:36:21 +08:00
|
|
|
|
f.enterturn(s1, nil)
|
2025-11-26 18:39:23 +08:00
|
|
|
|
//fmt.Println("2 空过 玩家执行技能:", s1.PlayerID, s1.Info.ID)
|
2025-11-01 18:36:21 +08:00
|
|
|
|
default:
|
2025-11-15 16:27:59 +08:00
|
|
|
|
if s1.CD != nil {
|
|
|
|
|
|
f.waittime = *s1.CD
|
|
|
|
|
|
}
|
|
|
|
|
|
if s2.CD != nil {
|
|
|
|
|
|
f.waittime += *s2.CD
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
f.enterturn(s1, s2)
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
2025-11-01 18:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 根据玩家ID返回对应对象
|
|
|
|
|
|
func (f *FightC) getPlayerByID(id uint32) common.PlayerI {
|
|
|
|
|
|
if id == f.Our.Player.GetInfo().UserID {
|
|
|
|
|
|
return f.Our.Player
|
|
|
|
|
|
}
|
|
|
|
|
|
return f.Opp.Player
|
|
|
|
|
|
}
|