From d02f0d2cdf67f1445a9ccae86b99a2578adab585 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 10 Jul 2026 17:02:13 -0400 Subject: feat(admin): update search to use standard condition/action framework rather than bespoke implementation --- internal/behavior/behavior.go | 51 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'internal/behavior/behavior.go') diff --git a/internal/behavior/behavior.go b/internal/behavior/behavior.go index 75f836b..9152f8c 100644 --- a/internal/behavior/behavior.go +++ b/internal/behavior/behavior.go @@ -55,21 +55,22 @@ type TalkOption struct { // scheduler and ignores the per-step Condition (its gating is done at the // parent Trigger level instead). type Step struct { - Condition *Condition `yaml:"condition,omitempty"` - Wait int `yaml:"wait,omitempty"` - Messages []string `yaml:"messages,omitempty"` - Broadcast string `yaml:"broadcast,omitempty"` - BroadcastGlobal string `yaml:"broadcast_global,omitempty"` - SpawnMob *SpawnMobConfig `yaml:"spawn_mob,omitempty"` - DespawnMob string `yaml:"despawn_mob,omitempty"` - SetGlobalFlags map[string]any `yaml:"set_global_flags,omitempty"` - SetPlayerFlags map[string]any `yaml:"set_player_flags,omitempty"` - GiveItem string `yaml:"give_item,omitempty"` - TakeItem string `yaml:"take_item,omitempty"` - Teleport int `yaml:"teleport,omitempty"` - Heal int `yaml:"heal,omitempty"` - Credits int `yaml:"credits,omitempty"` - ApsNode bool `yaml:"aps_node,omitempty"` + Condition *Condition `yaml:"condition,omitempty" json:"condition,omitempty"` + Wait int `yaml:"wait,omitempty" json:"wait,omitempty"` + Messages []string `yaml:"messages,omitempty" json:"messages,omitempty"` + Broadcast string `yaml:"broadcast,omitempty" json:"broadcast,omitempty"` + BroadcastGlobal string `yaml:"broadcast_global,omitempty" json:"broadcast_global,omitempty"` + SpawnMob *SpawnMobConfig `yaml:"spawn_mob,omitempty" json:"spawn_mob,omitempty"` + DespawnMob string `yaml:"despawn_mob,omitempty" json:"despawn_mob,omitempty"` + SetGlobalFlags map[string]any `yaml:"set_global_flags,omitempty" json:"set_global_flags,omitempty"` + SetPlayerFlags map[string]any `yaml:"set_player_flags,omitempty" json:"set_player_flags,omitempty"` + GiveItem string `yaml:"give_item,omitempty" json:"give_item,omitempty"` + TakeItem string `yaml:"take_item,omitempty" json:"take_item,omitempty"` + Teleport int `yaml:"teleport,omitempty" json:"teleport,omitempty"` + Heal int `yaml:"heal,omitempty" json:"heal,omitempty"` + Credits int `yaml:"credits,omitempty" json:"credits,omitempty"` + ApsNode bool `yaml:"aps_node,omitempty" json:"aps_node,omitempty"` + DropTable []DropEntry `yaml:"drop_table,omitempty" json:"drop_table,omitempty"` } // HasEffects reports whether the step carries any effect beyond a pure wait. @@ -78,7 +79,7 @@ func (s Step) HasEffects() bool { s.SpawnMob != nil || s.DespawnMob != "" || len(s.SetGlobalFlags) > 0 || len(s.SetPlayerFlags) > 0 || s.GiveItem != "" || s.TakeItem != "" || s.Teleport != 0 || s.Heal != 0 || - s.Credits != 0 || s.ApsNode + s.Credits != 0 || s.ApsNode || len(s.DropTable) > 0 } // Trigger is the one conditional wrapper used by every event block in the @@ -211,13 +212,13 @@ func (c *ShopConfig) FindItem(itemID string) *ShopItem { // Not inverter. Room matches when the triggering player is currently in that // room (ignored for global-flag triggers with no player). type Condition struct { - GlobalFlag string `yaml:"global_flag,omitempty"` - PlayerFlag string `yaml:"player_flag,omitempty"` - Room int `yaml:"room,omitempty"` - Value any `yaml:"value,omitempty"` - Not bool `yaml:"not,omitempty"` - HasItem string `yaml:"has_item,omitempty"` - MinCredits int `yaml:"min_credits,omitempty"` - AllOf []Condition `yaml:"all_of,omitempty"` - AnyOf []Condition `yaml:"any_of,omitempty"` + GlobalFlag string `yaml:"global_flag,omitempty" json:"global_flag,omitempty"` + PlayerFlag string `yaml:"player_flag,omitempty" json:"player_flag,omitempty"` + Room int `yaml:"room,omitempty" json:"room,omitempty"` + Value any `yaml:"value,omitempty" json:"value,omitempty"` + Not bool `yaml:"not,omitempty" json:"not,omitempty"` + HasItem string `yaml:"has_item,omitempty" json:"has_item,omitempty"` + MinCredits int `yaml:"min_credits,omitempty" json:"min_credits,omitempty"` + AllOf []Condition `yaml:"all_of,omitempty" json:"all_of,omitempty"` + AnyOf []Condition `yaml:"any_of,omitempty" json:"any_of,omitempty"` } -- cgit v1.2.3