mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
add board_canFlip and model_canFlip -- which seem to work though
there's no test that when a single tile is on the board it's not in the middle. Sue me.
This commit is contained in:
parent
3998a23f84
commit
43c34aa466
5 changed files with 30 additions and 4 deletions
|
@ -523,6 +523,13 @@ board_getYOffset( const BoardCtxt* board )
|
||||||
return vsd->offset;
|
return vsd->offset;
|
||||||
} /* board_getYOffset */
|
} /* board_getYOffset */
|
||||||
|
|
||||||
|
XP_Bool
|
||||||
|
board_canFlip( const BoardCtxt* board )
|
||||||
|
{
|
||||||
|
return model_canFlip( board->model, board->selPlayer,
|
||||||
|
TRAY_REVEALED == board->trayVisState );
|
||||||
|
}
|
||||||
|
|
||||||
static XP_U16
|
static XP_U16
|
||||||
adjustOffset( XP_U16 curOffset, XP_S16 zoomBy )
|
adjustOffset( XP_U16 curOffset, XP_S16 zoomBy )
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,6 +78,8 @@ void board_reset( BoardCtxt* board );
|
||||||
XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset );
|
XP_Bool board_setYOffset( BoardCtxt* board, XP_U16 newOffset );
|
||||||
XP_U16 board_getYOffset( const BoardCtxt* board );
|
XP_U16 board_getYOffset( const BoardCtxt* board );
|
||||||
|
|
||||||
|
XP_Bool board_canFlip( const BoardCtxt* board );
|
||||||
|
|
||||||
/* zoomBy: >0: zoom in; < 0: zoom out; 0: query only */
|
/* zoomBy: >0: zoom in; < 0: zoom out; 0: query only */
|
||||||
XP_Bool board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut );
|
XP_Bool board_zoom( BoardCtxt* board, XP_S16 zoomBy, XP_Bool* canInOut );
|
||||||
|
|
||||||
|
|
|
@ -480,13 +480,14 @@ undoFromMoveInfo( ModelCtxt* model, XP_U16 turn, Tile blankTile, MoveInfo* mi )
|
||||||
|
|
||||||
setModelTileRaw( model, col, row, EMPTY_TILE );
|
setModelTileRaw( model, col, row, EMPTY_TILE );
|
||||||
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
||||||
|
--model->vol.nTilesOnBoard;
|
||||||
|
|
||||||
if ( IS_BLANK(tile) ) {
|
if ( IS_BLANK(tile) ) {
|
||||||
tile = blankTile;
|
tile = blankTile;
|
||||||
}
|
}
|
||||||
model_addPlayerTile( model, turn, -1, tile );
|
model_addPlayerTile( model, turn, -1, tile );
|
||||||
}
|
}
|
||||||
|
XP_LOGF( "%s: %d tiles on board", __func__, model->vol.nTilesOnBoard );
|
||||||
adjustScoreForUndone( model, mi, turn );
|
adjustScoreForUndone( model, mi, turn );
|
||||||
} /* undoFromMoveInfo */
|
} /* undoFromMoveInfo */
|
||||||
|
|
||||||
|
@ -842,9 +843,9 @@ model_trayContains( ModelCtxt* model, XP_S16 turn, Tile tile )
|
||||||
} /* model_trayContains */
|
} /* model_trayContains */
|
||||||
|
|
||||||
XP_U16
|
XP_U16
|
||||||
model_getCurrentMoveCount( ModelCtxt* model, XP_S16 turn )
|
model_getCurrentMoveCount( const ModelCtxt* model, XP_S16 turn )
|
||||||
{
|
{
|
||||||
PlayerCtxt* player;
|
const PlayerCtxt* player;
|
||||||
XP_ASSERT( turn >= 0 );
|
XP_ASSERT( turn >= 0 );
|
||||||
player = &model->players[turn];
|
player = &model->players[turn];
|
||||||
return player->nPending;
|
return player->nPending;
|
||||||
|
@ -1104,6 +1105,14 @@ model_getNMoves( const ModelCtxt* model )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XP_Bool
|
||||||
|
model_canFlip( const ModelCtxt* model, XP_U16 turn, XP_Bool trayVisible )
|
||||||
|
{
|
||||||
|
XP_Bool canFlip = 0 < model->vol.nTilesOnBoard
|
||||||
|
|| (trayVisible && (0 < model_getCurrentMoveCount( model, turn )));
|
||||||
|
return canFlip;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
incrPendingTileCountAt( ModelCtxt* model, XP_U16 col, XP_U16 row )
|
incrPendingTileCountAt( ModelCtxt* model, XP_U16 col, XP_U16 row )
|
||||||
{
|
{
|
||||||
|
@ -1229,6 +1238,8 @@ commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles,
|
||||||
setModelTileRaw( model, col, row, tile );
|
setModelTileRaw( model, col, row, tile );
|
||||||
|
|
||||||
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
notifyBoardListeners( model, turn, col, row, XP_FALSE );
|
||||||
|
|
||||||
|
++model->vol.nTilesOnBoard;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)getCurrentMoveScoreIfLegal( model, turn, stream, &score );
|
(void)getCurrentMoveScoreIfLegal( model, turn, stream, &score );
|
||||||
|
@ -1247,6 +1258,7 @@ commitTurn( ModelCtxt* model, XP_S16 turn, TrayTileSet* newTiles,
|
||||||
model_addPlayerTile( model, turn, -1, *newTilesP++ );
|
model_addPlayerTile( model, turn, -1, *newTilesP++ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XP_LOGF( "%s: %d tiles on board", __func__, model->vol.nTilesOnBoard );
|
||||||
return score;
|
return score;
|
||||||
} /* commitTurn */
|
} /* commitTurn */
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ XP_U16 model_numCols( const ModelCtxt* model );
|
||||||
void model_addToCurrentMove( ModelCtxt* model, XP_S16 turn,
|
void model_addToCurrentMove( ModelCtxt* model, XP_S16 turn,
|
||||||
XP_U16 col, XP_U16 row,
|
XP_U16 col, XP_U16 row,
|
||||||
Tile tile, XP_Bool isBlank );
|
Tile tile, XP_Bool isBlank );
|
||||||
XP_U16 model_getCurrentMoveCount( ModelCtxt* model, XP_S16 turn );
|
XP_U16 model_getCurrentMoveCount( const ModelCtxt* model, XP_S16 turn );
|
||||||
|
|
||||||
void model_getCurrentMoveTile( ModelCtxt* model, XP_S16 turn, XP_S16* index,
|
void model_getCurrentMoveTile( ModelCtxt* model, XP_S16 turn, XP_S16* index,
|
||||||
Tile* tile, XP_U16* col, XP_U16* row,
|
Tile* tile, XP_U16* col, XP_U16* row,
|
||||||
|
@ -190,6 +190,10 @@ void model_makeTurnFromMoveInfo( ModelCtxt* model, XP_U16 playerNum,
|
||||||
void model_resetCurrentTurn( ModelCtxt* model, XP_S16 turn );
|
void model_resetCurrentTurn( ModelCtxt* model, XP_S16 turn );
|
||||||
XP_S16 model_getNMoves( const ModelCtxt* model );
|
XP_S16 model_getNMoves( const ModelCtxt* model );
|
||||||
|
|
||||||
|
/* Are there two or more tiles visible */
|
||||||
|
XP_Bool model_canFlip( const ModelCtxt* model, XP_U16 turn,
|
||||||
|
XP_Bool trayVisible );
|
||||||
|
|
||||||
/********************* notification ********************/
|
/********************* notification ********************/
|
||||||
typedef void (*BoardListener)(void* data, XP_U16 turn, XP_U16 col,
|
typedef void (*BoardListener)(void* data, XP_U16 turn, XP_U16 col,
|
||||||
XP_U16 row, XP_Bool added );
|
XP_U16 row, XP_Bool added );
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct ModelVolatiles {
|
||||||
void* trayListenerData;
|
void* trayListenerData;
|
||||||
DictListener dictListenerFunc;
|
DictListener dictListenerFunc;
|
||||||
void* dictListenerData;
|
void* dictListenerData;
|
||||||
|
XP_U16 nTilesOnBoard;
|
||||||
MPSLOT
|
MPSLOT
|
||||||
} ModelVolatiles;
|
} ModelVolatiles;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue