mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Added feedback to clients
This commit is contained in:
@@ -96,18 +96,34 @@ public class TicTacToe extends GameBase implements Runnable {
|
|||||||
// Attempt to play the move
|
// Attempt to play the move
|
||||||
State state = play(index);
|
State state = play(index);
|
||||||
|
|
||||||
|
if (state != State.INVALID){
|
||||||
|
// Tell all players who made a move and what move was made
|
||||||
|
// TODO: What is the reaction of the game? WIN, DRAW etc?
|
||||||
|
String player = getCurrentPlayer().name();
|
||||||
|
addSendToQueue("SVR GAME MOVE {PLAYER: \"" +
|
||||||
|
getCurrentPlayer().name() +
|
||||||
|
"\", DETAILS: \"<reactie spel op zet>\",MOVE: \"" +
|
||||||
|
index +
|
||||||
|
"\"}\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Check move result
|
// Check move result
|
||||||
switch (state){
|
switch (state){
|
||||||
case State.WIN:{
|
case State.WIN:{
|
||||||
// Win
|
// Win
|
||||||
running = false;
|
running = false;
|
||||||
|
addSendToQueue("VR GAME WIN {PLAYERONESCORE: \"<score speler1>\", PLAYERTWOSCORE: \"" +
|
||||||
|
"<score speler2>\", COMMENT: \"<commentaar op resultaat>\"}\n");
|
||||||
}
|
}
|
||||||
case State.DRAW:{
|
case State.DRAW:{
|
||||||
// Draw
|
// Draw
|
||||||
running = false;
|
running = false;
|
||||||
|
addSendToQueue("VR GAME DRAW {PLAYERONESCORE: \"<score speler1>\", PLAYERTWOSCORE: \"" +
|
||||||
|
"<score speler2>\", COMMENT: \"<commentaar op resultaat>\"}\n");
|
||||||
}
|
}
|
||||||
case State.NORMAL:{
|
case State.NORMAL:{
|
||||||
// Nothing wrong?
|
// Valid move but not end of game
|
||||||
|
addSendToQueue("SVR GAME YOURTURN");
|
||||||
}
|
}
|
||||||
case State.INVALID:{
|
case State.INVALID:{
|
||||||
// Invalid move
|
// Invalid move
|
||||||
|
|||||||
Reference in New Issue
Block a user