summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/interaction.rs13
-rw-r--r--test-client/main.ts2
2 files changed, 9 insertions, 6 deletions
diff --git a/server/src/interaction.rs b/server/src/interaction.rs
index 615d2aab..e3dccfba 100644
--- a/server/src/interaction.rs
+++ b/server/src/interaction.rs
@@ -192,12 +192,13 @@ pub fn interact(
} => {
let on_tile = this.as_ref().map(|i| i.kind);
let in_hand = other.as_ref().map(|i| i.kind);
- let ok = (inputs[0] == on_tile && inputs[1] == in_hand)
- || (inputs[1] == on_tile && inputs[0] == in_hand);
- if ok {
- info!("instant recipe {ri:?}");
- *other = outputs[0].map(|kind| Item { kind, active: None });
- *this = outputs[1].map(|kind| Item { kind, active: None });
+ let ok = inputs[0] == on_tile && inputs[1] == in_hand;
+ let ok_rev = inputs[1] == on_tile && inputs[0] == in_hand;
+ if ok || ok_rev {
+ info!("instant recipe {ri:?} reversed={ok_rev}");
+ let ok_rev = ok_rev as usize;
+ *other = outputs[1 - ok_rev].map(|kind| Item { kind, active: None });
+ *this = outputs[ok_rev].map(|kind| Item { kind, active: None });
return Some(InteractEffect::Produce);
}
}
diff --git a/test-client/main.ts b/test-client/main.ts
index 04cd2331..42c1a3e0 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -201,6 +201,8 @@ function keyboard(ev: KeyboardEvent, down: boolean) {
if (HANDLED_KEYS.includes(ev.code)) ev.preventDefault()
if (!keys_down.has("Space") && ev.code == "Space" && down) set_interact(true)
if (keys_down.has("Space") && ev.code == "Space" && !down) set_interact(false)
+ if (down && !ev.shiftKey && ev.code == "KeyK") send({ type: "communicate", message: { text: "/start" } })
+ if (down && ev.shiftKey && ev.code == "KeyK") send({ type: "communicate", message: { text: "/end" } })
if (down) keys_down.add(ev.code)
else keys_down.delete(ev.code)
}