diff --git a/score/src/main/java/com/oracle/developer/multiplayer/score/CurrentScoreController.java b/score/src/main/java/com/oracle/developer/multiplayer/score/CurrentScoreController.java index c57ae68..2d5557c 100644 --- a/score/src/main/java/com/oracle/developer/multiplayer/score/CurrentScoreController.java +++ b/score/src/main/java/com/oracle/developer/multiplayer/score/CurrentScoreController.java @@ -32,7 +32,7 @@ public CurrentScoreController(CurrentScoreRepository currentScoreRepository, Sco CurrentScoreDAO getByUuid(@PathVariable("uuid") String uuid) { logger.info("GET /api/score/" + uuid); CurrentScore score = currentScoreRepository.findByUuid(uuid).orElseThrow(() -> new NotAuthorizedOrNotFound()); - return new CurrentScoreDAO(score.getUuid(),score.getName(), score.getScore() ); + return new CurrentScoreDAO(score.getUuid(), score.getName(), score.getScore()); } @PutMapping("/api/score/{uuid}") @@ -49,15 +49,15 @@ CurrentScoreDAO addScore(@PathVariable("uuid") String uuid, @RequestBody ScoreOp scoreFromStore.setName(body.getName()); scoreFromStore.setUuid(uuid); CurrentScore saved = currentScoreRepository.save(scoreFromStore); - return new CurrentScoreDAO(saved.getUuid(),saved.getName(), saved.getScore() ); + return new CurrentScoreDAO(saved.getUuid(), saved.getName(), saved.getScore()); } @DeleteMapping("/api/score/{uuid}") @Transactional ResponseEntity deleteByUuid(@PathVariable("uuid") String uuid) { logger.info("DELETE /api/score/" + uuid); - CurrentScore currentScoreFromStore = - currentScoreRepository.findByUuid(uuid).orElseThrow(() -> new NotAuthorizedOrNotFound()); + CurrentScore currentScoreFromStore = currentScoreRepository.findByUuid(uuid) + .orElseThrow(() -> new NotAuthorizedOrNotFound()); Score scoreFromStore = scoreRepository.findByUuid(uuid).orElse(new Score(uuid, currentScoreFromStore.getName(), 0L)); if (currentScoreFromStore.getScore() > scoreFromStore.getScore()) { diff --git a/server/score.js b/server/score.js index 89e8641..966a21f 100644 --- a/server/score.js +++ b/server/score.js @@ -7,6 +7,7 @@ const isProduction = process.env.NODE_ENV === "production"; const logger = pino({ level: isProduction ? "warn" : "debug" }); let scoreFeatureFlag = true; +let scoreServiceUrl; const SCORE_SERVICE_HOST = process.env.SCORE_SERVICE_HOST; if (!SCORE_SERVICE_HOST) { @@ -20,7 +21,8 @@ if (!SCORE_SERVICE_PORT) { } if (scoreFeatureFlag) { - const scoreServiceUrl = `${SCORE_SERVICE_HOST}:${SCORE_SERVICE_PORT}`; + scoreServiceUrl = `${SCORE_SERVICE_HOST}:${SCORE_SERVICE_PORT}`; + logger.info({ scoreServiceUrl }); logger.info(`Connecting to Score on ${scoreServiceUrl}`); } @@ -32,7 +34,8 @@ export async function postCurrentScore(playerId, playerName, operationType) { name: playerName, }); // FIXME thrown exceptions will kill the process! - await fetch(`http://${scoreServiceUrl}/api/score/${playerId}`, { + const urlRequest = `http://${scoreServiceUrl}/api/score/${playerId}`; + await fetch(urlRequest, { method: "PUT", headers: { "Content-type": "application/json" }, body: stringifyBody, diff --git a/web/src/script.js b/web/src/script.js index 463e97a..5b0ca1f 100644 --- a/web/src/script.js +++ b/web/src/script.js @@ -28,7 +28,7 @@ if (!localStorage.getItem("yourId")) { localStorage.setItem("yourId", short()); } const yourId = localStorage.getItem("yourId"); -let playerName = localStorage.getItem("yourName") || "Default"; +let playerName; let renderer, scene, camera, sun, water; let canvas; @@ -57,6 +57,7 @@ const createGameButton = document.getElementById("create-game-button"); createGameButton.addEventListener("click", init); async function init() { + playerName = localStorage.getItem("yourName") || "Default"; scene = new THREE.Scene(); function fibonacciGenerator(maxTerm) { @@ -130,8 +131,8 @@ async function init() { ]; const materials = [ - new THREE.MeshPhongMaterial({ color: 0x90EE90 }), // green material for wildlife - new THREE.MeshPhongMaterial({ color: 0xBB8E51 }), // brown material for trash + new THREE.MeshPhongMaterial({ color: 0x90ee90 }), // green material for wildlife + new THREE.MeshPhongMaterial({ color: 0xbb8e51 }), // brown material for trash ]; //add music loader