playerColor add
This commit is contained in:
parent
07266f2031
commit
2602cd0acf
@ -111,6 +111,8 @@ public class GameRoom {
|
||||
|
||||
red.setY(10);
|
||||
sendMessage(message.getUid(), WebSocketMessageType.ChipMove, om.writeValueAsString(red));
|
||||
|
||||
sendMessage(message.getUid(), WebSocketMessageType.PlayerColor, om.writeValueAsString(new PlayerColor(2L, "#ff0000")));
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.alterdekim.game.component.game;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class PlayerColor {
|
||||
private Long playerId;
|
||||
private String color;
|
||||
}
|
@ -6,5 +6,6 @@ public enum WebSocketMessageType {
|
||||
InfoRequest,
|
||||
ChangeBoardTileState,
|
||||
AssignChip,
|
||||
ChipMove
|
||||
ChipMove,
|
||||
PlayerColor
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ $(document).ready(function() {
|
||||
socket = new SockJS('/websocket');
|
||||
|
||||
socket.onopen = function() {
|
||||
$("#loading").css("display", "");
|
||||
console.log('open');
|
||||
sendMessage({}, 'InfoRequest');
|
||||
};
|
||||
@ -120,6 +121,9 @@ function showMessage(message) {
|
||||
case 'ChipMove':
|
||||
chipMove(JSON.parse(message.body));
|
||||
break;
|
||||
case 'PlayerColor':
|
||||
playerColor(JSON.parse(message.body));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +139,16 @@ function chipMove(body) {
|
||||
moveChips();
|
||||
}
|
||||
|
||||
function playerColor(body) {
|
||||
$(".player").each(function() {
|
||||
if( $(this).attr("data-pid") == body.playerId ) {
|
||||
$(this).css("background-color", body.color);
|
||||
return;
|
||||
}
|
||||
$(this).css("background-color", "");
|
||||
});
|
||||
}
|
||||
|
||||
const corners = [
|
||||
{x: 0, y: 0},
|
||||
{x: 10, y: 0},
|
||||
|
@ -21,12 +21,12 @@
|
||||
</div>
|
||||
</head>
|
||||
<body>
|
||||
<!--<div id="loading" style="width: 100%; height: 100%;">
|
||||
<div id="loading" style="width: 100%; height: 100%;">
|
||||
<div style="text-align: center">
|
||||
<p id="loading_status" style="color: white">Идёт загрузка игры...</p>
|
||||
<div id="returnBtn" onclick="window.location = '/games?gtype=monopoly'" class="btn green" style="margin-top: 5px; display: none; margin-bottom: auto; margin-left: auto; margin-right: auto;">Назад</div>
|
||||
<p id="loading_status" style="color: white">Loading...</p>
|
||||
<div id="returnBtn" onclick="window.location.href = '/games'" class="btn green" style="margin-top: 5px; margin-bottom: auto; margin-left: auto; margin-right: auto;">Go back</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
<div class="wrapper" style="width: 100%; height: 100%">
|
||||
<div class="game">
|
||||
<div class="players">
|
||||
|
Loading…
x
Reference in New Issue
Block a user