Skip to content
Browse files

Merge pull request #20 from mdwoolley/master

Bug fix
  • Loading branch information...
2 parents b9d7118 + d990794 commit 4c305b0815c27d43618923088b42a7b6ea3ba303 @timwindsor timwindsor committed
View
2 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/Constants.java
@@ -18,7 +18,7 @@
public interface Constants {
- public static final String MYAPP_VERSION = "1.0.1";
+ public static final String MYAPP_VERSION = "1.0.2";
public static final String MYAPP_NAME = "Touch Tic Tac Toe";
public static final String [] WINNER_MESSAGE = {"YOU HAVE WON!!","Touch devices to start new game"};
View
4 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/game/GameState.java
@@ -103,6 +103,7 @@ public void updateTileThisPlayer(int tile, int players_symbol) {
tile_states[tile] = players_symbol;
setUiState(tile, players_symbol, true);
tile_count_this_turn++;
+ Utilities.log("XXXX updateTileThisPlayer tile_count_this_turn=" + tile_count_this_turn);
_listener.tileChanged(tile);
tile_set = true;
if (hasWon(players_symbol)) {
@@ -126,6 +127,9 @@ public void updateTileThisPlayer(int tile, int players_symbol) {
tile_states[tile] = Constants.TILE_STATE_BLANK;
setUiState(tile, Constants.TILE_STATE_BLANK, true);
tile_set = false;
+ tile_count_this_turn--;
+ _listener.tileChanged(tile);
+ Utilities.log("XXXX updateTileThisPlayer tile_count_this_turn=" + tile_count_this_turn);
} else {
Utilities.log("XXXX updateTileThisPlayer ignoring request as tile contains other player's symbol or is locked from previous turn");
tile_set = false;
View
13 NFC/TouchTicTacToe/src/nfc/sample/tictactoe/ui/GameScreen.java
@@ -277,10 +277,21 @@ public void tileChanged(int tile) {
turn_over.set_tile_changed(tile);
turn_over.set_symbol_played(_symbol);
if(!game_state.isGame_over() && !game_state.isBoardFull()) {
- setStatusMessage("Touch devices to pass turn to other player");
+ Utilities.log("XXXX tileChanged tile_count_this_turn=" + game_state.getTile_count_this_turn());
if(game_state.getTile_count_this_turn() == 1) {
// get ready to send the turn over message when players touch devices again
+ setStatusMessage("Touch devices to pass turn to other player");
prepTurnOver();
+ } else {
+ if(game_state.getTile_count_this_turn() == 0) {
+ // tile was unset so switch off messaging
+ try {
+ proto.disableMessaging();
+ } catch(NFCException e) {
+ Utilities.log("XXXX " + e.getClass().getName() + ":" + e.getMessage());
+ setStatusMessage("Error: please try again");
+ }
+ }
}
}
}

0 comments on commit 4c305b0

Please sign in to comment.
Something went wrong with that request. Please try again.