allow long-tap lookup of pending words too

When a word's been formed as part of the current turn, but not yet
committed, allow long-tap to trigger an offer to look it up online same
as for already-committed words. Allows checking the legality of
potential plays AND figuring WTF the hint feature just suggested.
This commit is contained in:
Eric House 2019-04-05 11:54:58 -07:00
parent 48880281dc
commit fec0124f8c
5 changed files with 44 additions and 32 deletions

View file

@ -1315,20 +1315,24 @@ timerFiredForPen( BoardCtxt* board )
#ifdef XWFEATURE_RAISETILE
draw = dragDropSetAdd( board );
#endif
} else {
}
/* We calculate words even for a pending tile set, meaning
dragDrop might be happening too. */
XP_Bool listWords = XP_FALSE;
#ifdef XWFEATURE_BOARDWORDS
#ifdef XWFEATURE_BOARDWORDS /* here it is */
XP_U16 modelCol, modelRow;
flipIf( board, col, row, &modelCol, &modelRow );
listWords = model_getTile( board->model, modelCol, modelRow,
XP_TRUE, board->selPlayer, NULL,
NULL, NULL, NULL );
if ( listWords ) {
XP_LOGF( "%s(): listWords came back true", __func__ );
XWStreamCtxt* stream =
mem_stream_make_raw( MPPARM(board->mpool)
dutil_getVTManager(board->dutil) );
model_listWordsThrough( board->model, modelCol, modelRow,
stream );
board->selPlayer, stream );
util_cellSquareHeld( board->util, stream );
stream_destroy( stream );
}
@ -1345,7 +1349,6 @@ timerFiredForPen( BoardCtxt* board )
#endif
}
}
}
board->penTimerFired = XP_TRUE;
}
} else if ( board->penDownObject == OBJ_SCORE ) {

View file

@ -1708,13 +1708,13 @@ commitTurn( ModelCtxt* model, XP_S16 turn, const TrayTileSet* newTiles,
PlayerCtxt* player = &model->players[turn];
if ( useStack ) {
MoveInfo moveInfo = {0};
XP_Bool isHorizontal;
#ifdef DEBUG
XP_Bool inLine =
#endif
tilesInLine( model, turn, &isHorizontal );
XP_ASSERT( inLine );
MoveInfo moveInfo = {0};
normalizeMoves( model, turn, isHorizontal, &moveInfo );
stack_addMove( model->vol.stack, turn, &moveInfo, newTiles );
@ -2396,11 +2396,20 @@ listWordsThrough( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal),
* How? Undo backwards until we find the move that placed that tile.*/
void
model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
XWStreamCtxt* stream )
XP_S16 turn, XWStreamCtxt* stream )
{
ModelCtxt* tmpModel = makeTmpModel( model, NULL, NULL, NULL, NULL );
copyStack( model, tmpModel->vol.stack, model->vol.stack );
XP_Bool isHorizontal;
if ( tilesInLine( model, turn, &isHorizontal ) ) {
MoveInfo moveInfo = {0};
normalizeMoves( model, turn, isHorizontal, &moveInfo );
model_makeTurnFromMoveInfo( tmpModel, turn, &moveInfo );
TrayTileSet newTiles = {0};
commitTurn( tmpModel, turn, &newTiles, NULL, NULL, XP_TRUE );
}
XP_ASSERT( !!stream );
StackCtxt* stack = tmpModel->vol.stack;
XP_U16 nEntriesBefore = stack_getNEntries( stack );

View file

@ -282,7 +282,7 @@ XP_Bool model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
LastMoveInfo* info );
#ifdef XWFEATURE_BOARDWORDS
void model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
XWStreamCtxt* stream );
XP_S16 turn, XWStreamCtxt* stream );
#endif
/* Have there been too many passes (so game should end)? */

View file

@ -90,7 +90,7 @@ struct ModelCtxt {
void invalidateScore( ModelCtxt* model, XP_S16 player );
XP_Bool tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal );
void normalizeMoves( ModelCtxt* model, XP_S16 turn,
void normalizeMoves( const ModelCtxt* model, XP_S16 turn,
XP_Bool isHorizontal, MoveInfo* moveInfo );
void adjustScoreForUndone( ModelCtxt* model, MoveInfo* mi, XP_U16 turn );
#ifdef CPLUS

View file

@ -277,15 +277,15 @@ tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal )
} /* tilesInLine */
void
normalizeMoves( ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal,
normalizeMoves( const ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal,
MoveInfo* moveInfo )
{
XP_S16 lowCol, ii, jj, thisCol; /* unsigned is a problem on palm */
PlayerCtxt* player = &model->players[turn];
const PlayerCtxt* player = &model->players[turn];
XP_U16 nTiles = player->nPending;
XP_S16 lastTaken;
short lowIndex = 0;
PendingTile* pt;
const PendingTile* pt;
moveInfo->isHorizontal = isHorizontal;
moveInfo->nTiles = (XP_U8)nTiles;