diff --git a/game/src/ai/prompts/execution_prompts.rs b/game/src/ai/prompts/execution_prompts.rs index 45c4cfa..2fa7c3b 100644 --- a/game/src/ai/prompts/execution_prompts.rs +++ b/game/src/ai/prompts/execution_prompts.rs @@ -9,6 +9,7 @@ use crate::models::world::scenes::{Exit, Prop, Scene, Stage}; use crate::models::Insertable; use gbnf::prelude::limit::{GbnfLimitedComplex, GbnfLimitedPrimitive}; use itertools::Itertools; +use std::sync::OnceLock; use strum::VariantNames; use tabled::settings::Style; use tabled::{Table, Tabled}; @@ -19,6 +20,16 @@ const ITEM: &'static str = "item"; const PROP: &'static str = "prop"; const NO_KEY: &'static str = "n/a"; +fn valid_event_names() -> &'static Vec { + static CELL: OnceLock> = OnceLock::new(); + CELL.get_or_init(|| { + CommandEvent::VARIANTS + .into_iter() + .map(|e| e.to_string()) + .collect() + }) +} + #[derive(Tabled)] struct EntityTableRow<'a> { name: &'a str, @@ -249,6 +260,7 @@ fn execution_gbnf_limit<'a>(stage: &'a Stage) -> RawCommandExecutionGbnfLimit { applies_to.push("self".to_string()); let event_limit = RawCommandEventGbnfLimit { + event_name: GbnfLimitedPrimitive::new(valid_event_names().to_owned()), applies_to: GbnfLimitedPrimitive::new(applies_to), parameter: GbnfLimitedPrimitive::new(all_uuids), }; diff --git a/game/src/models/commands.rs b/game/src/models/commands.rs index 90d08ef..a6e4efd 100644 --- a/game/src/models/commands.rs +++ b/game/src/models/commands.rs @@ -79,9 +79,12 @@ impl RawCommandExecution { #[derive(Debug, Serialize, Deserialize, Clone, Gbnf)] #[serde(rename_all = "snake_case")] pub struct RawCommandEvent { + #[gbnf_limit_primitive] pub event_name: String, + #[gbnf_limit_primitive] pub applies_to: String, + #[gbnf_limit_primitive] pub parameter: String, }