add summary when no tiles played too

This commit is contained in:
ehouse 2004-02-27 06:19:31 +00:00
parent f7bd5b703e
commit 4a3d85e058

View file

@ -87,7 +87,7 @@ scoreCurrentMove( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream )
/* recalc goes here */ /* recalc goes here */
score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream, score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream,
XP_TRUE, (WordNotifierInfo*)NULL ); XP_TRUE, (WordNotifierInfo*)NULL );
XP_ASSERT( score >= 0 || score == ILLEGAL_MOVE_SCORE ); XP_ASSERT( score >= 0 || score == ILLEGAL_MOVE_SCORE );
player->curMoveScore = score; player->curMoveScore = score;
@ -114,7 +114,7 @@ adjustScoreForUndone( ModelCtxt* model, MoveInfo* mi, XP_U16 turn )
XP_Bool XP_Bool
model_checkMoveLegal( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream, model_checkMoveLegal( ModelCtxt* model, XP_S16 turn, XWStreamCtxt* stream,
WordNotifierInfo* notifyInfo ) WordNotifierInfo* notifyInfo )
{ {
XP_S16 score; XP_S16 score;
score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream, XP_FALSE, score = checkScoreMove( model, turn, (EngineCtxt*)NULL, stream, XP_FALSE,
@ -130,7 +130,7 @@ invalidateScore( ModelCtxt* model, XP_S16 turn )
XP_Bool XP_Bool
getCurrentMoveScoreIfLegal( ModelCtxt* model, XP_S16 turn, getCurrentMoveScoreIfLegal( ModelCtxt* model, XP_S16 turn,
XWStreamCtxt* stream, XP_S16* score ) XWStreamCtxt* stream, XP_S16* score )
{ {
PlayerCtxt* player = &model->players[turn]; PlayerCtxt* player = &model->players[turn];
if ( !player->curMoveValid ) { if ( !player->curMoveValid ) {
@ -153,7 +153,7 @@ model_getPlayerScore( ModelCtxt* model, XP_S16 player )
*/ */
void void
model_figureFinalScores( ModelCtxt* model, XP_S16* finalScoresP, model_figureFinalScores( ModelCtxt* model, XP_S16* finalScoresP,
XP_S16* tilePenalties ) XP_S16* tilePenalties )
{ {
XP_S16 i, j; XP_S16 i, j;
XP_S16 penalties[MAX_NUM_PLAYERS]; XP_S16 penalties[MAX_NUM_PLAYERS];
@ -217,8 +217,8 @@ model_figureFinalScores( ModelCtxt* model, XP_S16* finalScoresP,
*/ */
static XP_S16 static XP_S16
checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine, checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
XWStreamCtxt* stream, XP_Bool silent, XWStreamCtxt* stream, XP_Bool silent,
WordNotifierInfo* notifyInfo ) WordNotifierInfo* notifyInfo )
{ {
XP_Bool isHorizontal; XP_Bool isHorizontal;
XP_S16 score = ILLEGAL_MOVE_SCORE; XP_S16 score = ILLEGAL_MOVE_SCORE;
@ -227,10 +227,13 @@ checkScoreMove( ModelCtxt* model, XP_S16 turn, EngineCtxt* engine,
XP_ASSERT( player->nPending <= MAX_TRAY_TILES ); XP_ASSERT( player->nPending <= MAX_TRAY_TILES );
if ( player->nPending == 0 ) { if ( player->nPending == 0 ) {
return 0; score = 0;
}
if ( tilesInLine( model, turn, &isHorizontal ) ) { if ( !!stream ) {
formatSummary( stream, model, 0 );
}
} else if ( tilesInLine( model, turn, &isHorizontal ) ) {
MoveInfo moveInfo; MoveInfo moveInfo;
normalizeMoves( model, turn, isHorizontal, &moveInfo ); normalizeMoves( model, turn, isHorizontal, &moveInfo );
@ -273,7 +276,7 @@ tilesInLine( ModelCtxt* model, XP_S16 turn, XP_Bool* isHorizontal )
void void
normalizeMoves( ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal, normalizeMoves( ModelCtxt* model, XP_S16 turn, XP_Bool isHorizontal,
MoveInfo* moveInfo ) MoveInfo* moveInfo )
{ {
XP_S16 lowCol, i, j, thisCol; /* unsigned is a problem on palm */ XP_S16 lowCol, i, j, thisCol; /* unsigned is a problem on palm */
PlayerCtxt* player = &model->players[turn]; PlayerCtxt* player = &model->players[turn];
@ -440,8 +443,8 @@ isLegalMove( ModelCtxt* model, MoveInfo* mInfo, XP_Bool silent )
XP_U16 XP_U16
figureMoveScore( ModelCtxt* model, MoveInfo* moveInfo, EngineCtxt* engine, figureMoveScore( ModelCtxt* model, MoveInfo* moveInfo, EngineCtxt* engine,
XWStreamCtxt* stream, XP_Bool silent, XWStreamCtxt* stream, XP_Bool silent,
WordNotifierInfo* notifyInfo ) WordNotifierInfo* notifyInfo )
{ {
XP_U16 col, row; XP_U16 col, row;
XP_U16* incr; XP_U16* incr;
@ -732,7 +735,7 @@ find_end( ModelCtxt* model, XP_U16 col, XP_U16 row, XP_Bool isHorizontal )
static void static void
wordScoreFormatterInit( WordScoreFormatter* fmtr, XWStreamCtxt* stream, wordScoreFormatterInit( WordScoreFormatter* fmtr, XWStreamCtxt* stream,
DictionaryCtxt* dict ) DictionaryCtxt* dict )
{ {
XP_ASSERT( !!stream ); XP_ASSERT( !!stream );
fmtr->stream = stream; fmtr->stream = stream;
@ -746,7 +749,7 @@ wordScoreFormatterInit( WordScoreFormatter* fmtr, XWStreamCtxt* stream,
static void static void
wordScoreFormatterAddTile( WordScoreFormatter* fmtr, Tile tile, wordScoreFormatterAddTile( WordScoreFormatter* fmtr, Tile tile,
XP_U16 tileMultiplier, XP_Bool isBlank ) XP_U16 tileMultiplier, XP_Bool isBlank )
{ {
XP_UCHAR buf[4]; XP_UCHAR buf[4];
XP_UCHAR* fullBufPtr; XP_UCHAR* fullBufPtr;
@ -793,7 +796,7 @@ wordScoreFormatterFinish( WordScoreFormatter* fmtr, Tile* word )
static void static void
formatWordScore( XWStreamCtxt* stream, XP_U16 wordScore, formatWordScore( XWStreamCtxt* stream, XP_U16 wordScore,
XP_U16 moveMultiplier ) XP_U16 moveMultiplier )
{ {
if ( wordScore > 0 ) { if ( wordScore > 0 ) {
XP_U16 multipliedScore = wordScore * moveMultiplier; XP_U16 multipliedScore = wordScore * moveMultiplier;