diff --git a/README.md b/README.md index 996d5d5..67c845f 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ ### General - [X] Routing URLs ? - [X] Add logout -- [ ] Cancel background image animation cancel -- [ ] Translate values +- [X] Translate values ### Navbar - [X] Fix navbar @@ -34,11 +33,11 @@ See register.js comments - [X] Search bar - [X] Modal create game - [X] Join game -- [ ] Validations on create game +- [X] Validations on create game - [X] Color on table points ### Game - [X] Game name - [X] *'Kiriki'* on roll - [X] Value table -- [ ] Winning a game, update game +- [X] Winning a game, update game diff --git a/game.html b/game.html index 5a67968..9185398 100644 --- a/game.html +++ b/game.html @@ -182,6 +182,28 @@
+ + diff --git a/js/game.js b/js/game.js index 1eefdc6..8f6b2ce 100644 --- a/js/game.js +++ b/js/game.js @@ -27,6 +27,7 @@ function gameData() { }, error: function (result) { console.log('Cant load data'); + console.log(result); loadError(); } }); @@ -162,6 +163,15 @@ function loadData(result) { hideBid(); getOwnRoll(); } + + // if winner show winner modal + if (result.winner !== null) { + $('#spectate').addClass('d-none'); + $('#decide').addClass('d-none'); + $('#roll').addClass('d-none'); + $('#bid').addClass('d-none'); + loadWinnerModal(result); + } } function loadError() { @@ -283,10 +293,7 @@ function hideAnnounce() { } function loadPointResultModal(json) { - - - - console.log("Loser: " + json.point_loser); + console.log('Loading point result modal'); if (json.point_loser === localStorage.getItem('username')) { $('#whosLoser').addClass('text-danger').html('Has perdido'); @@ -317,6 +324,11 @@ function loadPointResultModal(json) { return false; } +function loadWinnerModal(json) { + $('#winner').html(json.winner); + $('#winnerModal').modal('show'); +} + function changeGameName(json) { console.log('Changing game name'); console.log(json); @@ -391,11 +403,4 @@ function lessValue(bid, bidImage) { }); $(bidImage).addClass("dice-" + val); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -$('#test').on('click', function (e) { - displayBidResult(); - -}); \ No newline at end of file +} \ No newline at end of file diff --git a/js/games.js b/js/games.js index 2964a59..3726fdb 100644 --- a/js/games.js +++ b/js/games.js @@ -6,6 +6,7 @@ jQuery(function () { } else { ajaxGetGames(); ajaxGetStartedGames(); + ajaxGetFinishedGames(); } }); @@ -76,6 +77,41 @@ function loadStartedGamesWherePlayerIs(json) { }; +function loadFinishedGamesWherePlayerIs(json) { + console.log("finished games"); + let games = json.results; + console.log(games); + + + $('#gamesFinished').html(''); + + games.forEach(game => { + $('#gamesFinished').append(` +Nombre | +Puntos | +
---|