refactor: 优化先手判断逻辑,增加IsFirst接口
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -12,7 +12,7 @@ type Effect173 struct {
|
||||
|
||||
func (e *Effect173) OnSkill() bool {
|
||||
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
|
||||
if e.IsFirst() { // 先出手
|
||||
chance := e.Args()[0].IntPart()
|
||||
success, _, _ := e.Input.Player.Roll(int(chance), 100)
|
||||
if success {
|
||||
|
||||
@@ -11,7 +11,7 @@ type Effect196 struct {
|
||||
}
|
||||
|
||||
func (e *Effect196) OnSkill() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
|
||||
if e.IsFirst() { // 先出手
|
||||
chance := e.Args()[4].IntPart() // j%
|
||||
effectValue := e.Args()[5].IntPart() // 等级-k
|
||||
success, _, _ := e.Input.Player.Roll(int(chance), 100)
|
||||
|
||||
@@ -14,7 +14,7 @@ type Effect458 struct {
|
||||
}
|
||||
|
||||
func (e *Effect458) SkillHit_ex() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
|
||||
if e.IsFirst() { // 先出手
|
||||
damageDone := e.Ctx().Our.SumDamage
|
||||
healPercent := e.Args()[0].Div(alpacadecimal.NewFromInt(100)) // n%
|
||||
healAmount := damageDone.Mul(healPercent)
|
||||
|
||||
@@ -37,7 +37,7 @@ func (e *Effect471) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
||||
return true
|
||||
}
|
||||
func (e *Effect471) OnSkill() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
|
||||
if e.IsFirst() { // 先出手
|
||||
e.can = true
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ type Effect476 struct {
|
||||
}
|
||||
|
||||
func (e *Effect476) OnSkill() bool {
|
||||
if !e.Input.FightC.IsFirst(e.Input.Player) {
|
||||
if e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
healAmount := alpacadecimal.NewFromInt(int64(e.Args()[0].IntPart()))
|
||||
|
||||
@@ -11,8 +11,8 @@ type Effect561 struct {
|
||||
can bool
|
||||
}
|
||||
|
||||
func (e *Effect561) Action_end_ex() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) {
|
||||
func (e *Effect561) Skill_Use_ex() bool {
|
||||
if e.IsFirst() {
|
||||
if e.Ctx().Our.CurrentPet.GetHP().IntPart() == 0 {
|
||||
e.Ctx().Our.CurrentPet.Info.Hp = e.Ctx().Our.CurrentPet.Info.MaxHp
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ type Effect122 struct {
|
||||
|
||||
func (e *Effect122) OnSkill() bool {
|
||||
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) == e.isfrist {
|
||||
if e.IsFirst() == e.isfrist {
|
||||
propIndex := int(e.Args()[0].IntPart())
|
||||
chance := int(e.Args()[1].IntPart())
|
||||
changeAmount := int(e.Args()[2].IntPart())
|
||||
|
||||
@@ -15,7 +15,7 @@ type Effect147 struct {
|
||||
|
||||
func (e *Effect147) OnSkill() bool {
|
||||
|
||||
if e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) {
|
||||
if e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
chance := int(e.Args()[0].IntPart())
|
||||
@@ -44,7 +44,7 @@ type Effect148 struct {
|
||||
|
||||
func (e *Effect148) OnSkill() bool {
|
||||
|
||||
if e.Ctx().Our.FightC.IsFirst(e.Ctx().Our.Player) {
|
||||
if e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
propIndex := int(e.Args()[0].IntPart())
|
||||
|
||||
@@ -12,7 +12,7 @@ type Effect172 struct {
|
||||
}
|
||||
|
||||
func (e *Effect172) OnSkill() bool {
|
||||
if !e.Input.FightC.IsFirst(e.Input.Player) {
|
||||
if e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
damage := e.Ctx().Opp.SumDamage
|
||||
|
||||
@@ -25,7 +25,7 @@ type Effect405 struct {
|
||||
|
||||
func (e *Effect405) OnSkill() bool {
|
||||
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) == e.isfrist {
|
||||
if e.IsFirst() == e.isfrist {
|
||||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: e.Ctx().Opp.CurrentPet.GetHP().Div(e.Args()[0]),
|
||||
|
||||
@@ -28,7 +28,7 @@ func (e *Effect499) ActionStartEx(fattack, sattack *action.SelectSkillAction) bo
|
||||
return true
|
||||
}
|
||||
func (e *Effect499) OnSkill() bool {
|
||||
if e.Input.FightC.IsFirst(e.Input.Player) {
|
||||
if e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
e.can = true
|
||||
|
||||
@@ -34,7 +34,7 @@ func (e *Effect73) SetArgs(t *input.Input, a ...int) {
|
||||
}
|
||||
func (e *Effect73) Action_end_ex() bool {
|
||||
|
||||
if !e.Input.FightC.IsFirst(e.Ctx().Our.Player) {
|
||||
if !e.IsFirst() {
|
||||
return true
|
||||
}
|
||||
tt := &info.DamageZone{
|
||||
|
||||
@@ -220,17 +220,37 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
|
||||
attacker.RecoverEffect()
|
||||
currentSkill = nil
|
||||
if i == 0 {
|
||||
//不能使用,所以这时候取消后手
|
||||
defender.ReactvieEffect()
|
||||
firstAttack, secondAttack = secondAttack, firstAttack //互换先手权
|
||||
f.First, f.Second = f.Second, f.First
|
||||
//反转先后手
|
||||
originalSkill = f.copySkill(firstAttack)
|
||||
if i == 0 { //先手方被控,这时候应该算做未出手状态
|
||||
if canUse {
|
||||
f.TrueFirst = attacker
|
||||
|
||||
attacker.Exec(func(effect input.Effect) bool {
|
||||
effect.IsFirst(true)
|
||||
return true
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
f.TrueFirst = defender
|
||||
defender.Exec(func(effect input.Effect) bool {
|
||||
effect.IsFirst(true)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
currentSkill = originalSkill
|
||||
attacker, defender = defender, attacker
|
||||
}
|
||||
//先手权不一定出手
|
||||
// if i == 0 {
|
||||
// //不能使用,所以这时候取消后手
|
||||
// defender.ReactvieEffect()
|
||||
// firstAttack, secondAttack = secondAttack, firstAttack //互换先手权
|
||||
// f.First, f.Second = f.Second, f.First
|
||||
// //反转先后手
|
||||
// originalSkill = f.copySkill(firstAttack)
|
||||
|
||||
// currentSkill = originalSkill
|
||||
// attacker, defender = defender, attacker
|
||||
// }
|
||||
|
||||
} else {
|
||||
f.processSkillAttack(attacker, defender, currentSkill)
|
||||
@@ -297,6 +317,10 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
|
||||
})
|
||||
ff.GenInfo()
|
||||
})
|
||||
if f.TrueFirst != f.First {
|
||||
f.First, f.Second = f.Second, f.First
|
||||
|
||||
}
|
||||
|
||||
attackValueResult := info.AttackValueS{
|
||||
FAttack: *f.First.AttackValue,
|
||||
|
||||
@@ -37,10 +37,10 @@ type FightC struct {
|
||||
StartTime time.Time
|
||||
actionChan chan action.BattleActionI // 所有操作统一从这里进入
|
||||
|
||||
quit chan struct{}
|
||||
over chan struct{}
|
||||
First *input.Input
|
||||
//TrueFirst *input.Input
|
||||
quit chan struct{}
|
||||
over chan struct{}
|
||||
First *input.Input
|
||||
TrueFirst *input.Input
|
||||
Second *input.Input
|
||||
closefight bool
|
||||
overl sync.Once
|
||||
@@ -96,11 +96,11 @@ func (f *FightC) GetRand() *rand.Rand {
|
||||
|
||||
}
|
||||
|
||||
// 获取随机数
|
||||
// // 获取随机数
|
||||
func (f *FightC) IsFirst(play common.PlayerI) bool {
|
||||
|
||||
return f.First.Player == play
|
||||
}
|
||||
return f.TrueFirst.Player == play
|
||||
}
|
||||
func (f *FightC) Chat(c common.PlayerI, msg string) {
|
||||
|
||||
f.GetInputByPlayer(c, true).Player.SendPackCmd(50002, &user.ChatOutboundInfo{
|
||||
|
||||
@@ -66,6 +66,7 @@ type Effect interface {
|
||||
Duration(...int) int
|
||||
//Hit(...bool) bool
|
||||
Alive(...bool) bool
|
||||
IsFirst(...bool) bool
|
||||
Stack(...int) int
|
||||
CanStack(...bool) bool
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ type EffectNode struct {
|
||||
Input *input.Input
|
||||
stacks int // 当前层数
|
||||
id input.EffectIDCombiner
|
||||
canStack bool // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果 ,异常和能力的叠层
|
||||
canStack bool // 最大叠加层数 ,正常都是不允许叠加的,除了衰弱特殊效果 ,异常和能力的叠层
|
||||
isFirst bool
|
||||
SideEffectArgs []int // 附加效果参数
|
||||
// owner bool //是否作用自身
|
||||
Success bool // 是否执行成功 成功XXX,失败XXX
|
||||
@@ -86,6 +87,14 @@ func (e *EffectNode) CanStack(t ...bool) bool {
|
||||
}
|
||||
return e.canStack
|
||||
|
||||
}
|
||||
func (e *EffectNode) IsFirst(t ...bool) bool {
|
||||
|
||||
if len(t) > 0 {
|
||||
e.isFirst = t[0]
|
||||
}
|
||||
return e.isFirst
|
||||
|
||||
}
|
||||
|
||||
// 回合类改成int.max,然后魂印类重写切换精灵替换
|
||||
|
||||
Reference in New Issue
Block a user