From 42ea61b9f4b0a7ea0d1d298c3ffa4a6bdee9e8c5 Mon Sep 17 00:00:00 2001 From: Nathan OGER Date: Sun, 11 Oct 2026 20:03:05 +0200 Subject: [PATCH 1/5] feat(core): parse the coordinate grammar of /zaap --- crates/zaapy-core/src/command.rs | 91 ++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/crates/zaapy-core/src/command.rs b/crates/zaapy-core/src/command.rs index 9c1609f..679ade1 100644 --- a/crates/zaapy-core/src/command.rs +++ b/crates/zaapy-core/src/command.rs @@ -47,11 +47,12 @@ pub enum GameCommand { x: i32, y: i32, }, - /// Announced by Ankama but not yet live in game. Parsed so that enabling it - /// later is a configuration switch rather than a redesign; the argument - /// grammar is intentionally loose until the real one exists. + /// Teleport to the zaap nearest `x,y`. Guides may chain a `/travel` for the + /// last leg, which the game runs once the teleport lands. Zaap { - destination: String, + x: i32, + y: i32, + then: Option<(i32, i32)>, }, Item { name: String, @@ -74,7 +75,12 @@ impl GameCommand { pub fn canonical(&self) -> String { match self { GameCommand::Travel { x, y } => format!("/travel {x},{y}"), - GameCommand::Zaap { destination } => format!("/zaap {destination}"), + GameCommand::Zaap { x, y, then: None } => format!("/zaap {x} {y}"), + GameCommand::Zaap { + x, + y, + then: Some((tx, ty)), + } => format!("/zaap {x} {y} ; /travel {tx} {ty}"), GameCommand::Item { name } => name.clone(), } } @@ -134,7 +140,12 @@ pub fn parse(raw: &str) -> Result { } fn parse_travel(args: &str) -> Result { - let bad = || Rejection::BadArguments { verb: Verb::Travel }; + let (x, y) = parse_coordinates(args, Verb::Travel)?; + Ok(GameCommand::Travel { x, y }) +} + +fn parse_coordinates(args: &str, verb: Verb) -> Result<(i32, i32), Rejection> { + let bad = || Rejection::BadArguments { verb }; // Guides write `1,2`; the treasure-hunt overlay writes `1 2`. let (x, y) = match args.split_once(',') { Some((x, y)) => (x.trim(), y.trim()), @@ -145,25 +156,23 @@ fn parse_travel(args: &str) -> Result { if x.abs() > COORDINATE_BOUND || y.abs() > COORDINATE_BOUND { return Err(bad()); } - Ok(GameCommand::Travel { x, y }) + Ok((x, y)) } +/// `/zaap x y`, optionally chained with `; /travel x y` — and nothing else may +/// follow the `;`, since the game runs whatever command sits there. fn parse_zaap(args: &str) -> Result { - let bad = || Rejection::BadArguments { verb: Verb::Zaap }; - if args.is_empty() { - return Err(bad()); - } - // Until the real grammar ships, accept what a place name plausibly contains - // and nothing that could be read as punctuation by the chat parser. - let acceptable = args - .chars() - .all(|c| c.is_alphanumeric() || matches!(c, ' ' | '-' | '_' | '\'' | ',')); - if !acceptable { - return Err(bad()); - } - Ok(GameCommand::Zaap { - destination: args.to_string(), - }) + let (head, tail) = match args.split_once(';') { + Some((head, tail)) => (head, Some(tail)), + None => (args, None), + }; + let (x, y) = parse_coordinates(head.trim(), Verb::Zaap)?; + let then = match tail.map(parse) { + None => None, + Some(Ok(GameCommand::Travel { x, y })) => Some((x, y)), + Some(_) => return Err(Rejection::BadArguments { verb: Verb::Zaap }), + }; + Ok(GameCommand::Zaap { x, y, then }) } /// Text with no letter in it — a number, a stray symbol — is not an item name. @@ -293,17 +302,45 @@ mod tests { } #[test] - fn parses_zaap_ahead_of_its_release() { + fn accepts_ganymede_zaap_commands() { assert_eq!( - parse("/zaap Astrub"), + parse("/zaap 5 7"), Ok(GameCommand::Zaap { - destination: "Astrub".to_string() + x: 5, + y: 7, + then: None }) ); + let chained = parse("/zaap -31 -56 ; /travel -32 -57").unwrap(); assert_eq!( - parse("/zaap"), - Err(Rejection::BadArguments { verb: Verb::Zaap }) + chained, + GameCommand::Zaap { + x: -31, + y: -56, + then: Some((-32, -57)) + } ); + assert_eq!(parse(&chained.canonical()), Ok(chained)); + } + + #[test] + fn rejects_malformed_zaap_commands() { + for payload in [ + "/zaap", + "/zaap Astrub", + "/zaap 1 2 ;", + "/zaap 1 2 ; /who", + "/zaap 1 2 ; /zaap 3 4", + "/zaap 1 2 ; /travel 3 4 ; /travel 5 6", + "/zaap 1 2 ; Bottes", + "/zaap 99999 0", + ] { + assert_eq!( + parse(payload), + Err(Rejection::BadArguments { verb: Verb::Zaap }), + "payload: {payload}" + ); + } } #[test] From 5170cac29e06159928edacb56ccff9fa20a75765 Mon Sep 17 00:00:00 2001 From: Nathan OGER Date: Sun, 11 Oct 2026 20:03:05 +0200 Subject: [PATCH 2/5] feat(core): enable /zaap by default --- crates/zaapy-core/src/bridge.rs | 2 +- crates/zaapy-core/src/config.rs | 28 +++++++++++++++++++------ crates/zaapy-core/tests/bridge.rs | 34 ++++++++++++++++--------------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/crates/zaapy-core/src/bridge.rs b/crates/zaapy-core/src/bridge.rs index ecf1e6d..88c687f 100644 --- a/crates/zaapy-core/src/bridge.rs +++ b/crates/zaapy-core/src/bridge.rs @@ -65,7 +65,7 @@ pub enum IgnoreReason { verb: Verb, foreground: Option, }, - /// A known command the user has switched off — `/zaap` until it ships. + /// A known command the user has switched off. CommandDisabled { verb: Verb, }, diff --git a/crates/zaapy-core/src/config.rs b/crates/zaapy-core/src/config.rs index 1c10f48..03f550e 100644 --- a/crates/zaapy-core/src/config.rs +++ b/crates/zaapy-core/src/config.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; use crate::command::Verb; use crate::platform::{Key, Modifier, SendStep, WindowRef}; -pub const CONFIG_VERSION: u32 = 1; +pub const CONFIG_VERSION: u32 = 2; /// Bounds on the focus confirmation wait. Below the floor the game has no time /// to come forward; above the ceiling the user is just staring at a frozen guide. @@ -77,6 +77,12 @@ impl Config { self.paste_sequence = default_paste_sequence(); } self.source_processes.retain(|name| !name.trim().is_empty()); + // Version 1 saved `/zaap` off while it was not in the game yet, behind a + // toggle the user could not reach. + if self.version < 2 { + self.commands.zaap = true; + } + self.version = CONFIG_VERSION; self } @@ -125,8 +131,6 @@ impl TargetSelector { #[serde(default)] pub struct EnabledCommands { pub travel: bool, - /// Off by default: the command does not exist in game yet, so relaying it - /// would only type a rejected line into the chat. pub zaap: bool, /// Item names clicked in Ganymède, pasted without opening the chat. pub items: bool, @@ -136,7 +140,7 @@ impl Default for EnabledCommands { fn default() -> Self { Self { travel: true, - zaap: false, + zaap: true, items: true, } } @@ -230,10 +234,22 @@ mod tests { } #[test] - fn zaap_stays_off_until_ankama_ships_it() { + fn travel_and_zaap_are_on_by_default() { let config = Config::default(); assert!(config.commands.allows(Verb::Travel)); - assert!(!config.commands.allows(Verb::Zaap)); + assert!(config.commands.allows(Verb::Zaap)); + } + + #[test] + fn zaap_is_switched_on_once_for_a_version_1_file() { + let saved = r#"{"version":1,"commands":{"travel":true,"zaap":false,"items":true}}"#; + let config = serde_json::from_str::(saved).unwrap().sanitised(); + assert!(config.commands.zaap); + assert_eq!(config.version, CONFIG_VERSION); + + let saved = r#"{"version":2,"commands":{"travel":true,"zaap":false,"items":true}}"#; + let config = serde_json::from_str::(saved).unwrap().sanitised(); + assert!(!config.commands.zaap); } #[test] diff --git a/crates/zaapy-core/tests/bridge.rs b/crates/zaapy-core/tests/bridge.rs index befcdb4..db40694 100644 --- a/crates/zaapy-core/tests/bridge.rs +++ b/crates/zaapy-core/tests/bridge.rs @@ -282,33 +282,35 @@ fn text_that_is_neither_a_command_nor_an_item_is_ignored() { } #[test] -fn zaap_is_recognised_but_not_relayed_until_it_ships() { +fn a_chained_zaap_is_relayed_through_the_chat() { let (rig, mut bridge) = armed(config()); - rig.clipboard.copy("/zaap Astrub"); + rig.clipboard.copy("/zaap -31 -56 ; /travel -32 -57"); let report = bridge.tick().unwrap(); - assert_eq!( + assert!(matches!( report.outcome, - Outcome::Ignored { - reason: IgnoreReason::CommandDisabled { verb: Verb::Zaap } - } - ); - assert!(rig.input.sends().is_empty()); + Outcome::Sent { ref command, .. } if command == "/zaap -31 -56 ; /travel -32 -57" + )); + assert_eq!(rig.input.sends(), vec![config().send_sequence]); } #[test] -fn enabling_zaap_is_a_single_switch() { +fn zaap_can_be_switched_off() { let mut config = config(); - config.commands.zaap = true; + config.commands.zaap = false; let (rig, mut bridge) = armed(config); - rig.clipboard.copy("/zaap Astrub"); - assert!(matches!( - bridge.tick().unwrap().outcome, - Outcome::Sent { .. } - )); - assert_eq!(rig.input.sends().len(), 1); + rig.clipboard.copy("/zaap 5 7"); + let report = bridge.tick().unwrap(); + + assert_eq!( + report.outcome, + Outcome::Ignored { + reason: IgnoreReason::CommandDisabled { verb: Verb::Zaap } + } + ); + assert!(rig.input.sends().is_empty()); } /// Clipboard notifications like to fire twice for one copy. From 9b72cd2269ae21c1f93d22fb91b6ada17f13f555 Mon Sep 17 00:00:00 2001 From: Nathan OGER Date: Sun, 11 Oct 2026 20:03:17 +0200 Subject: [PATCH 3/5] feat(panel): make the /zaap toggle live --- src/App.svelte | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index b4d2440..678298b 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -219,11 +219,17 @@ /> /travel - -