From ecba7f726f70b37126d852c38c7e3eec7b04d730 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 9 Jul 2026 22:15:54 -0400 Subject: feat: old standalone trigger systems completely unified into trigger->condition->action system --- internal/game/act.go | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'internal/game/act.go') diff --git a/internal/game/act.go b/internal/game/act.go index 1fc2b1c..352f235 100644 --- a/internal/game/act.go +++ b/internal/game/act.go @@ -235,8 +235,6 @@ func (g *Game) AdvanceActions() { g.advanceTalk(sess, p) case behavior.TypeTriggerModule: g.advanceTriggerModule(sess, p) - case behavior.TypeInteractionSeq: - g.advanceInteractionSeq(sess, p) case behavior.TypeCombine: g.advanceCombine(sess, p) default: @@ -302,6 +300,13 @@ func (g *Game) checkCondition(sess *net.Session, c *behavior.Condition) bool { val, present := g.GlobalFlags.Get(c.GlobalFlag) return flagMatches(present, val, c.Value, c.Not) } + if c.Room != 0 { + has := p != nil && p.RoomID == c.Room + if c.Not { + return !has + } + return has + } if c.HasItem != "" { has := p != nil && p.HasItem(c.HasItem) if c.Not { @@ -319,6 +324,44 @@ func (g *Game) checkCondition(sess *net.Session, c *behavior.Condition) bool { return true } +// checkConditionGlobal evaluates a condition without a player session. +// Only global_flag predicates (plus all_of/any_of/not composition) are evaluated. +// Room, player_flag, has_item, and min_credits are player-dependent: Room passes +// (it is used as a reference-room selector, not a gate), and the rest fail. +func (g *Game) checkConditionGlobal(c *behavior.Condition) bool { + if c.AllOf != nil { + for _, sub := range c.AllOf { + if !g.checkConditionGlobal(&sub) { + return false + } + } + return true + } + if c.AnyOf != nil { + for _, sub := range c.AnyOf { + if g.checkConditionGlobal(&sub) { + return true + } + } + return false + } + + if c.GlobalFlag != "" { + val, present := g.GlobalFlags.Get(c.GlobalFlag) + return flagMatches(present, val, c.Value, c.Not) + } + if c.PlayerFlag != "" { + return c.Not + } + if c.HasItem != "" { + return c.Not + } + if c.MinCredits > 0 { + return c.Not + } + return true +} + // flagMatches evaluates a global_flag/player_flag condition. The name is // historical; it evaluates both flag types. // -- cgit v1.2.3