diff options
| author | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-25 15:40:48 -0400 |
| commit | abd612c15799f604e671e83dc7c410ed2b44185f (patch) | |
| tree | 0597ca92350de73aac2a7cf26b2f2d6595dac0cc /internal/game/condition_test.go | |
| parent | 2725e2927a1595c7b100d942d1f14146252adeb7 (diff) | |
| download | thehouseoficarus-abd612c15799f604e671e83dc7c410ed2b44185f.tar.gz | |
slop refactor
Diffstat (limited to 'internal/game/condition_test.go')
| -rw-r--r-- | internal/game/condition_test.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/internal/game/condition_test.go b/internal/game/condition_test.go index d932d18..f365f2e 100644 --- a/internal/game/condition_test.go +++ b/internal/game/condition_test.go @@ -3,7 +3,7 @@ package game import ( "testing" - "thehouseoficarus/internal/action" + "thehouseoficarus/internal/behavior" "thehouseoficarus/internal/net" "thehouseoficarus/internal/object" "thehouseoficarus/internal/player" @@ -45,7 +45,7 @@ func TestCheckConditionPlayerFlagTruthy(t *testing.T) { unset := sessWithFlags(map[string]any{}) // {player_flag: x} -> set means present+truthy - posCond := &action.Condition{PlayerFlag: "x"} + posCond := &behavior.Condition{PlayerFlag: "x"} if !g.checkCondition(set, posCond) { t.Error("expected positive flag check to pass when flag is true") } @@ -54,7 +54,7 @@ func TestCheckConditionPlayerFlagTruthy(t *testing.T) { } // {player_flag: x, not: true} -> negative - negCond := &action.Condition{PlayerFlag: "x", Not: true} + negCond := &behavior.Condition{PlayerFlag: "x", Not: true} if g.checkCondition(set, negCond) { t.Error("expected negative flag check to fail when flag is true") } @@ -76,13 +76,13 @@ func TestCheckConditionValueComparisonPreserved(t *testing.T) { g := &Game{Flags: NewFlagStore()} sess := sessWithFlags(map[string]any{"n": 1}) - if !g.checkCondition(sess, &action.Condition{PlayerFlag: "n", Value: 1}) { + if !g.checkCondition(sess, &behavior.Condition{PlayerFlag: "n", Value: 1}) { t.Error("value match should pass for equal int") } - if g.checkCondition(sess, &action.Condition{PlayerFlag: "n", Value: 2}) { + if g.checkCondition(sess, &behavior.Condition{PlayerFlag: "n", Value: 2}) { t.Error("value match should fail for unequal int") } - if !g.checkCondition(sess, &action.Condition{PlayerFlag: "n", Value: 2, Not: true}) { + if !g.checkCondition(sess, &behavior.Condition{PlayerFlag: "n", Value: 2, Not: true}) { t.Error("negated value match should pass for unequal int") } } @@ -92,13 +92,13 @@ func TestCheckConditionWorldFlag(t *testing.T) { g.Flags.Set("gate_open", true) sess := sessWithFlags(map[string]any{}) - if !g.checkCondition(sess, &action.Condition{Flag: "gate_open"}) { + if !g.checkCondition(sess, &behavior.Condition{Flag: "gate_open"}) { t.Error("world flag truthy check should pass") } - if g.checkCondition(sess, &action.Condition{Flag: "gate_open", Not: true}) { + if g.checkCondition(sess, &behavior.Condition{Flag: "gate_open", Not: true}) { t.Error("negated world flag should fail when set") } - if g.checkCondition(sess, &action.Condition{Flag: "missing"}) { + if g.checkCondition(sess, &behavior.Condition{Flag: "missing"}) { t.Error("missing world flag should not pass") } } @@ -107,9 +107,9 @@ func TestResolveObjDescPresence(t *testing.T) { g := &Game{Flags: NewFlagStore()} def := &object.ObjectDef{ - Descriptions: []object.ConditionalDesc{ - {Text: "lined", Condition: &action.Condition{PlayerFlag: "lined_up"}}, - {Text: "milling", Condition: &action.Condition{PlayerFlag: "lined_up", Not: true}}, + Description: behavior.DescList{ + {Text: "lined", Condition: &behavior.Condition{PlayerFlag: "lined_up"}}, + {Text: "milling", Condition: &behavior.Condition{PlayerFlag: "lined_up", Not: true}}, }, } @@ -124,16 +124,16 @@ func TestResolveObjDescPresence(t *testing.T) { // gated entirely off -> absent gated := &object.ObjectDef{ - Descriptions: []object.ConditionalDesc{ - {Text: "x", Condition: &action.Condition{PlayerFlag: "done", Not: true}}, + Description: behavior.DescList{ + {Text: "x", Condition: &behavior.Condition{PlayerFlag: "done", Not: true}}, }, } if _, present := g.resolveObjDesc(sessWithFlags(map[string]any{"done": true}), gated); present { t.Error("expected object to be absent when no variant matches") } - // plain object (no Descriptions) always present - plain := &object.ObjectDef{Description: "plain"} + // plain object always present + plain := &object.ObjectDef{Description: behavior.DescList{{Text: "plain"}}} if text, present := g.resolveObjDesc(sessWithFlags(nil), plain); !present || text != "plain" { t.Errorf("expected plain/present, got %q/%v", text, present) } @@ -142,9 +142,9 @@ func TestResolveObjDescPresence(t *testing.T) { func TestRoomDescriptionSelection(t *testing.T) { g := &Game{Flags: NewFlagStore()} room := &world.Room{ - Description: "empty pad", - Descriptions: []world.RoomDesc{ - {Text: "crowd", Condition: &action.Condition{PlayerFlag: "done", Not: true}}, + Description: behavior.DescList{ + {Text: "crowd", Condition: &behavior.Condition{PlayerFlag: "done", Not: true}}, + {Text: "empty pad"}, }, } if got := g.roomDescription(sessWithFlags(map[string]any{}), room); got != "crowd" { |
