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
This commit is contained in:
mdb
2001-10-18 02:18:47 +00:00
parent 1b5809f3fa
commit 72e0998b6f
@@ -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