diff options
Diffstat (limited to 'internal/game/act.go')
| -rw-r--r-- | internal/game/act.go | 47 |
1 files changed, 45 insertions, 2 deletions
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. // |
