From 192119eea2ebca62f8055c1aa1ce24a540574172 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Sun, 6 Apr 2025 12:04:55 +0000 Subject: [PATCH] allow another monster + refactor --- w/w.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/w/w.c b/w/w.c index d92ad8a..8d8550a 100644 --- a/w/w.c +++ b/w/w.c @@ -482,6 +482,18 @@ void freerounds() currentround = NULL; } +void gotomonster() +{ + int index = dice() == 6 ? 1 : 0; + memcpy(&state.monster, &(monsters[index]), sizeof(Character)); + state.screen = SC_MONSTER; +} + +void gotostation() +{ + state.screen = SC_STATION; +} + void update(char* command) { char c = command[0]; @@ -496,8 +508,7 @@ void update(char* command) forward(); if ( (x != state.position.x || y != state.position.y) && dice() > 4) { - memcpy(&state.monster, &(monsters[0]), sizeof(Character)); - state.screen = SC_MONSTER; + gotomonster(); } break; case CMD_RIGHT: @@ -509,7 +520,7 @@ void update(char* command) case CMD_BACKTOSTATION: if (currentchar() == TILE_START) { - state.screen = SC_STATION; + gotostation(); } break; default: @@ -529,7 +540,7 @@ void update(char* command) if (strlen(command) > 0) { createhero(command); - state.screen = SC_STATION; + gotostation(); } } else if (state.screen == SC_STATION)