Add code to count piecens from the tile state rather than the piecen set.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@370 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-10-18 02:17:54 +00:00
parent d520132440
commit 1b5809f3fa
@@ -1,5 +1,5 @@
//
// $Id: TileUtil.java,v 1.10 2001/10/17 23:27:52 mdb Exp $
// $Id: TileUtil.java,v 1.11 2001/10/18 02:17:54 mdb Exp $
package com.threerings.venison;
@@ -523,9 +523,36 @@ public class TileUtil implements TileCodes
return (tidx >= 0) ? (VenisonTile)tiles.get(tidx) : null;
}
/**
* Returns the number of piecens on the board owned the specified
* player. This can be used when we need to count piecens and the
* server potentially hasn't gotten around to processing piecen
* removal events quite yet.
*
* @param tiles a list of the tiles on the board.
* @param playerIndex the index of the player whose piecen count is
* desired.
*/
public static int countPiecens (List tiles, int playerIndex)
{
int count = 0;
for (int i = 0; i < tiles.size(); i++) {
VenisonTile tile = (VenisonTile)tiles.get(i);
if (tile.piecen != null &&
tile.piecen.owner == playerIndex) {
count++;
}
}
return count;
}
/**
* Returns the number of piecens on the board owned the specified
* player.
*
* @param piecens the piecens set from the game object.
* @param playerIndex the index of the player whose piecen count is
* desired.
*/
public static int countPiecens (DSet piecens, int playerIndex)
{