Loading gamelogic.c +12 −7 Original line number Diff line number Diff line Loading @@ -132,7 +132,6 @@ unsigned int calculate_selection_score(game_context *ctx, char *selection) { points_awarded = ctx->game_state.scorecard.sixes; } else if (strcasecmp(selection, "three of a kind") == 0) { // sum all dice if 3 of a kind match; 0 otherwise // printf("not implemented, scoring 0 for now"); if (n_of_a_kind(ctx->game_state.dice, NUM_DICE, 3, 0)) { ctx->game_state.scorecard.three_of_a_kind = sum_dice(ctx->game_state.dice); } else { Loading Loading @@ -178,7 +177,6 @@ unsigned int calculate_selection_score(game_context *ctx, char *selection) { points_awarded = ctx->game_state.scorecard.large_straight; } else if (strcasecmp(selection, "yahtc") == 0) { // 50 points for five of a kind; 0 otherwise printf("not implemented, scoring 0 for now"); if (n_of_a_kind(ctx->game_state.dice, NUM_DICE, NUM_DICE, 0)) { ctx->game_state.scorecard.yahtc = 50; } else { Loading Loading @@ -323,17 +321,24 @@ unsigned int n_of_a_kind(struct die_st *dice, unsigned int num_dice, unsigned in unsigned int n_in_a_row(struct die_st *dice, unsigned int num_dice, unsigned int n) { // testing only: large straight (note: this scores 0 despite being valid!) BUT this does register as a small straight. // dice[0].value = 6; // dice[1].value = 2; // dice[2].value = 5; dice[0].value = 6; dice[1].value = 2; dice[2].value = 5; dice[3].value = 4; dice[4].value = 3; // testing only: small straight // dice[0].value = 2; // dice[1].value = 3; // dice[2].value = 3; // dice[3].value = 4; // dice[4].value = 3; // dice[4].value = 1; if (n > num_dice) { printf("n_in_a_row(): error: n is greater than num_dice"); } for (unsigned int i = 0; i < num_dice - 1; i++) { for (unsigned int i = 0; i < num_dice; i++) { unsigned int sequence_count = 1; unsigned int next_in_sequence = dice[i].value + 1; for (unsigned int j = 0; j < num_dice; j++) { Loading Loading
gamelogic.c +12 −7 Original line number Diff line number Diff line Loading @@ -132,7 +132,6 @@ unsigned int calculate_selection_score(game_context *ctx, char *selection) { points_awarded = ctx->game_state.scorecard.sixes; } else if (strcasecmp(selection, "three of a kind") == 0) { // sum all dice if 3 of a kind match; 0 otherwise // printf("not implemented, scoring 0 for now"); if (n_of_a_kind(ctx->game_state.dice, NUM_DICE, 3, 0)) { ctx->game_state.scorecard.three_of_a_kind = sum_dice(ctx->game_state.dice); } else { Loading Loading @@ -178,7 +177,6 @@ unsigned int calculate_selection_score(game_context *ctx, char *selection) { points_awarded = ctx->game_state.scorecard.large_straight; } else if (strcasecmp(selection, "yahtc") == 0) { // 50 points for five of a kind; 0 otherwise printf("not implemented, scoring 0 for now"); if (n_of_a_kind(ctx->game_state.dice, NUM_DICE, NUM_DICE, 0)) { ctx->game_state.scorecard.yahtc = 50; } else { Loading Loading @@ -323,17 +321,24 @@ unsigned int n_of_a_kind(struct die_st *dice, unsigned int num_dice, unsigned in unsigned int n_in_a_row(struct die_st *dice, unsigned int num_dice, unsigned int n) { // testing only: large straight (note: this scores 0 despite being valid!) BUT this does register as a small straight. // dice[0].value = 6; // dice[1].value = 2; // dice[2].value = 5; dice[0].value = 6; dice[1].value = 2; dice[2].value = 5; dice[3].value = 4; dice[4].value = 3; // testing only: small straight // dice[0].value = 2; // dice[1].value = 3; // dice[2].value = 3; // dice[3].value = 4; // dice[4].value = 3; // dice[4].value = 1; if (n > num_dice) { printf("n_in_a_row(): error: n is greater than num_dice"); } for (unsigned int i = 0; i < num_dice - 1; i++) { for (unsigned int i = 0; i < num_dice; i++) { unsigned int sequence_count = 1; unsigned int next_in_sequence = dice[i].value + 1; for (unsigned int j = 0; j < num_dice; j++) { Loading