Hey,
I have to program the game yahtzee and at some point I have to check if the score selection is correct. It's correct if the input matches the score types and if the score isn't used already.
the code for select score:
Code:
static void select_score (int scores [], int dice [])
{
int i, score;
do
{
printf("Choose a free category to score your roll:\n");
for (i = 0; i < NUM_OF_ROUNDS; i++)
{
printf ("%d\t%s", i + 1, selectable_score_names[i]);
printf (" %s\n", check_score (scores, i) == score_used ? "(used)" : "(unused)");
}
scanf ("%d", &score);
score--;
}
while (! is_valid_score_selection (scores, score));
add_score (score, scores, dice);
}
static int game_ended (int scores [])
{
return 0;
}
And i have to make the is_valid_score_selection.
Also I have to use:
Code:
enum score_type
{
unused = -1,
aces,
twos,
threes,
fours,
fives,
sixes,
three_of_a_kind,
four_of_a_kind,
full_house,
small_straight,
large_straight,
yathzee,
chance,
bonus_upper_part,
total_upper_part,
total_lower_part,
total,
num_of_scores
};
I hope some one can help.