Commit 360234b3 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Refuse to impute a game if it leads to a petit sec.

parent 5f64c57d
Pipeline #174968 failed with stages
in 80 minutes and 57 seconds
......@@ -653,6 +653,25 @@ counter_and_game_impute (TarotCounter * counter,
}
if (energy < 0.5)
{
TarotPlayer owners[78];
for (i = 0; i < 78; i++)
{
owners[i] = (TarotPlayer) (-1);
}
for (i = 0; i < current_solution.n_remaining; i++)
{
c = current_solution.cards[i].card;
p = current_solution.cards[i].assigned;
assert (owners[c] == (TarotPlayer) (-1));
owners[c] = p;
}
for (i = TAROT_PETIT + 1;
i <= TAROT_TWENTYONE && owners[i] != owners[TAROT_PETIT]; i++)
;
if (i > TAROT_TWENTYONE)
{
return TAROT_IMPUTATION_FAILED;
}
for (i = 0; i < current_solution.n_remaining; i++)
{
c = current_solution.cards[i].card;
......@@ -672,7 +691,7 @@ counter_and_game_impute (TarotCounter * counter,
if (game_assign_missing_card (game, c, p) != 0
|| counter_assign_missing_card (counter, c, p) != 0)
{
assert (0);
return TAROT_IMPUTATION_FAILED;
}
}
else if (p == TAROT_COUNTER_CARD_OWNER_DISCARDED)
......@@ -681,7 +700,7 @@ counter_and_game_impute (TarotCounter * counter,
if (game_assign_missing_card (game, c, p) != 0
|| counter_assign_missing_card (counter, c, p) != 0)
{
assert (0);
return TAROT_IMPUTATION_FAILED;
}
}
}
......
......@@ -171,6 +171,10 @@ hands_assign_missing_card (TarotHandsHandle * hands, TarotCard card,
if (error == 0 && hand_size (&(hands->hands[player])) >= n_remaining)
{
hands->known[player] = 1;
if (hand_has_petit_sec (&(hands->hands[player])))
{
error = 1;
}
}
return error;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment