add pool_containsTiles()

This commit is contained in:
Eric House 2012-05-01 07:49:41 -07:00
parent 4ffdeefe3b
commit 89ca45357a
2 changed files with 18 additions and 0 deletions

View file

@ -208,6 +208,22 @@ pool_removeTiles( PoolContext* pool, const TrayTileSet* tiles )
XP_LOGF( "%s: %d tiles left in pool", __func__, pool->numTilesLeft );
} /* pool_removeTiles */
XP_Bool
pool_containsTiles( const PoolContext* pool, const TrayTileSet* tiles )
{
XP_Bool allThere = XP_TRUE;
XP_U16 ii;
XP_U8 counts[pool->numFaces];
XP_MEMCPY( counts, pool->lettersLeft, sizeof(counts) );
/* In case we have duplicates, make count of each type */
for ( ii = 0; allThere && ii < tiles->nTiles; ++ii ) {
allThere = 0 <= --counts[tiles->tiles[ii]];
}
return allThere;
}
XP_U16
pool_getNTilesLeft( PoolContext* pool )
{

View file

@ -28,6 +28,8 @@ void pool_requestTiles( PoolContext* pool, Tile* tiles,
/*in out*/ XP_U8* maxNum );
void pool_replaceTiles( PoolContext* pool, const TrayTileSet* tiles );
void pool_removeTiles( PoolContext* pool, const TrayTileSet* tiles );
XP_Bool pool_containsTiles( const PoolContext* pool,
const TrayTileSet* tiles );
XP_U16 pool_getNTilesLeft( PoolContext* pool );
XP_U16 pool_getNTilesLeftFor( PoolContext* pool, Tile tile );