From 2c2e68ff93fd41100ccd2ea0a688e8ad88358969 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 2 Apr 2023 19:36:28 -0700 Subject: [PATCH] Fix shadowing bug in rules engine. --- cardsim/rules.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cardsim/rules.go b/cardsim/rules.go index 02d44e8..b98d071 100644 --- a/cardsim/rules.go +++ b/cardsim/rules.go @@ -141,7 +141,7 @@ func (r *RuleCollection[C]) performInsert(k *keyedRule[C]) { r.rules[k.id] = k s := r.byStep[k.Step()] - if s == nil { + if len(s) == 0 { r.steps = nil } s = append(s, k.id) @@ -326,7 +326,7 @@ func (r *RuleCollection[C]) Run(p *Player[C]) error { steps := r.steps if steps == nil { // Step set changed, recalculate. - steps := make([]int, 0, len(r.byStep)) + steps = make([]int, 0, len(r.byStep)) for step := range r.byStep { steps = append(steps, step) }