uuid -> id

This commit is contained in:
Eden Kirin
2023-03-31 17:19:26 +02:00
parent 10290dba54
commit edca936325
4 changed files with 35 additions and 35 deletions

View File

@ -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) {

View File

@ -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,