diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-18 11:56:31 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:20:50 +0200 | 
| commit | b0b37da40d2c737e37d47de97aef19bd6494e228 (patch) | |
| tree | 162ba8bf680e951afa5e6083d71cd1398a9a4433 /test-client/protocol.ts | |
| parent | 101ef75240e5d94f182fa1f15b58881c39221cfa (diff) | |
| download | hurrycurry-b0b37da40d2c737e37d47de97aef19bd6494e228.tar hurrycurry-b0b37da40d2c737e37d47de97aef19bd6494e228.tar.bz2 hurrycurry-b0b37da40d2c737e37d47de97aef19bd6494e228.tar.zst  | |
protocol
Diffstat (limited to 'test-client/protocol.ts')
| -rw-r--r-- | test-client/protocol.ts | 34 | 
1 files changed, 17 insertions, 17 deletions
diff --git a/test-client/protocol.ts b/test-client/protocol.ts index ccd891dd..d5605e37 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -1,29 +1,29 @@ -export type Vec2 = [number, number] +export type Vec2 = [number, number] // x, y  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[], +    item_names: string[], // Look-up table for ItemIndex +    tile_names: string[], // Look-up table for TileIndex  }  export type PacketS = -    { join: { name: string } } -    | "leave" -    | { position: { pos: Vec2, rot: number } } -    | { interact: { pos: Vec2, edge: boolean } } +    { join: { name: string } } // You join, sent as first packet. +    | { position: { pos: Vec2, rot: number } } // Update your position +    | { interact: { pos: Vec2, edge: boolean } } // Interact with some tile. edge is true when pressing and false when releasing interact button +    | { collide: { player: PlayerID, force: Vec2 } } // Apply force to another player as a result of a collision  export type PacketC = -    { 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, progress?: number } } -    | { update_map: { pos: Vec2, tile: TileIndex } } +    { joined: { id: PlayerID, data: Gamedata } } // You joined +    | { add_player: { id: PlayerID, name: string, hand?: [ItemID, ItemIndex] } } // Somebody else joined (or was already in the game) +    | { remove_player: { id: PlayerID } }  // Somebody left +    | { position: { player: PlayerID, pos: Vec2, rot: number } } // Update the position of a players (your own position is included here) +    | { take_item: { item: ItemID, player: PlayerID } }  // An item was taken from a tile +    | { put_item: { item: ItemID, pos: Vec2 } } // An item was put on a tile +    | { produce_item: { id: ItemID, pos: Vec2, kind: ItemIndex } } // A tile generated a new item +    | { consume_item: { id: ItemID, pos: Vec2 } } // A tile removed an item +    | { set_active: { tile: Vec2, progress?: number } } // A tile is doing something. progress goes from 0 to 1, then null when finished +    | { update_map: { pos: Vec2, tile: TileIndex } } // A map tile was changed  |