aboutsummaryrefslogtreecommitdiff
path: root/test-client/protocol.ts
blob: d5cb203422dc9f2a51c74d14bc1a41c7e3e9ce97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
export type Vec2 = [number, number]
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 } }
    | "leave"
    | { position: { pos: Vec2, rot: number } }
    | { interact: { pos: Vec2, edge: boolean } }

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 } }
    | { update_map: { pos: Vec2, tile: TileIndex } }