diff --git a/w/w.c b/w/w.c index fc005ce..4f80297 100644 --- a/w/w.c +++ b/w/w.c @@ -16,6 +16,7 @@ #define CMD_LEFT 'w' #define CMD_BACKTOSTATION 'r' #define CMD_GOTOMAZE 'v' +#define CMD_GOTOMARKET 'm' #define SC_TITLE 0 #define SC_SETNAME 1 @@ -24,6 +25,7 @@ #define SC_MONSTER 4 #define SC_GAMEOVER 5 #define SC_WON 6 +#define SC_MARKET 7 #define NORTH 0 #define EAST 1 @@ -58,7 +60,6 @@ typedef struct { typedef struct { Character hero; - Character monster; Position position; char screen; } Gamestate; @@ -67,9 +68,10 @@ const char* statepath = "w.state"; char pov[POV_SIZE][POV_SIZE]; unsigned char pov3d[POV_3D_SIZE][POV_3D_SIZE]; Gamestate state; +Character currentmonster; -struct Round* firstround = NULL; -struct Round* currentround = NULL; +Round* firstround = NULL; +Round* currentround = NULL; int mapsize = 15; char map[15][15] = { @@ -79,14 +81,14 @@ char map[15][15] = { "w w w d w w w", "w w w w w w w", "w w w w w w", - "wdwwwwwdwwwwwdw", - "w w w w w", - "w www w w", - "ws w w w", - "wwwwwww w w", - "w w w", - "w w w", - "w d w", + "wdwwwwwdwwwdwdw", + "w w w w w w", + "w www w w w", + "ws w w w w", + "wwwwwww w w w", + "w w w w", + "w w w w", + "w w", "wwwwwwwwwwwwwww" }; @@ -485,7 +487,7 @@ void freerounds() void gotomonster() { int index = dice() == 6 ? 1 : 0; - memcpy(&state.monster, &(monsters[index]), sizeof(Character)); + memcpy(¤tmonster, &(monsters[index]), sizeof(Character)); state.screen = SC_MONSTER; } @@ -494,6 +496,11 @@ void gotostation() state.screen = SC_STATION; } +void gotomarket() +{ + state.screen = SC_MARKET; +} + void update(char* command) { char c = command[0]; @@ -553,6 +560,10 @@ void update(char* command) state.position.orientation = NORTH; updatepov(); } + else if (c == CMD_GOTOMARKET) + { + gotomarket(); + } } else if (state.screen == SC_MONSTER) { @@ -578,18 +589,18 @@ void update(char* command) int herodmg = 0; if (!fleefails) { - monsterdmg = attack(&state.hero, &state.monster); + monsterdmg = attack(&state.hero, ¤tmonster); } - if (state.monster.hp <= 0) + if (currentmonster.hp <= 0) { - state.hero.gold += state.monster.gold; + state.hero.gold += currentmonster.gold; state.screen = SC_WON; } else { // monster attacks - herodmg = attack(&state.monster, &state.hero); + herodmg = attack(¤tmonster, &state.hero); if (state.hero.hp <= 0) { state.hero.hp = 0; @@ -610,6 +621,10 @@ void update(char* command) state.screen = SC_MAP; freerounds(); } + else if (state.screen == SC_MARKET) + { + + } } @@ -621,7 +636,7 @@ void debugoutput() void drawrounds() { - printf("Rencontre avec %s.\n\n", state.monster.name); + printf("Rencontre avec %s.\n\n", currentmonster.name); Round* p = firstround; int n = 1; while (p) @@ -629,7 +644,7 @@ void drawrounds() printf("Tour %d\n", n++); if (p->action == CMD_ATTACK) { - printf("%s perd %d points de vie\n", state.monster.name, p->monsterdmg); + printf("%s perd %d points de vie\n", currentmonster.name, p->monsterdmg); printf("%s perd %d points de vie\n\n", state.hero.name, p->herodmg); } else if (p->action == CMD_FLEE) @@ -716,6 +731,7 @@ void draw() printf("\n"); printf("v: Partir en vaisseau\n"); + printf("m: Aller au super space market\n"); } else if (state.screen == SC_MONSTER) { @@ -728,14 +744,19 @@ void draw() { drawrounds(); - printf("%s est vaincu.\n", state.monster.name); - printf("%s gagne %d crédits galactiques.\n", state.hero.name, state.monster.gold); + printf("%s est vaincu.\n", currentmonster.name); + printf("%s gagne %d crédits galactiques.\n", state.hero.name, currentmonster.gold); } else if (state.screen == SC_GAMEOVER) { drawrounds(); printf("%s est fatigué.e.\nIel retourne à la station.\n", state.hero.name); } + else if (state.screen == SC_MARKET) + { + printf("Super space market\n\n"); + printf("1: Composé protomol.: 10\n"); + } if (state.screen != SC_TITLE && state.screen != SC_SETNAME) {