Loading gamelogic.c +3 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ #include "graphics.h" #include "utils.h" const int NUM_DICE = 5; const unsigned int NUM_DICE = 5; const int SCORE_UNSCORED = -1; void roll_and_print(game_context *ctx, unsigned int *out_dice_values, unsigned int animation_seconds) { Loading Loading @@ -70,7 +70,7 @@ void clear_held_values(game_context *ctx) { unsigned int calculate_score(struct scorecard_st *scorecard, char *scoring_selection) { // discern score action based on the scoring selection return 0; } void initialize_scorecard(struct scorecard_st *scorecard) { Loading @@ -90,7 +90,7 @@ void initialize_scorecard(struct scorecard_st *scorecard) { = SCORE_UNSCORED; } unsigned int scorecard_is_not_full(struct scorecard_st *scorecard) { unsigned int can_continue_playing(struct scorecard_st *scorecard) { return scorecard->aces == SCORE_UNSCORED || scorecard->twos == SCORE_UNSCORED || scorecard->threes == SCORE_UNSCORED Loading gamelogic.h +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ #ifndef DICELOGIC_H #define DICELOGIC_H extern const int NUM_DICE; extern const unsigned int NUM_DICE; extern const int SCORE_UNSCORED; //const unsigned int MAX_TURNS = 3; Loading Loading @@ -49,7 +49,7 @@ void generate_dice_roll(game_context *ctx, unsigned int *out_dice_values, int sa int set_die_held(game_context *ctx, unsigned int index, unsigned int held); void roll_and_print(game_context *ctx, unsigned int *out_dice_values, unsigned int animation_seconds); void clear_held_values(game_context *ctx); unsigned int scorecard_is_not_full(struct scorecard_st *scorecard); unsigned int can_continue_playing(struct scorecard_st *scorecard); // scorecard functions unsigned int calculate_score(struct scorecard_st *scorecard, char *scoring_selection); Loading yaht.c +3 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ int main(void) { const char *selected_action = menu_prompt(items, num_menu_items); if (strcasecmp(selected_action, "start") == 0) { while (scorecard_is_not_full(&ctx.game_state.scorecard)) { while (can_continue_playing(&ctx.game_state.scorecard)) { take_turn(&ctx, NUM_DICE); } } else if (strcasecmp(selected_action, "demo") == 0) { Loading Loading @@ -76,11 +76,13 @@ void take_turn(game_context *ctx, unsigned int num_dice) { const char *player_action = menu_prompt(in_turn_menu, num_menu_items); if (strcasecmp(player_action, "enter_hold_selection") == 0) { // enter the menu for which dice to hold } else if (strcasecmp(player_action, "roll") == 0) { printf("Rolling again...\n"); can_move_on = 1; } else if (strcasecmp(player_action, "score") == 0) { // enter the score menu } } } Loading Loading
gamelogic.c +3 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ #include "graphics.h" #include "utils.h" const int NUM_DICE = 5; const unsigned int NUM_DICE = 5; const int SCORE_UNSCORED = -1; void roll_and_print(game_context *ctx, unsigned int *out_dice_values, unsigned int animation_seconds) { Loading Loading @@ -70,7 +70,7 @@ void clear_held_values(game_context *ctx) { unsigned int calculate_score(struct scorecard_st *scorecard, char *scoring_selection) { // discern score action based on the scoring selection return 0; } void initialize_scorecard(struct scorecard_st *scorecard) { Loading @@ -90,7 +90,7 @@ void initialize_scorecard(struct scorecard_st *scorecard) { = SCORE_UNSCORED; } unsigned int scorecard_is_not_full(struct scorecard_st *scorecard) { unsigned int can_continue_playing(struct scorecard_st *scorecard) { return scorecard->aces == SCORE_UNSCORED || scorecard->twos == SCORE_UNSCORED || scorecard->threes == SCORE_UNSCORED Loading
gamelogic.h +2 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ #ifndef DICELOGIC_H #define DICELOGIC_H extern const int NUM_DICE; extern const unsigned int NUM_DICE; extern const int SCORE_UNSCORED; //const unsigned int MAX_TURNS = 3; Loading Loading @@ -49,7 +49,7 @@ void generate_dice_roll(game_context *ctx, unsigned int *out_dice_values, int sa int set_die_held(game_context *ctx, unsigned int index, unsigned int held); void roll_and_print(game_context *ctx, unsigned int *out_dice_values, unsigned int animation_seconds); void clear_held_values(game_context *ctx); unsigned int scorecard_is_not_full(struct scorecard_st *scorecard); unsigned int can_continue_playing(struct scorecard_st *scorecard); // scorecard functions unsigned int calculate_score(struct scorecard_st *scorecard, char *scoring_selection); Loading
yaht.c +3 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ int main(void) { const char *selected_action = menu_prompt(items, num_menu_items); if (strcasecmp(selected_action, "start") == 0) { while (scorecard_is_not_full(&ctx.game_state.scorecard)) { while (can_continue_playing(&ctx.game_state.scorecard)) { take_turn(&ctx, NUM_DICE); } } else if (strcasecmp(selected_action, "demo") == 0) { Loading Loading @@ -76,11 +76,13 @@ void take_turn(game_context *ctx, unsigned int num_dice) { const char *player_action = menu_prompt(in_turn_menu, num_menu_items); if (strcasecmp(player_action, "enter_hold_selection") == 0) { // enter the menu for which dice to hold } else if (strcasecmp(player_action, "roll") == 0) { printf("Rolling again...\n"); can_move_on = 1; } else if (strcasecmp(player_action, "score") == 0) { // enter the score menu } } } Loading