diff --git a/javascript/demo.js b/javascript/demo.js index 897e08c..84c2e9c 100644 --- a/javascript/demo.js +++ b/javascript/demo.js @@ -18,23 +18,23 @@ async function main() { console.log("Initial player position is", game.player.position); let moveResult; - const playerUuid = game.player.uuid; + const playerId = game.player.id; try { console.log("Trying to move right"); - moveResult = await fh.move(playerUuid, sdk.Direction.RIGHT); + moveResult = await fh.move(playerId, sdk.Direction.RIGHT); console.log("Successfully moved to", moveResult.player.position); console.log("Trying to move right"); - moveResult = await fh.move(playerUuid, sdk.Direction.RIGHT); + moveResult = await fh.move(playerId, sdk.Direction.RIGHT); console.log("Successfully moved to", moveResult.player.position); console.log("Trying to move right"); - moveResult = await fh.move(playerUuid, sdk.Direction.RIGHT); + moveResult = await fh.move(playerId, sdk.Direction.RIGHT); console.log("Successfully moved to", moveResult.player.position); console.log("Trying to move down"); - moveResult = await fh.move(playerUuid, sdk.Direction.DOWN); + moveResult = await fh.move(playerId, sdk.Direction.DOWN); console.log("Successfully moved to", moveResult.player.position); } catch (err) { if (err instanceof sdk.PositionError) { diff --git a/javascript/fh_sdk.js b/javascript/fh_sdk.js index 3096983..f86f145 100644 --- a/javascript/fh_sdk.js +++ b/javascript/fh_sdk.js @@ -76,8 +76,8 @@ class FairHopper { return await r.json(); } - async getPlayerInfo(playerUuid) { - const r = await fetch(this.formatUrl(`/player/${playerUuid}`), { + async getPlayerInfo(playerId) { + const r = await fetch(this.formatUrl(`/player/${playerId}`), { headers: this.defaultHeaders, }); switch (r.status) { @@ -89,24 +89,24 @@ class FairHopper { return await r.json(); } - async moveLeft(playerUuid) { - return await this.move(playerUuid, "left"); + async moveLeft(playerId) { + return await this.move(playerId, "left"); } - async moveRight(playerUuid) { - return await this.move(playerUuid, "right"); + async moveRight(playerId) { + return await this.move(playerId, "right"); } - async moveUp(playerUuid) { - return await this.move(playerUuid, "up"); + async moveUp(playerId) { + return await this.move(playerId, "up"); } - async moveDown(playerUuid) { - return await this.move(playerUuid, "down"); + async moveDown(playerId) { + return await this.move(playerId, "down"); } - async move(playerUuid, direction) { - const url = this.formatUrl(`/player/${playerUuid}/move/${direction}`); + async move(playerId, direction) { + const url = this.formatUrl(`/player/${playerId}/move/${direction}`); const r = await fetch(url, { method: "post", headers: this.defaultHeaders, diff --git a/python/demo.py b/python/demo.py index de2f986..b8ba577 100644 --- a/python/demo.py +++ b/python/demo.py @@ -18,23 +18,23 @@ def main() -> None: print() print("Initial player position is", game.player.position) - player_uuid = game.player.uuid + player_id = game.player.id try: print("Trying to move right") - moveResult = fh.move(player_uuid, Direction.RIGHT) + moveResult = fh.move(player_id, Direction.RIGHT) print("Successfully moved to", moveResult.player.position) print("Trying to move right") - moveResult = fh.move(player_uuid, Direction.RIGHT) + moveResult = fh.move(player_id, Direction.RIGHT) print("Successfully moved to", moveResult.player.position) print("Trying to move right") - moveResult = fh.move(player_uuid, Direction.RIGHT) + moveResult = fh.move(player_id, Direction.RIGHT) print("Successfully moved to", moveResult.player.position) print("Trying to move down") - moveResult = fh.move(player_uuid, Direction.DOWN) + moveResult = fh.move(player_id, Direction.DOWN) print("Successfully moved to", moveResult.player.position) except PositionError: print("Cant't move in this direction") diff --git a/python/fh_sdk.py b/python/fh_sdk.py index 8d48592..f7049f6 100644 --- a/python/fh_sdk.py +++ b/python/fh_sdk.py @@ -42,7 +42,7 @@ class Destination(BaseModel): class Player(BaseModel): - uuid: str + id: str name: str active: bool position: Position @@ -95,8 +95,8 @@ class FairHopper: r.raise_for_status() return GameInfoResponse(**r.json()) - def get_player_info(self, uuid: str) -> PlayerInfoResponse: - r = requests.get(self.format_url(f"/player/{uuid}")) + def get_player_info(self, id: str) -> PlayerInfoResponse: + r = requests.get(self.format_url(f"/player/{id}")) if r.status_code == 403: raise PlayerInactiveError() @@ -107,20 +107,20 @@ class FairHopper: return PlayerInfoResponse(**r.json()) - def move_left(self, uuid: str) -> PlayerInfoResponse: - return self.move(uuid, Direction.LEFT) + def move_left(self, id: str) -> PlayerInfoResponse: + return self.move(id, Direction.LEFT) - def move_right(self, uuid: str) -> PlayerInfoResponse: - return self.move(uuid, Direction.RIGHT) + def move_right(self, id: str) -> PlayerInfoResponse: + return self.move(id, Direction.RIGHT) - def move_up(self, uuid: str) -> PlayerInfoResponse: - return self.move(uuid, Direction.UP) + def move_up(self, id: str) -> PlayerInfoResponse: + return self.move(id, Direction.UP) - def move_down(self, uuid: str) -> PlayerInfoResponse: - return self.move(uuid, Direction.DOWN) + def move_down(self, id: str) -> PlayerInfoResponse: + return self.move(id, Direction.DOWN) - def move(self, uuid: str, direction: Direction) -> PlayerInfoResponse: - path = f"/player/{uuid}/move/{direction}" + def move(self, id: str, direction: Direction) -> PlayerInfoResponse: + path = f"/player/{id}/move/{direction}" r = requests.post(self.format_url(path)) if r.status_code == 403: