aboutsummaryrefslogtreecommitdiff
path: root/test-client/main.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-19 18:13:41 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-19 18:13:41 +0100
commit0bdd9ed7b86fc39f154d762644de8483df0189bc (patch)
tree3ca0dee35235cafa2e7e9ed00bfee1ecdb23f696 /test-client/main.ts
parentfdffbdca756ab13e057b779fc53ccf31d5b9858a (diff)
downloadhurrycurry-0bdd9ed7b86fc39f154d762644de8483df0189bc.tar
hurrycurry-0bdd9ed7b86fc39f154d762644de8483df0189bc.tar.bz2
hurrycurry-0bdd9ed7b86fc39f154d762644de8483df0189bc.tar.zst
fix testclient for single-handed games
Diffstat (limited to 'test-client/main.ts')
-rw-r--r--test-client/main.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/test-client/main.ts b/test-client/main.ts
index 4c1f28f0..946b933e 100644
--- a/test-client/main.ts
+++ b/test-client/main.ts
@@ -130,11 +130,14 @@ let last_server_sent_position: V2 = { x: 0, y: 0 }
function get_item_location(loc: ItemLocation): PlayerData | TileData {
if ("tile" in loc) return tiles.get(loc.tile.toString())!
- if ("player" in loc) return players.get(loc.player)!
+ if ("player" in loc) return players.get(loc.player[0])!
throw new Error("invalid item location");
}
-function send(p: PacketS) { ws.send(JSON.stringify(p)) }
+function send(p: PacketS) {
+ if (p.type != "movement") console.log("send", p);
+ ws.send(JSON.stringify(p))
+}
function packet(p: PacketC) {
if (!["movement", "update_map"].includes(p.type))
console.log(p);
@@ -403,7 +406,7 @@ export function get_interact_target(): V2 | undefined {
function set_interact(edge: boolean) {
if (edge) interacting = get_interact_target()
- if (interacting) send({ player: my_id, type: "interact", pos: edge ? [interacting.x, interacting.y] : undefined })
+ if (interacting) send({ player: my_id, type: "interact", pos: edge ? [interacting.x, interacting.y] : undefined, hand: 0 })
if (!edge) interacting = undefined
}