Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["crates/zaapy-core", "crates/zaapy-platform", "src-tauri"]

[workspace.package]
version = "1.1.0"
version = "1.2.0"
edition = "2021"
license = "MIT"
repository = "https://github.com/Miniluchi/zaapy"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Download the latest version from the

| System | File |
| ------- | ----------------------------------------------------- |
| Windows | `Zaapy_1.1.0_x64-setup.exe` |
| macOS | `Zaapy_1.1.0_universal.dmg` (Intel and Apple Silicon) |
| Windows | `Zaapy_1.2.0_x64-setup.exe` |
| macOS | `Zaapy_1.2.0_universal.dmg` (Intel and Apple Silicon) |

Zaapy isn't code signed — the certificates cost more per year than this free
project does — so both systems will warn you the first time.
Expand Down Expand Up @@ -66,8 +66,8 @@ settings.
By default the Dofus chat keeps the keyboard after a command. Tick **Press
Escape** in the settings to hand it back to the game.

`/zaap` is greyed out for now. Ankama has announced the command but it does not
exist in the game yet; Zaapy will support it when it ships.
`/zaap` commands, chained `/travel` included, are relayed the same way. Turn
them off with **/zaap** in the settings.

## Privacy

Expand Down
2 changes: 1 addition & 1 deletion crates/zaapy-core/src/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum IgnoreReason {
verb: Verb,
foreground: Option<String>,
},
/// A known command the user has switched off — `/zaap` until it ships.
/// A known command the user has switched off.
CommandDisabled {
verb: Verb,
},
Expand Down
91 changes: 64 additions & 27 deletions crates/zaapy-core/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(),
}
}
Expand Down Expand Up @@ -134,7 +140,12 @@ pub fn parse(raw: &str) -> Result<GameCommand, Rejection> {
}

fn parse_travel(args: &str) -> Result<GameCommand, Rejection> {
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()),
Expand All @@ -145,25 +156,23 @@ fn parse_travel(args: &str) -> Result<GameCommand, Rejection> {
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<GameCommand, Rejection> {
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.
Expand Down Expand Up @@ -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]
Expand Down
28 changes: 22 additions & 6 deletions crates/zaapy-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand All @@ -136,7 +140,7 @@ impl Default for EnabledCommands {
fn default() -> Self {
Self {
travel: true,
zaap: false,
zaap: true,
items: true,
}
}
Expand Down Expand Up @@ -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::<Config>(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::<Config>(saved).unwrap().sanitised();
assert!(!config.commands.zaap);
}

#[test]
Expand Down
34 changes: 18 additions & 16 deletions crates/zaapy-core/tests/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ key's `i` marker, which is a mark in a line of text rather than a control —
fallback face.

Explanations too long for a label go in a native `title` tooltip, which both
WKWebView and WebView2 render themselves: the `/zaap` row says why it is greyed
out, and the chat key says which keybind it has to match. A tooltip nobody hovers
WKWebView and WebView2 render themselves: the Items row says where the name
lands, and the chat key says which keybind it has to match. A tooltip nobody hovers
is invisible, so the ones worth reading are marked.

Nothing is offered that cannot be acted on: `HostStatus::can_request_permission`
Expand Down
7 changes: 3 additions & 4 deletions docs/VISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ A Dofus 3 player following a Ganymède guide, on **Windows or macOS**, possibly
| macOS permissions | **Accessibility**, asked for from the settings window. The source gate works without it, so nothing is ever sent from an unpermitted install — the panel says what is missing instead |
| Trigger | Fully automatic and immediate, **gated**: the command is only bridged if Ganymède was the foreground window when it appeared in the clipboard |
| Source app | Ganymède **desktop app** (detected by process/window, no browser support) |
| Commands relayed | `/travel` today, from guides and from the treasure-hunt overlay; `/zaap` designed for but not active (see open questions) |
| Commands relayed | `/travel`, from guides and from the treasure-hunt overlay; `/zaap x y`, optionally chained with `; /travel x y`, since Dofus 3.7 |
| Items | An item name clicked in Ganymède is **pasted** into Dofus as is — no chat, no `Enter` — into whatever field is open there, typically the auction house search |
| Dofus target | **Manual selection** of the client window inside Zaapy — the user picks it, Zaapy remembers it |
| Focus after send | **Stays on Dofus** — no automatic return to Ganymède |
Expand All @@ -66,8 +66,7 @@ A Dofus 3 player following a Ganymède guide, on **Windows or macOS**, possibly

These are deliberately left undecided here:

1. **`/zaap` support.** Announced but not yet implemented in-game. Only `/travel` works today, so the command handling must be able to accept `/zaap` later without a redesign — but the exact trigger and formatting cannot be locked in until Ankama ships it.
2. **Distribution.** Signed installers, notarization, and auto-update only become relevant at the public-release step — but they constrain packaging choices made earlier.
1. **Distribution.** Signed installers, notarization, and auto-update only become relevant at the public-release step — but they constrain packaging choices made earlier.

## 9. Beyond v1 — non-committal directions

Expand All @@ -88,6 +87,6 @@ That said, whether this kind of tooling is acceptable under Ankama's terms of se
- **Ganymède** — companion app providing Dofus guides; copies `/travel` commands, and item names, to the clipboard on click.
- **Dofus 3** — the game client Zaapy sends commands to.
- **`/travel x,y`** — in-game chat command that sends the character to the map at those coordinates.
- **Zaap** — in-game teleportation network; the basis for the announced `/zaap` command.
- **Zaap** — in-game teleportation network; the basis for the `/zaap` command.
- **Bridge** — Zaapy's core job: turning a clipboard event in one window into a keyboard event in another.
- **Target window** — the specific Dofus client the user selected to receive commands.
16 changes: 11 additions & 5 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,17 @@
/>
/travel
</label>
<!-- Left visible rather than hidden: the command is coming, and a missing
row reads as a missing feature. -->
<label class="check" title="Announced by Ankama, not live in game yet">
<input type="checkbox" checked={config.commands.zaap} disabled />
/zaap <span class="hint">soon</span>
<label class="check">
<input
type="checkbox"
checked={config.commands.zaap}
onchange={(event) =>
save({
...config!,
commands: { ...config!.commands, zaap: event.currentTarget.checked },
})}
/>
/zaap
</label>
<label class="check" title="An item name clicked in Ganymède is pasted into Dofus as is — into the search field you have open, without opening the chat">
<input
Expand Down
Loading