mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
newg_juggle returns bool indicating whether anything changed
This commit is contained in:
parent
5fb3705535
commit
9a52d82e0d
2 changed files with 10 additions and 5 deletions
|
@ -225,9 +225,10 @@ deepCopy( NGValue value, const void* closure )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
XP_Bool
|
||||||
newg_juggle( NewGameCtx* ngc )
|
newg_juggle( NewGameCtx* ngc )
|
||||||
{
|
{
|
||||||
|
XP_Bool changed = XP_FALSE;
|
||||||
XP_U16 nPlayers = ngc->nPlayers;
|
XP_U16 nPlayers = ngc->nPlayers;
|
||||||
|
|
||||||
if ( nPlayers > 1 ) {
|
if ( nPlayers > 1 ) {
|
||||||
|
@ -238,7 +239,8 @@ newg_juggle( NewGameCtx* ngc )
|
||||||
/* Get a randomly juggled array of numbers 0..nPlayers-1. Then the
|
/* Get a randomly juggled array of numbers 0..nPlayers-1. Then the
|
||||||
number at pos[n] inicates where the entry currently at n should
|
number at pos[n] inicates where the entry currently at n should
|
||||||
be. */
|
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
|
/* Deep-copy off to tmp storage. But skip lines that won't be moved
|
||||||
in the juggle. */
|
in the juggle. */
|
||||||
|
@ -261,10 +263,9 @@ newg_juggle( NewGameCtx* ngc )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
XP_LOGF( "%s: no juggle this time", __FUNCTION__ );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return changed;
|
||||||
} /* newg_juggle */
|
} /* newg_juggle */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -110,7 +110,11 @@ void newg_colChanged( NewGameCtx* ngc, XP_U16 player, NewGameColumn col,
|
||||||
void newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr,
|
void newg_attrChanged( NewGameCtx* ngc, NewGameAttr attr,
|
||||||
NGValue value );
|
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
|
EXTERN_C_END
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue