Skip to content

Commit

Permalink
Merge pull request #2220 from jarveson/jake/exclusive-overwrite
Browse files Browse the repository at this point in the history
ee: dont overwrite same priority with less duration
  • Loading branch information
jarveson authored Dec 22, 2022
2 parents f9b2af5 + 4a5bab4 commit 4cb6b16
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sim/core/exclusive_effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (ee *ExclusiveEffect) Activate(sim *Simulation) bool {
return true
}

if ee.Category.SingleAura && ee.Category.activeEffect != nil && ee.Category.activeEffect != ee && ee.Category.activeEffect.Priority > ee.Priority {
if ee.Category.SingleAura && ee.Category.activeEffect != nil && ee.Category.activeEffect != ee && (ee.Category.activeEffect.Priority > ee.Priority || (ee.Priority == ee.Category.activeEffect.Priority && ee.Category.activeEffect.Aura.RemainingDuration(sim) > ee.Aura.Duration)) {
return false
}

Expand Down
56 changes: 56 additions & 0 deletions sim/core/exclusive_effect_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package core

import (
"testing"
"time"
)

func TestSingleAuraExclusiveDurationNoOverwrite(t *testing.T) {
sim := &Simulation{}

target := Unit{
Type: EnemyUnit,
Index: 0,
Level: 83,
auraTracker: newAuraTracker(),
}
mangle := MangleAura(&target)
trauma := MakePermanent(TraumaAura(&target, 2))

// Trauma in this case should *never* be overwritten
// as its duration from 'MakePermanent' should make it non overwritable by 1 min duration mangles
trauma.Activate(sim)

sim.CurrentTime = 1 * time.Second

mangle.Activate(sim)

if !(trauma.IsActive() && !mangle.IsActive()) {
t.Fatalf("lower duration exclusive aura overwrote previous!")
}
}

func TestSingleAuraExclusiveDurationOverwrite(t *testing.T) {
sim := &Simulation{}

target := Unit{
Type: EnemyUnit,
Index: 0,
Level: 83,
auraTracker: newAuraTracker(),
}
mangle := MangleAura(&target)
trauma := TraumaAura(&target, 2)

trauma.Activate(sim)

sim.CurrentTime = 1 * time.Second

mangle.Activate(sim)

// In this case mangle should overwrite trauma as mangle will give a greater duration

if !(mangle.IsActive() && !trauma.IsActive()) {
t.Fatalf("longer duration exclusive aura failed to overwrite")
}
}

0 comments on commit 4cb6b16

Please sign in to comment.