aboutsummaryrefslogtreecommitdiff
path: root/test-client/protocol.ts
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-17 17:39:39 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-23 19:20:50 +0200
commit6f0424b9b4cddc0495eb673d314c570e27e61e83 (patch)
tree3ca2f5c8f1d16020dfa432d8a93fb1f53be93c4b /test-client/protocol.ts
parent428fa6fb8dac18c541c0c231f1b640ba172e52b9 (diff)
downloadhurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar
hurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar.bz2
hurrycurry-6f0424b9b4cddc0495eb673d314c570e27e61e83.tar.zst
everything indexed
Diffstat (limited to 'test-client/protocol.ts')
-rw-r--r--test-client/protocol.ts31
1 files changed, 18 insertions, 13 deletions
diff --git a/test-client/protocol.ts b/test-client/protocol.ts
index 707c09a3..d5cb2034 100644
--- a/test-client/protocol.ts
+++ b/test-client/protocol.ts
@@ -1,7 +1,13 @@
-export type ID = number;
export type Vec2 = [number, number]
-export type Item = string
-export type Tile = string
+export type PlayerID = number
+export type ItemID = number
+export type ItemIndex = number
+export type TileIndex = number
+
+export interface Gamedata {
+ item_names: string[],
+ tile_names: string[],
+}
export type PacketS =
{ join: { name: string } }
@@ -9,16 +15,15 @@ export type PacketS =
| { position: { pos: Vec2, rot: number } }
| { interact: { pos: Vec2, edge: boolean } }
-
export type PacketC =
- { joined: { id: ID } }
- | { add_player: { id: ID, name: string, hand?: [number, Item] } }
- | { remove_player: { id: ID } }
- | { position: { player: ID, pos: Vec2, rot: number } }
- | { take_item: { item: ID, player: ID } }
- | { put_item: { item: ID, pos: Vec2 } }
- | { produce_item: { id: ID, pos: Vec2, kind: Item } }
- | { consume_item: { id: ID, pos: Vec2 } }
+ { joined: { id: PlayerID, data: Gamedata } }
+ | { add_player: { id: PlayerID, name: string, hand?: [ItemID, ItemIndex] } }
+ | { remove_player: { id: PlayerID } }
+ | { position: { player: PlayerID, pos: Vec2, rot: number } }
+ | { take_item: { item: ItemID, player: PlayerID } }
+ | { put_item: { item: ItemID, pos: Vec2 } }
+ | { produce_item: { id: ItemID, pos: Vec2, kind: ItemIndex } }
+ | { consume_item: { id: ItemID, pos: Vec2 } }
| { set_active: { tile: Vec2 } }
- | { update_map: { pos: Vec2, tile: Tile } }
+ | { update_map: { pos: Vec2, tile: TileIndex } }