allow another monster + refactor

This commit is contained in:
quenousimporte 2025-04-06 12:04:55 +00:00
parent 209e100be7
commit 192119eea2
1 changed files with 15 additions and 4 deletions

19
w/w.c
View File

@ -482,6 +482,18 @@ void freerounds()
currentround = NULL; 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) void update(char* command)
{ {
char c = command[0]; char c = command[0];
@ -496,8 +508,7 @@ void update(char* command)
forward(); forward();
if ( (x != state.position.x || y != state.position.y) && dice() > 4) if ( (x != state.position.x || y != state.position.y) && dice() > 4)
{ {
memcpy(&state.monster, &(monsters[0]), sizeof(Character)); gotomonster();
state.screen = SC_MONSTER;
} }
break; break;
case CMD_RIGHT: case CMD_RIGHT:
@ -509,7 +520,7 @@ void update(char* command)
case CMD_BACKTOSTATION: case CMD_BACKTOSTATION:
if (currentchar() == TILE_START) if (currentchar() == TILE_START)
{ {
state.screen = SC_STATION; gotostation();
} }
break; break;
default: default:
@ -529,7 +540,7 @@ void update(char* command)
if (strlen(command) > 0) if (strlen(command) > 0)
{ {
createhero(command); createhero(command);
state.screen = SC_STATION; gotostation();
} }
} }
else if (state.screen == SC_STATION) else if (state.screen == SC_STATION)