aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yhtz.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/yhtz.c b/yhtz.c
index 9f1ff36..d8d3b2c 100644
--- a/yhtz.c
+++ b/yhtz.c
@@ -74,17 +74,18 @@ uint16_t roll_die(uint16_t* seed) {
}
void print_dice(yhtz_state* state) {
- char* label = "die %d ";
+ char* label = " %d ";
char* top = ",---,";
char* mid = "| %d | ";
char* bot = "'---'";
- for (int i = 0; i < 5; i++)
- printf(label, i);
printf("\n%s %s %s %s %s\n", top, top, top, top, top);
for (int i = 0; i < 5; i++)
printf(mid, GET_DIE(state, i));
printf("\n%s %s %s %s %s\n", bot, bot, bot, bot, bot);
+ for (int i = 0; i < 5; i++)
+ printf(label, i);
+ printf("\n\n");
}
void ask_for_rerolls(yhtz_state* state) {
@@ -102,7 +103,7 @@ void ask_for_rerolls(yhtz_state* state) {
}
}
-void do_turn(yhtz_state* state) {
+void do_roll(yhtz_state* state) {
int roll = GET_ROLL(state);
bool reset = false;
@@ -120,6 +121,15 @@ void do_turn(yhtz_state* state) {
SET_ROLL(state, ++roll);
}
+void do_turn(yhtz_state* state) {
+ for (int i = 0; i < 3; i++) {
+ do_roll(state);
+ print_dice(state);
+ if (i < 2)
+ ask_for_rerolls(state);
+ }
+}
+
void init_yhtz_state(yhtz_state* state) {
state->topflag_w_roll = 0;
state->topscore = 0;
@@ -145,12 +155,4 @@ void main() {
do_turn(&y);
- printf("new roll: %d\n", GET_ROLL((&y)));
-
- print_dice(&y);
-
- ask_for_rerolls(&y);
- do_turn(&y);
- printf("newer roll: %d\n", GET_ROLL((&y)));
- print_dice(&y);
}