Commit f4214265 authored by Chris's avatar Chris
Browse files

clear_held_values() created, which clears the held state of all dice in game state

parent 4ac0f0cd
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -56,3 +56,9 @@ int set_die_held(game_context *ctx, unsigned int index, unsigned int held) {

    return error;
}

void clear_held_values(game_context *ctx) {
    for (int i = 0; i < NUM_DICE; i++) {
        ctx->game_state.dice[i].held = 0;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -26,5 +26,6 @@ unsigned int generate_single_die_roll(FILE *urandom_file);
void generate_dice_roll(game_context *ctx, unsigned int *out_dice_values, int save_in_game_state);
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, int animation_seconds);
void clear_held_values(game_context *ctx);

#endif //DICELOGIC_H
+2 −4
Original line number Diff line number Diff line
@@ -15,10 +15,8 @@ int main() {

	printf("yaht.c\n");

	// un-hold all dice todo make this a function
	for (int i = 0; i < NUM_DICE; i++) {
		ctx.game_state.dice[i].held = 0;
	}
	// un-hold all dice
	clear_held_values(&ctx);

	// first roll
	roll_and_print(&ctx, next_roll, 0);