diff options
| author | historia <[not public]> | 2026-07-09 05:27:10 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-09 05:27:10 -0400 |
| commit | c705ae942573984784ef501bf8198f61f5206ddd (patch) | |
| tree | c964066f3a244002bf75cb50a877630f46496f81 /internal/game/act.go | |
| parent | 74153c7814fc4cef988066ef04e38731a943bc12 (diff) | |
| download | thehouseoficarus-c705ae942573984784ef501bf8198f61f5206ddd.tar.gz | |
refactor: simplify yaml, remove support for old scalar fields
Diffstat (limited to 'internal/game/act.go')
| -rw-r--r-- | internal/game/act.go | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/internal/game/act.go b/internal/game/act.go index ddeed04..91f05a8 100644 --- a/internal/game/act.go +++ b/internal/game/act.go @@ -7,6 +7,7 @@ import ( "strings" "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/engine" "thehouseoficarus/internal/net" "thehouseoficarus/internal/object" "thehouseoficarus/internal/player" @@ -332,7 +333,7 @@ func flagMatches(present bool, val, want any, not bool) bool { if want == nil { match = present && isTruthy(val) } else { - match = present && valuesEqual(val, want) + match = present && engine.ValuesEqual(val, want) } if not { return !match @@ -340,31 +341,6 @@ func flagMatches(present bool, val, want any, not bool) bool { return match } -// valuesEqual compares two any-typed values, normalizing numeric types (int, -// int64, float64) so that e.g. int(3) == int64(3) == float64(3). Non-numeric -// types fall back to ==. -func valuesEqual(a, b any) bool { - ai, aok := numericValue(a) - bi, bok := numericValue(b) - if aok && bok { - return ai == bi - } - return a == b -} - -// numericValue returns the value as a float64 if it is a numeric type. -func numericValue(v any) (float64, bool) { - switch x := v.(type) { - case int: - return float64(x), true - case int64: - return float64(x), true - case float64: - return x, true - } - return 0, false -} - func isTruthy(v any) bool { switch x := v.(type) { case nil: |
