Remove (currently unnecessary) game started event

This commit is contained in:
Charles Gould 2017-02-11 18:18:44 -05:00
parent 573b8d14c4
commit 241cb6bdae
3 changed files with 7 additions and 18 deletions

View File

@ -12,8 +12,6 @@ public class Destinations {
public static final String GAME_LEFT = topicDestination("gameLeft"); public static final String GAME_LEFT = topicDestination("gameLeft");
public static final String GAME_STARTED = topicDestination("gameStarted");
public static final String OPPONENT_JOINED = topicDestination("opponentJoined"); public static final String OPPONENT_JOINED = topicDestination("opponentJoined");
public static final String OPPONENT_REPORTS = topicDestination("opponentReports"); public static final String OPPONENT_REPORTS = topicDestination("opponentReports");

View File

@ -154,6 +154,7 @@ public class LingoController {
// TODO: require the players to "ready up" // TODO: require the players to "ready up"
game.setAcceptableGuesses(wordRepo.getGuesses()); game.setAcceptableGuesses(wordRepo.getGuesses());
game.setPossibleWords(wordRepo.getWords()); game.setPossibleWords(wordRepo.getWords());
final String firstWord = game.newGame(); final String firstWord = game.newGame();
final String firstLetter = String.valueOf(firstWord.charAt(0)); final String firstLetter = String.valueOf(firstWord.charAt(0));
log.info("First word: {}", firstWord); log.info("First word: {}", firstWord);
@ -163,7 +164,6 @@ public class LingoController {
final String[] playerTwoMessage = new String[] { firstLetter, playerOne.getUsername() }; final String[] playerTwoMessage = new String[] { firstLetter, playerOne.getUsername() };
sendToPlayer(playerOne, Destinations.OPPONENT_JOINED, playerOneMessage); sendToPlayer(playerOne, Destinations.OPPONENT_JOINED, playerOneMessage);
sendToPlayer(playerTwo, Destinations.OPPONENT_JOINED, playerTwoMessage); sendToPlayer(playerTwo, Destinations.OPPONENT_JOINED, playerTwoMessage);
send(Destinations.GAME_STARTED, new String[] { playerOne.getUsername(), playerTwo.getUsername() });
} }
} }

View File

@ -343,7 +343,6 @@ function start() {
client.subscribe('/topic/gameHosted', onGameHosted); client.subscribe('/topic/gameHosted', onGameHosted);
client.subscribe('/topic/gameJoined', onGameJoined); client.subscribe('/topic/gameJoined', onGameJoined);
client.subscribe('/topic/gameLeft', onGameLeft); client.subscribe('/topic/gameLeft', onGameLeft);
client.subscribe('/topic/gameStarted', onGameStarted);
client.subscribe('/user/topic/opponentJoined', onOpponentJoined); client.subscribe('/user/topic/opponentJoined', onOpponentJoined);
client.subscribe('/user/topic/opponentLeft', onOpponentLeft); client.subscribe('/user/topic/opponentLeft', onOpponentLeft);
client.subscribe('/user/topic/opponentReports', onOpponentReport); client.subscribe('/user/topic/opponentReports', onOpponentReport);
@ -441,7 +440,11 @@ function onGameJoined(message) {
var gameId = game.id; var gameId = game.id;
var playerOne = game.playerOne.username; var playerOne = game.playerOne.username;
var playerTwo = game.playerTwo.username; var playerTwo = game.playerTwo.username;
console.log(playerTwo + ' joined ' + playerOne + "'s game");
var message = playerTwo + ' joined ' + playerOne + "'s game"
console.log(message);
addChatAnnouncement(message);
for (var i = 0; i < vm.games.length; i++) { for (var i = 0; i < vm.games.length; i++) {
if (vm.games[i].id === gameId) { if (vm.games[i].id === gameId) {
vm.games[i].playerTwo = playerTwo; vm.games[i].playerTwo = playerTwo;
@ -449,6 +452,7 @@ function onGameJoined(message) {
break; break;
} }
} }
if (playerTwo === vm.username) { if (playerTwo === vm.username) {
vm.gameId = gameId; vm.gameId = gameId;
} }
@ -480,19 +484,6 @@ function onGameLeft(message) {
} }
} }
function onGameStarted(message) {
var report = JSON.parse(message.body);
var playerOne = report[0];
var playerTwo = report[1];
if (playerOne === vm.username) {
addChatAnnouncement('You are playing with ' + playerTwo);
} else if (playerTwo === vm.username) {
addChatAnnouncement('You are playing with ' + playerOne);
} else {
addChatAnnouncement(playerOne + ' is playing with ' + playerTwo);
}
}
function onOpponentJoined(message) { function onOpponentJoined(message) {
var report = JSON.parse(message.body); var report = JSON.parse(message.body);
var firstLetter = report[0]; var firstLetter = report[0];