Skip to content

Commit

Permalink
All multiplayerGame correct
Browse files Browse the repository at this point in the history
  • Loading branch information
uo288061 committed Apr 25, 2024
1 parent 147bb7d commit c85ee32
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 44 deletions.
7 changes: 2 additions & 5 deletions src/main/java/com/uniovi/controllers/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public String getGame(HttpSession session, Model model, Principal principal) {

@GetMapping("/multiplayerGame")
public String getMultiplayerGame() {
//EL elminar el multiplaterCode del jugador se puede hacer cuando comienze el proximo
//juego con amigos o cuando acaba la partida, lo suyo seria cuando acabe
//ya mirare como
return "game/multiplayerGame";
}

Expand All @@ -87,7 +84,6 @@ public String joinMultiplayerGame(@PathVariable String code, HttpSession session
session.setAttribute("multiplayerCode",code);
return "redirect:/game/lobby";
} else {
//Hay q tratarlo como como se hace en sinUp, hacienado validate y tal
return "redirect:/multiplayerGame";
}
}
Expand Down Expand Up @@ -193,12 +189,12 @@ public Map<String, String> endMultiplayerGameTable(@PathVariable String code) {
@GetMapping("/game/lobby/{code}")
@ResponseBody
public List<String> updatePlayerList(@PathVariable String code) {
//List<Player> players = playerService.getUsersByMultiplayerCode(Integer.parseInt(code));
Map<Player,Integer> players= multiplayerSessionService.getPlayersWithScores(Integer.parseInt(code));
List<String> playerNames = new ArrayList<>();
for (Map.Entry<Player, Integer> player : players.entrySet()) {
playerNames.add(player.getKey().getUsername());
}
Collections.sort(playerNames);
return playerNames;
}
@GetMapping("/game/lobby")
Expand Down Expand Up @@ -292,6 +288,7 @@ public String updateGame(Model model, HttpSession session, Principal principal)
isMultiPlayer=false;
//return "game/multiplayerGame/endGame/"+p.getMultiplayerCode();
//return "redirect:multiplayerGame/endGame/"+p.getMultiplayerCode();
//return "redirect:multiplayerGame/endGame/"+p.getMultiplayerCode();
return "game/multiFinished";
}
if (nextQuestion == null) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ ranking.time=Tiempo
# -------------------Statements for the multiplayerGame.html file---------------------
multi.text = ¿Aún no tienes un código? Crea uno y compártelo con tus amigos
multi.create = Crear
multi.placeholder= Introduce el código de una partida
multi.placeholder= Introduce el código correcto
multi.label = Únete a una partida
multi.join = Unirse
multi.onlyNumber = Solo se permiten números
multi.copyCode= Copiar código
multi.info=Resultados para la partida:

# -------------------Statements for the lobby.html file---------------------
lobby.info =Jugadores unidos a la partida:
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ ranking.time=Time
# -------------------Statements for the multiplayerGame.html file---------------------
multi.text =Don't have a code yet? Create one and share it with your friends
multi.create = Create
multi.placeholder=Enter the game code
multi.placeholder=Enter the correct code
multi.label=Join a game
multi.join = Join
multi.onlyNumber=Only numbers allowed
multi.copyCode= Copy code
multi.info=reults for the game:

# -------------------Statements for the lobby.html file---------------------
lobby.info =Players joining the game:
lobby.friends =Share your game code with your friends
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ ranking.time=Tiempo
# -------------------Statements for the multiplayerGame.html file---------------------
multi.text = ¿Aún no tienes un código? Crea uno y compártelo con tus amigos
multi.create = Crear
multi.placeholder= Introduce el código de una partida
multi.placeholder= Introduce el código correcto
multi.label = Únete a una partida
multi.join = Unirse
multi.onlyNumber = Solo se permiten números
multi.copyCode= Copiar código

multi.info=Resultados para la partida:

# -------------------Statements for the lobby.html file---------------------
lobby.info =Jugadores unidos a la partida:
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ ranking.time=Temps
# -------------------Statements for the multiplayerGame.html file---------------------
multi.text = Vous n'avez pas encore de code ? Créez-en un et partagez-le avec vos amis.
multi.create = Créer
multi.placeholder=Entrez le code du jeu
multi.placeholder=Entrez le bon code
multi.label=Rejoignez une partie
multi.join =Rejoindre
multi.onlyNumber=Seuls les chiffres sont autorisés
multi.copyCode= Copier le code
multi.info=résultats du jeu:

# -------------------Statements for the lobby.html file---------------------
lobby.info =Joueurs rejoignant le jeu :
Expand Down
35 changes: 6 additions & 29 deletions src/main/resources/templates/game/multiFinished.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,14 @@ <h2 id="finishedGame" th:text ="#{multi.finished}"> </h2>
<h3 th:text ="#{multi.code}"> </h3>
<code id="lobbyCode" th:text="${code}"></code>

<!--<h3 id="multiPoints" th:text ="#{multi.points}"> </h3>
<ul id="playerList">
<li th:each="player : ${players}"></li>
</ul>-->

<a th:href="@{'/multiplayerGame/endGame/' + ${code}}">
<button id="createBtn" type="button" class="btn btn-custom btn-block mb-2">Continuar</button>
<button id="createBtn" type="button" class="btn btn-custom btn-block mb-2" th:text="#{multi.results}"></button>
</a>

<!--<script>
$(document).ready(function() {
function updatePlayerList() {
const code = [[${code}]];
$.ajax({
//url: '/game/multiFinished/' + code,
url: '/endGameList/' + code,
type: 'GET',
dataType: 'json',
success: function (response) {
$('#playerList').empty();
$.each(response, function(playerName, playerPoints) {
$('#playerList').append('<li><span class="playerName">' + playerName + '</span>: <span class="playerStatus">' + playerPoints + '</span></li>');
});
},
error: function (xhr, status, error) {
console.error('Error al actualizar la lista de jugadores:', error);
}
});
}
setInterval(updatePlayerList, 1000);
<script>
$(document).ready(function () {
$(".points").remove();
$(".questionCounter").remove();
});
</script>-->

</script>
</div>
7 changes: 2 additions & 5 deletions src/main/resources/templates/ranking/multiplayerRanking.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

<div class="container">
<div class="table-responsive">
<h2>Fin multijugador</h2>
<!--<div class="table-responsive">
<table class="table table-hover" th:fragment="globalRankingTable" id="globalRankingTable" th:replace="~{ranking/multiplayerRanking_table}"/>
</div>-->
<h2 th:text ="#{multi.info}"></h2>
<h3 th:text="${code}"></h3>
<ul id="playerList">
</ul>
</div>
Expand All @@ -25,7 +23,6 @@ <h2>Fin multijugador</h2>
function updatePlayerList() {
const code = [[${code}]];
$.ajax({
//url: '/game/multiFinished/' + code,
url: '/endGameList/' + code,
type: 'GET',
dataType: 'json',
Expand Down

0 comments on commit c85ee32

Please sign in to comment.