diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-18 09:57:39 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:20:50 +0200 |
commit | 9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991 (patch) | |
tree | f99e521bf3b199162ed3e4e45536e944fe634489 /test-client | |
parent | a99aa006599827ea999a5684e40635175c8d790a (diff) | |
download | hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar.bz2 hurrycurry-9bdb81bb34bd6a7e33c47d6fcb3dced1c5bda991.tar.zst |
can start passive recipes
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/main.ts | 10 | ||||
-rw-r--r-- | test-client/protocol.ts | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index 6622d37f..3926dffc 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -36,7 +36,7 @@ interface PlayerData { x: number; y: number, name: string, rot: number, hand?: I const players = new Map<PlayerID, PlayerData>() interface ItemData { kind: ItemIndex, tile?: V2, player?: PlayerID, tracking_player: boolean, x: number, y: number } const items = new Map<ItemID, ItemData>() -interface TileData { x: number; y: number, kind: TileIndex, items: ItemID[], active: boolean } +interface TileData { x: number; y: number, kind: TileIndex, items: ItemID[], active_progress?: number } const tiles = new Map<string, TileData>() let data: Gamedata = { item_names: [], tile_names: [] } @@ -79,9 +79,9 @@ function packet(p: PacketC) { t.items.splice(t.items.indexOf(p.consume_item.id)) items.delete(p.consume_item.id) } else if ("set_active" in p) { - // TODO + tiles.get(p.set_active.tile.toString())!.active_progress = p.set_active.progress } else if ("update_map" in p) { - tiles.set(p.update_map.pos.toString(), { x: p.update_map.pos[0], y: p.update_map.pos[1], kind: p.update_map.tile, active: false, items: [] }) + tiles.set(p.update_map.pos.toString(), { x: p.update_map.pos[0], y: p.update_map.pos[1], kind: p.update_map.tile, items: [] }) } else console.warn("unknown packet", p); } @@ -197,6 +197,10 @@ function draw_ingame() { for (const c of comps) { c(ctx) } + if (tile.active_progress !== null && tile.active_progress !== undefined) { + ctx.fillStyle = "rgba(115, 230, 58, 0.66)" + ctx.fillRect(0, 0, 1, tile.active_progress) + } ctx.restore() } diff --git a/test-client/protocol.ts b/test-client/protocol.ts index d5cb2034..ccd891dd 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -24,6 +24,6 @@ export type PacketC = | { put_item: { item: ItemID, pos: Vec2 } } | { produce_item: { id: ItemID, pos: Vec2, kind: ItemIndex } } | { consume_item: { id: ItemID, pos: Vec2 } } - | { set_active: { tile: Vec2 } } + | { set_active: { tile: Vec2, progress?: number } } | { update_map: { pos: Vec2, tile: TileIndex } } |