Merge pull request #23 from greno4ka/windetect
Detect possible win situation
This commit is contained in:
commit
923063a6cc
14
src/game.c
14
src/game.c
@ -206,8 +206,14 @@ void game_end() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool game_won() {
|
bool game_won() {
|
||||||
return(stack_length(deck->foundation[0]) == 13 &&
|
// if any card is covered, game is not won
|
||||||
stack_length(deck->foundation[1]) == 13 &&
|
for (int i = 0; i < MANEUVRE_STACKS_NUMBER; i++)
|
||||||
stack_length(deck->foundation[2]) == 13 &&
|
for (struct stack *j = deck->maneuvre[i]; j!= NULL; j = j->next)
|
||||||
stack_length(deck->foundation[3]) == 13);
|
if (j->card->face == COVERED)
|
||||||
|
return false;
|
||||||
|
// else look in stock and waste pile
|
||||||
|
if (stack_empty(deck->stock) &&
|
||||||
|
stack_empty(deck->waste_pile))
|
||||||
|
return true;
|
||||||
|
else return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user