feat: 支持多精灵战斗位操作
This commit is contained in:
@@ -33,8 +33,8 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
|
||||
var originalProps [2][6]int8
|
||||
var originalPetInfo [2]model.PetInfo
|
||||
//复制属性
|
||||
originalProps[0], originalProps[1] = f.Our.Prop, f.Opp.Prop //先复制能力提升
|
||||
originalPetInfo[0], originalPetInfo[1] = f.Our.CurrentPet.Info, f.Opp.CurrentPet.Info //先复制宠物信息
|
||||
originalProps[0], originalProps[1] = f.Our[0].Prop, f.Opp[0].Prop //先复制能力提升
|
||||
originalPetInfo[0], originalPetInfo[1] = f.Our[0].CurrentPet[0].Info, f.Opp[0].CurrentPet[0].Info //先复制宠物信息
|
||||
attacker.Exec(func(effect input.Effect) bool {
|
||||
//计算变威力
|
||||
effect.Ctx().SkillEntity = skill
|
||||
@@ -55,8 +55,8 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
|
||||
}
|
||||
|
||||
//还原属性
|
||||
f.Our.Prop, f.Opp.Prop = originalProps[0], originalProps[1]
|
||||
f.Our.CurrentPet.Info, f.Opp.CurrentPet.Info = originalPetInfo[0], originalPetInfo[1]
|
||||
f.Our[0].Prop, f.Opp[0].Prop = originalProps[0], originalProps[1]
|
||||
f.Our[0].CurrentPet[0].Info, f.Opp[0].CurrentPet[0].Info = originalPetInfo[0], originalPetInfo[1]
|
||||
|
||||
if attacker.IsCritical == 1 { //命中了才有暴击
|
||||
//暴击破防
|
||||
@@ -120,6 +120,13 @@ func (f *FightC) copySkill(action *action.SelectSkillAction) *info.SkillEntity {
|
||||
return originalSkill.(*info.SkillEntity)
|
||||
}
|
||||
|
||||
func (f *FightC) getSkillParticipants(skillAction *action.SelectSkillAction) (*input.Input, *input.Input) {
|
||||
if skillAction == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return f.GetInputByAction(skillAction, false), f.GetInputByAction(skillAction, true)
|
||||
}
|
||||
|
||||
// enterturn 处理战斗回合逻辑
|
||||
// 回合有先手方和后手方,同时有攻击方和被攻击方
|
||||
func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction) {
|
||||
@@ -143,13 +150,13 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
|
||||
if firstAttack != nil { //如果首技能是空的,说明都空过了
|
||||
if firstAttack.GetPlayerID() == f.ownerID {
|
||||
//是否miss都应该施加解析effect
|
||||
f.Our.Parseskill(firstAttack) //解析到临时数据
|
||||
f.Opp.Parseskill(secondAttack) //解析到临时数据
|
||||
} else {
|
||||
f.Opp.Parseskill(firstAttack)
|
||||
f.Our.Parseskill(secondAttack)
|
||||
firstAttacker, _ := f.getSkillParticipants(firstAttack)
|
||||
if firstAttacker != nil {
|
||||
firstAttacker.Parseskill(firstAttack)
|
||||
}
|
||||
secondAttacker, _ := f.getSkillParticipants(secondAttack)
|
||||
if secondAttacker != nil {
|
||||
secondAttacker.Parseskill(secondAttack)
|
||||
}
|
||||
}
|
||||
f.Broadcast(func(fighter *input.Input) {
|
||||
@@ -159,11 +166,21 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
fighter.ResetAttackValue()
|
||||
})
|
||||
f.First, f.Second = f.Our, f.Opp
|
||||
if firstAttack != nil {
|
||||
if firstAttack.GetPlayerID() != f.ownerID {
|
||||
f.First, f.Second = f.Opp, f.Our // 攻击方为对方时,主攻击方是对方
|
||||
}
|
||||
f.First, f.Second = f.primaryOur(), f.primaryOpp()
|
||||
switch {
|
||||
case firstAttack != nil && secondAttack != nil:
|
||||
f.First, _ = f.getSkillParticipants(firstAttack)
|
||||
f.Second, _ = f.getSkillParticipants(secondAttack)
|
||||
case firstAttack != nil:
|
||||
f.First, f.Second = f.getSkillParticipants(firstAttack)
|
||||
case secondAttack != nil:
|
||||
f.First, f.Second = f.getSkillParticipants(secondAttack)
|
||||
}
|
||||
if f.First == nil {
|
||||
f.First = f.primaryOur()
|
||||
}
|
||||
if f.Second == nil {
|
||||
f.Second = f.primaryOpp()
|
||||
}
|
||||
|
||||
if firstAttack != nil && secondAttack != nil {
|
||||
@@ -217,7 +234,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
return effect.ActionStart(firstAttack, secondAttack)
|
||||
})
|
||||
|
||||
canUse := canUseSkill && action.CanUse(currentSkill) && attacker.CurrentPet.Info.Hp > 0
|
||||
canUse := canUseSkill && action.CanUse(currentSkill) && attacker.CurrentPet[0].Info.Hp > 0
|
||||
|
||||
if !canUse {
|
||||
|
||||
@@ -240,7 +257,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
f.processSkillAttack(attacker, defender, currentSkill)
|
||||
currentSkill = originalSkill //还原技能
|
||||
|
||||
_, skill, ok := utils.FindWithIndex(attacker.CurrentPet.Info.SkillList, func(item model.SkillInfo) bool {
|
||||
_, skill, ok := utils.FindWithIndex(attacker.CurrentPet[0].Info.SkillList, func(item model.SkillInfo) bool {
|
||||
return item.ID == currentSkill.Info.ID
|
||||
})
|
||||
if ok {
|
||||
@@ -253,7 +270,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
skill.Use(usecount)
|
||||
}
|
||||
}
|
||||
if defender.CurrentPet.Info.Hp > 0 {
|
||||
if defender.CurrentPet[0].Info.Hp > 0 {
|
||||
//技能使用后
|
||||
defender.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
@@ -262,7 +279,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
}
|
||||
|
||||
if attacker.CurrentPet.Info.Hp > 0 {
|
||||
if attacker.CurrentPet[0].Info.Hp > 0 {
|
||||
//技能使用后
|
||||
attacker.Exec(func(effect input.Effect) bool { //技能使用后的我方效果
|
||||
effect.Ctx().SkillEntity = currentSkill
|
||||
@@ -283,16 +300,16 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
return true
|
||||
})
|
||||
|
||||
if defender.CurrentPet.Info.Hp <= 0 && attacker.CurrentPet.Info.Hp <= 0 { //先手方死亡,触发反同归于尽
|
||||
attacker.CurrentPet.Info.Hp = 1
|
||||
if defender.CurrentPet[0].Info.Hp <= 0 && attacker.CurrentPet[0].Info.Hp <= 0 { //先手方死亡,触发反同归于尽
|
||||
attacker.CurrentPet[0].Info.Hp = 1
|
||||
}
|
||||
if defender.CurrentPet.Info.Hp <= 0 {
|
||||
if defender.CurrentPet[0].Info.Hp <= 0 {
|
||||
|
||||
f.TURNOVER(defender)
|
||||
|
||||
break
|
||||
}
|
||||
if attacker.CurrentPet.Info.Hp <= 0 {
|
||||
if attacker.CurrentPet[0].Info.Hp <= 0 {
|
||||
f.TURNOVER(attacker)
|
||||
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user