From 8ee3eca5d6de0b950881783821d1be86cd0586d5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 2 Jul 2024 00:52:42 +0200 Subject: generalize protocol --- test-client/protocol.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test-client/protocol.ts') diff --git a/test-client/protocol.ts b/test-client/protocol.ts index 1e76700a..fd0f8d43 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -41,11 +41,9 @@ export type PacketC = | { type: "add_player", id: PlayerID, name: string, position: Vec2, character: number } // Somebody else joined (or was already in the game) | { type: "remove_player", id: PlayerID } // Somebody left | { type: "position", player: PlayerID, pos: Vec2, rot: number } // Update the position of a players (your own position is included here) - | { type: "take_item", tile: Vec2, player: PlayerID } // An item was taken from a tile - | { type: "put_item", tile: Vec2, player: PlayerID } // An item was put on a tile - | { type: "set_tile_item", tile: Vec2, item?: ItemIndex } // A tile changed its item - | { type: "set_player_item", player: PlayerID, item?: ItemIndex } // A player changed their item - | { type: "set_active", tile: Vec2, progress?: number, warn: boolean } // A tile is doing something. progress goes from 0 to 1, then null when finished + | { type: "move_item", from: ItemLocation, to: ItemLocation } // Item moved + | { type: "set_item", location: ItemLocation, item?: ItemIndex } // the item contained in a tile or player changed + | { type: "set_progress", item: ItemLocation, progress?: number, warn: boolean } // A tile is doing something. progress goes from 0 to 1, then null when finished | { type: "update_map", tile: Vec2, kind: TileIndex | null, neighbors: [TileIndex | null] } // A map tile was changed | { type: "communicate", player: PlayerID, message?: Message, persist: boolean } // A player wants to communicate something, message is null when cleared | { type: "server_message", text: string } // Text message from the server @@ -57,3 +55,7 @@ export type Message = { item: number } | { text: string } | { effect: string } + +export type ItemLocation = + { player: PlayerID } + | { tile: Vec2 } -- cgit v1.2.3-70-g09d2