2025-09-14 01:35:16 +08:00
|
|
|
|
package input
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
2025-09-30 18:32:15 +08:00
|
|
|
|
"blazing/common/data/xmlres"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
"blazing/logic/service/common"
|
2025-09-30 18:32:15 +08:00
|
|
|
|
"blazing/logic/service/fight/action"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
2025-09-28 08:13:42 +00:00
|
|
|
|
"github.com/shopspring/decimal"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type Input struct {
|
2025-09-30 18:32:15 +08:00
|
|
|
|
CanChange bool //是否可以死亡切换CanChange
|
|
|
|
|
|
CurrentPet *info.BattlePetEntity //当前精灵
|
|
|
|
|
|
AllPet []*info.BattlePetEntity
|
|
|
|
|
|
Player common.PlayerI
|
|
|
|
|
|
EffectCache []Effect
|
|
|
|
|
|
Finished bool //是否加载完成
|
2025-09-14 01:35:16 +08:00
|
|
|
|
*info.AttackValue
|
|
|
|
|
|
FightC common.FightI
|
|
|
|
|
|
// info.BattleActionI
|
2025-10-31 11:21:24 +00:00
|
|
|
|
Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的
|
2025-09-26 21:15:58 +00:00
|
|
|
|
DamageZone struct {
|
2025-09-29 02:40:35 +08:00
|
|
|
|
Damage decimal.Decimal //伤害
|
|
|
|
|
|
BeforeADD decimal.Decimal //攻击伤害
|
|
|
|
|
|
BeforeMul decimal.Decimal
|
|
|
|
|
|
BeforeFloor decimal.Decimal
|
|
|
|
|
|
BeforeDiv decimal.Decimal
|
|
|
|
|
|
BeforeSUB decimal.Decimal
|
|
|
|
|
|
BeforeLock decimal.Decimal //锁伤 先锁受击方,再锁攻击方 受击方免疫也是这么锁 免疫等于锁0
|
|
|
|
|
|
BeforeLocked decimal.Decimal
|
2025-09-28 09:31:08 +00:00
|
|
|
|
//BeforePost decimal.Decimal
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2025-09-28 01:58:42 +08:00
|
|
|
|
//OldAttack int //攻击伤害被挡前伤害记录
|
2025-09-26 21:15:58 +00:00
|
|
|
|
} //伤害容器
|
2025-09-30 18:32:15 +08:00
|
|
|
|
//First bool //是否先手
|
2025-09-14 01:35:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-14 04:48:38 +08:00
|
|
|
|
func NewInput(c common.FightI, p common.PlayerI) *Input {
|
|
|
|
|
|
ret := &Input{FightC: c, Player: p}
|
2025-10-31 11:21:24 +00:00
|
|
|
|
ret.Effects = make([]Effect, 0)
|
2025-09-26 21:15:58 +00:00
|
|
|
|
|
2025-09-26 02:09:33 +00:00
|
|
|
|
// t := Geteffect(EffectType.Damage, 0)
|
|
|
|
|
|
// t.Effect.SetArgs(ret)
|
|
|
|
|
|
// ret.AddEffect(t) //添加默认基类,实现继承
|
|
|
|
|
|
p.SetFightC(c) //给玩家设置战斗容器
|
2025-09-24 19:46:42 +08:00
|
|
|
|
|
2025-09-14 04:48:38 +08:00
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-14 01:35:16 +08:00
|
|
|
|
func (i *Input) GetPetInfo() *info.BattlePetEntity {
|
|
|
|
|
|
|
|
|
|
|
|
return i.CurrentPet
|
|
|
|
|
|
|
2025-10-31 02:24:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
func (i *Input) ResetAttackValue() {
|
|
|
|
|
|
i.AttackValue.SkillID = 0
|
|
|
|
|
|
|
2025-09-14 01:35:16 +08:00
|
|
|
|
}
|
2025-09-14 04:48:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 这个每回合都会调用
|
2025-09-14 01:35:16 +08:00
|
|
|
|
func (i *Input) InitAttackValue() {
|
2025-09-21 14:56:37 +00:00
|
|
|
|
i.AttackValue = info.NewAttackValue(i.Player.GetInfo().UserID)
|
2025-09-14 01:35:16 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
func (i *Input) GetPet(id uint32) (ii *info.BattlePetEntity, Reason info.ChangePetInfo) {
|
|
|
|
|
|
for _, v := range i.AllPet {
|
|
|
|
|
|
if v.Info.CatchTime == uint32(id) {
|
|
|
|
|
|
copier.Copy(&Reason, &v.Info)
|
2025-09-21 14:56:37 +00:00
|
|
|
|
Reason.UserId = i.Player.GetInfo().UserID
|
2025-09-14 01:35:16 +08:00
|
|
|
|
|
|
|
|
|
|
ii = v
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-21 14:56:37 +00:00
|
|
|
|
|
|
|
|
|
|
// GetStatusBonus 获取最高的状态倍率
|
|
|
|
|
|
// 遍历状态数组,返回存在的状态中最高的倍率(无状态则返回1.0)
|
|
|
|
|
|
func (i *Input) GetStatusBonus() float64 {
|
|
|
|
|
|
// 异常状态倍率映射表(状态索引 -> 倍率)
|
|
|
|
|
|
var statusBonuses = map[info.EnumBattleStatus]float64{
|
2025-09-25 14:51:11 +00:00
|
|
|
|
info.PetStatus.Paralysis: 1.5,
|
|
|
|
|
|
info.PetStatus.Poisoned: 1.5,
|
|
|
|
|
|
info.PetStatus.Sleep: 2.0,
|
2025-09-21 14:56:37 +00:00
|
|
|
|
// /info.BattleStatus.Frozen: 2.0,
|
|
|
|
|
|
}
|
|
|
|
|
|
maxBonus := 1.0 // 默认无状态倍率
|
|
|
|
|
|
|
|
|
|
|
|
for statusIdx := 0; statusIdx < 20; statusIdx++ {
|
2025-09-24 16:36:32 +00:00
|
|
|
|
t := Geteffect(EffectType.Status, statusIdx)
|
2025-09-21 14:56:37 +00:00
|
|
|
|
|
|
|
|
|
|
// 检查状态是否存在(数组中值为1表示存在该状态)
|
2025-10-31 11:21:24 +00:00
|
|
|
|
if t != nil && t.Stack() > 0 {
|
2025-09-21 14:56:37 +00:00
|
|
|
|
if bonus, exists := statusBonuses[info.EnumBattleStatus(statusIdx)]; exists && bonus > maxBonus {
|
|
|
|
|
|
maxBonus = bonus
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return maxBonus
|
|
|
|
|
|
}
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 解析并 施加effect
|
|
|
|
|
|
func (i *Input) Parseskill(defender *Input, skill *action.SelectSkillAction) {
|
2025-10-05 00:29:22 +08:00
|
|
|
|
i.EffectCache = make([]Effect, 0) //先把上一回合数据清空
|
2025-10-26 20:56:03 +08:00
|
|
|
|
temparg := skill.SideEffectArgS
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-10-26 20:56:03 +08:00
|
|
|
|
for _, v := range skill.SideEffectS {
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
|
|
|
|
|
t := Geteffect(EffectType.Skill, v)
|
|
|
|
|
|
|
|
|
|
|
|
args := xmlres.EffectArgs[v]
|
2025-10-05 00:29:22 +08:00
|
|
|
|
//这里是给双方添加buff
|
2025-10-31 11:21:24 +00:00
|
|
|
|
if t != nil {
|
|
|
|
|
|
t.SetArgs(i, temparg[:args]...) //设置入参,施加方永远是我方
|
2025-09-30 18:32:15 +08:00
|
|
|
|
|
2025-11-03 14:46:33 +00:00
|
|
|
|
if t.Owner() { //如果取反,说明是给对方添加的回合效果
|
2025-10-05 00:29:22 +08:00
|
|
|
|
//实际上,owner永远为反,说明是对方给我添加的
|
2025-10-31 11:21:24 +00:00
|
|
|
|
t.SetArgs(i, temparg[:args]...) //设置入参,施加方永远是我方
|
2025-10-05 00:29:22 +08:00
|
|
|
|
//给双方添加
|
|
|
|
|
|
defender.AddEffect(t)
|
|
|
|
|
|
} else {
|
2025-10-31 11:21:24 +00:00
|
|
|
|
t.SetArgs(i, temparg[:args]...) //设置入参
|
2025-10-05 00:29:22 +08:00
|
|
|
|
i.AddEffect(t)
|
|
|
|
|
|
}
|
|
|
|
|
|
//这里是临时缓存buff,后面确认命中后修改HIT状态
|
|
|
|
|
|
|
2025-10-31 11:21:24 +00:00
|
|
|
|
i.EffectCache = append(i.EffectCache, t)
|
2025-09-30 18:32:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
temparg = temparg[args:]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|