newg_juggle returns bool indicating whether anything changed

This commit is contained in:
ehouse 2006-06-29 03:38:25 +00:00
parent 34a1f737e0
commit 4fd379d663
2 changed files with 10 additions and 5 deletions

View file

@ -225,9 +225,10 @@ deepCopy( NGValue value, const void* closure )
}
}
void
XP_Bool
newg_juggle( NewGameCtx* ngc )
{
XP_Bool changed = XP_FALSE;
XP_U16 nPlayers = ngc->nPlayers;
if ( nPlayers > 1 ) {
@ -238,7 +239,8 @@ newg_juggle( NewGameCtx* ngc )
/* Get a randomly juggled array of numbers 0..nPlayers-1. Then the
number at pos[n] inicates where the entry currently at n should
be. */
if ( randIntArray( pos, nPlayers ) ) {
changed = randIntArray( pos, nPlayers );
if ( changed ) {
/* Deep-copy off to tmp storage. But skip lines that won't be moved
in the juggle. */
@ -261,10 +263,9 @@ newg_juggle( NewGameCtx* ngc )
}
}
}
} else {
XP_LOGF( "%s: no juggle this time", __FUNCTION__ );
}
}
return changed;
} /* newg_juggle */
static void

View file

@ -110,7 +110,11 @@ void newg_colChanged( NewGameCtx* ngc, XP_U16 player, NewGameColumn col,
void newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr,
NGValue value );
void newg_juggle( NewGameCtx* ngc );
/** newg_juggle: Return XP_TRUE if a juggle happened, XP_FALSE if randomness
* dictated that all players stay put. Platforms can call repeatedly until
* true if they want to force change.
*/
XP_Bool newg_juggle( NewGameCtx* ngc );
EXTERN_C_END