``` refactor(fight): 重构精灵切换逻辑,将切换效果处理移至回合收集阶段并优化闪光字段结构
This commit is contained in:
@@ -68,23 +68,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
|
||||
selfinput.CurrentPet, ret.Reason = selfinput.GetPet(id)
|
||||
c.SendPackCmd(2407, &ret.Reason)
|
||||
InitAttackValue := *selfinput.AttackValue
|
||||
oldpet := selfinput.CurrentPet
|
||||
f.Switch[c.GetInfo().UserID] = ret
|
||||
|
||||
selfinput.InitAttackValue() //切换精灵消除能力提升
|
||||
//这时候精灵已经切换过了,可以直接给新精灵加效果
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
ff.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.Switch(selfinput, InitAttackValue, oldpet)
|
||||
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
f.actionChan <- ret
|
||||
}
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
||||
}
|
||||
}
|
||||
|
||||
attacker.CanChange = true
|
||||
//attacker.CanChange = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
||||
attacker.CurrentPet.Info.Hp = 1
|
||||
}
|
||||
|
||||
defender.CanChange = true //被打死就可以切精灵了
|
||||
//defender.CanChange = true //被打死就可以切精灵了
|
||||
// AI自动技能
|
||||
|
||||
if f.IsWin(attacker, defender.CurrentPet.Info.CatchTime) { //然后检查是否战斗结束
|
||||
@@ -403,5 +403,6 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
||||
}
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
ff.Player.SendPackCmd(2505, &ret)
|
||||
ff.CanChange = true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -139,17 +139,30 @@ func (f *FightC) collectPlayerActions(ourID, oppID uint32) map[uint32]action.Bat
|
||||
// fmt.Printf("玩家%d 已经提交过动作,忽略重复\n", pid)
|
||||
// continue
|
||||
// }
|
||||
if f.GetInputByAction(paction, false).CanChange {
|
||||
// 被动切换处理(不计入本回合)
|
||||
if _, ok := paction.(*action.ActiveSwitchAction); ok {
|
||||
continue
|
||||
} else {
|
||||
f.GetInputByAction(paction, false).CanChange = false
|
||||
|
||||
if ret, ok := paction.(*action.ActiveSwitchAction); ok {
|
||||
selfinput := f.GetInputByAction(paction, false)
|
||||
if selfinput.CanChange || selfinput.CurrentPet.Info.Hp <= 0 {
|
||||
selfinput.CanChange = false
|
||||
InitAttackValue := *selfinput.AttackValue
|
||||
oldpet := selfinput.CurrentPet
|
||||
f.Switch[selfinput.UserID] = ret
|
||||
|
||||
selfinput.InitAttackValue() //切换精灵消除能力提升
|
||||
//这时候精灵已经切换过了,可以直接给新精灵加效果
|
||||
|
||||
f.Broadcast(func(ff *input.Input) {
|
||||
|
||||
ff.Exec(func(t input.Effect) bool {
|
||||
|
||||
t.Switch(selfinput, InitAttackValue, oldpet)
|
||||
|
||||
return true
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// AI自动技能
|
||||
if pid != 0 && (f.Info.Status == info.BattleMode.FIGHT_WITH_NPC) {
|
||||
f.GetInputByAction(paction, true).GetAction(f.Our)
|
||||
|
||||
@@ -108,8 +108,12 @@ type PetInfo struct {
|
||||
SkinID uint32 `fieldDesc:"皮肤id默认为0" `
|
||||
|
||||
// 是否闪光(@UInt long → uint32,0=否,1=是)
|
||||
Shiny uint32 `fieldDesc:"是不是闪" `
|
||||
// AbilityType uint32 `struc:"skip"` //特性
|
||||
ShinyLen uint32 `struc:"sizeof=Shiny"`
|
||||
Shiny []GlowFilter
|
||||
|
||||
//时间轮转,然后effect根据type同时只共存一个,特性是1 特质是1,柱子是两种,魂印是一个,然后异色字段,然后特训技能字段
|
||||
ExtSKill []uint32 `struc:"skip"` //特训技能
|
||||
|
||||
}
|
||||
|
||||
// 定义常量,提升可维护性(避免魔法数字)
|
||||
@@ -237,6 +241,7 @@ func (pet *PetInfo) RnadAN() {
|
||||
}
|
||||
}
|
||||
|
||||
// 1是特性特质,<!-- Stat: 精灵特效Stat: 0: 无效(默认值), 1: 永久, 2: 有`有效次数'的特效 3: 爆发特效 4: 异能精灵特质,5特训,6魂印-->
|
||||
func (pet *PetInfo) GetEffect(ptype int) (int, *PetEffectInfo, bool) {
|
||||
|
||||
return utils.FindWithIndex(pet.EffectInfo, func(item PetEffectInfo) bool {
|
||||
@@ -411,7 +416,8 @@ func GenPetInfo(
|
||||
|
||||
// ---- 处理闪光 ----
|
||||
if shinyid != -1 {
|
||||
p.Shiny = uint32(shinyid)
|
||||
//todo 待实现异色字段
|
||||
// p.Shiny = uint32(shinyid)
|
||||
}
|
||||
|
||||
// ---- 性格 ----
|
||||
@@ -565,14 +571,6 @@ type GlowFilter struct {
|
||||
Inner bool `json:"inner,omitempty"`
|
||||
|
||||
// Knockout 是否挖空,默认 false
|
||||
Knockout bool `json:"knockout,omitempty"`
|
||||
}
|
||||
type ColorMatrixFilter struct {
|
||||
// Matrix 4×5 颜色变换矩阵,固定长度20的int8数组(不可变长度,避免越界)
|
||||
// 矩阵格式(行优先):
|
||||
// [ Rr, Rg, Rb, Ra, Ro, // 输出R = Rr*输入R + Rg*输入G + Rb*输入B + Ra*输入A + Ro
|
||||
// Gr, Gg, Gb, Ga, Go, // 输出G = Gr*输入R + Gg*输入G + Gb*输入B + Ga*输入A + Go
|
||||
// Br, Bg, Bb, Ba, Bo, // 输出B = Br*输入R + Bg*输入G + Bb*输入B + Ba*输入A + Bo
|
||||
// Ar, Ag, Ab, Aa, Ao ] // 输出A = Ar*输入R + Ag*输入G + Ab*输入B + Aa*输入A + Ao
|
||||
Matrix [20]uint8 `json:"matrix,omitempty"`
|
||||
Knockout bool `json:"knockout,omitempty"`
|
||||
ColorMatrixFilter [20]uint8 `json:"matrix,omitempty"`
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@
|
||||
<!-- NewSeIdx: 精灵特效索引 (默认0: 无效) -->
|
||||
<!-- Type: 0 - 仅单人战斗; 1 - 仅组队战斗; 2 - both; (默认0: 仅单人) -->
|
||||
<!-- Eid: 精灵特效eid (默认0: 无效) -->
|
||||
<!-- Stat: 精灵特效Stat: 0: 无效(默认值), 1: 永久, 2: 有`有效次数'的特效 3: 爆发特效 4: 异能精灵特质-->
|
||||
<!-- Stat: 精灵特效Stat: 0: 无效(默认值), 1: 永久, 2: 有`有效次数'的特效 3: 爆发特效 4: 异能精灵特质,5特训,6魂印-->
|
||||
<!-- Times: 精灵特效可使用次数: 当type==2时有效 (默认值:0) -->
|
||||
<!-- Args: 特效参数, 不超过8个 (注意: 每个参数不能超过 65535) -->
|
||||
<!-- AdditionType:特效加成类型 1 种族值加成 2 技能威力加成 -->
|
||||
|
||||
Reference in New Issue
Block a user