From 72e0998b6fb96295f54970e1141136ea14192e48 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 18 Oct 2001 02:18:47 +0000 Subject: [PATCH] Set things up if we show up in the room and its our turn. Also do the right thing if we had no piecens to place, but our act of placing a tile freed up one of our piecens for placement. git-svn-id: https://samskivert.googlecode.com/svn/trunk@371 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../atlanti/client/AtlantiController.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/projects/atlanti/src/java/com/samskivert/atlanti/client/AtlantiController.java b/projects/atlanti/src/java/com/samskivert/atlanti/client/AtlantiController.java index cb98c1b0..b9b768fa 100644 --- a/projects/atlanti/src/java/com/samskivert/atlanti/client/AtlantiController.java +++ b/projects/atlanti/src/java/com/samskivert/atlanti/client/AtlantiController.java @@ -66,8 +66,10 @@ public class VenisonController _panel.board.setTiles(_venobj.tiles); _panel.board.setPiecens(_venobj.piecens); - // TBD: check to see if it's our turn and set things up - // accordingly + // if it's our turn, set the tile to be placed + if (_venobj.turnHolder.equals(_self.username)) { + _panel.board.setTileToBePlaced(_venobj.currentTile); + } } // documentation inherited @@ -121,8 +123,18 @@ public class VenisonController { if (event.getName().equals(VenisonObject.PIECENS)) { // a piecen was removed, update the board - Log.info("Clearing piecen " + event.getKey() + "."); _panel.board.clearPiecen(event.getKey()); + + // if we just freed up our only playable piecen... + int pcount = TileUtil.countPiecens(_venobj.piecens, _selfIndex); + if (pcount == (PIECENS_PER_PLAYER-1) && + // ...and it's also our turn... + _venobj.turnHolder.equals(_self.username)) { + // ...reenable piecen placement + _panel.board.enablePiecenPlacement(); + // and, enable the noplace button + _panel.noplace.setEnabled(true); + } } } @@ -138,14 +150,18 @@ public class VenisonController _ctx.getDObjectManager().postEvent(mevt); // if we have no piecens to place, we immediately disable - // piecen placement in the board + // piecen placement in the board and expect that the server + // will end our turn (however, it may determine that our + // placement freed up one of our pieces which we will react to + // and reenable piecen placement) int pcount = TileUtil.countPiecens(_venobj.piecens, _selfIndex); if (pcount >= PIECENS_PER_PLAYER) { _panel.board.cancelPiecenPlacement(); - } - // enable the noplace button - _panel.noplace.setEnabled(true); + } else { + // otherwise, enable the noplace button + _panel.noplace.setEnabled(true); + } } else if (action.getActionCommand().equals(PIECEN_PLACED)) { // the user placed a piecen on the tile. grab the piecen from