Lagt til så det står hvilken brikke man traff hvis man traff en brikke.

This commit is contained in:
Jens ]dne Rydland 2008-10-09 22:41:29 +00:00
parent 86e2bb041b
commit fc4418e158
3 changed files with 10 additions and 3 deletions

View File

@ -73,12 +73,15 @@ laser(game_t *game, int side) {
case NONE: case NONE:
break; break;
case PHARAO: case PHARAO:
game->last_hit = PHARAO;
lreturn(SILVER_WINS + 1-game->board[x][y].side); /* GAME OVER */ lreturn(SILVER_WINS + 1-game->board[x][y].side); /* GAME OVER */
case OBELISK2: case OBELISK2:
game->board[x][y].piece = OBELISK; game->board[x][y].piece = OBELISK;
game->last_hit = OBELISK;
lreturn(L_PIECE); lreturn(L_PIECE);
case OBELISK: case OBELISK:
game->board[x][y].piece = NONE; game->board[x][y].piece = NONE;
game->last_hit = OBELISK;
lreturn(L_PIECE); lreturn(L_PIECE);
case DJHED: case DJHED:
ddir = (game->board[x][y].dir - dir) & 3; ddir = (game->board[x][y].dir - dir) & 3;
@ -88,6 +91,7 @@ laser(game_t *game, int side) {
ddir = (game->board[x][y].dir - dir) & 3; ddir = (game->board[x][y].dir - dir) & 3;
if (ddir & 2) { if (ddir & 2) {
game->board[x][y].piece = NONE; game->board[x][y].piece = NONE;
game->last_hit = PYRAMID;
lreturn(L_PIECE); lreturn(L_PIECE);
} }
dir=(dir + 1 - 2*(ddir & 1)) & 3; dir=(dir + 1 - 2*(ddir & 1)) & 3;

View File

@ -40,6 +40,7 @@ typedef struct {
int winner; int winner;
square_t board[BOARD_WIDTH][BOARD_HEIGHT]; square_t board[BOARD_WIDTH][BOARD_HEIGHT];
int laser_pos[2]; int laser_pos[2];
int last_hit;
} game_t; } game_t;
typedef struct { typedef struct {
@ -53,6 +54,8 @@ typedef enum { D_NW=0, D_N, D_NE, D_E, D_SE, D_S, D_SW, D_W } dir_t;
extern char classic_setup[]; extern char classic_setup[];
extern sideinfo_t sideinfo[]; extern sideinfo_t sideinfo[];
char* piece_names[N_PIECE_TYPES] = {NULL,"pharao","djhed","pyramid","obelisk"};
int laser_at(game_t *game, int x, int y); int laser_at(game_t *game, int x, int y);
int laser(game_t *game, int side); int laser(game_t *game, int side);
int movable(game_t *game, int row, int col, int side); int movable(game_t *game, int row, int col, int side);

View File

@ -210,15 +210,15 @@ simple_game(void)
net_all_printf("%s", aabuf); net_all_printf("%s", aabuf);
switch (r) { switch (r) {
case SILVER_WINS: case SILVER_WINS:
net_all_printf("SILVER WINS\n"); net_all_printf("SILVER WINS!\n");
return; return;
case RED_WINS: case RED_WINS:
net_all_printf("RED WINS\n"); net_all_printf("RED WINS!\n");
return; return;
case L_WALL: case L_WALL:
case L_PIECE: case L_PIECE:
net_all_printf("laser hits %s at %c%c\n", net_all_printf("laser hits %s at %c%c\n",
r==L_WALL ? "wall" : "piece", r==L_WALL ? "wall" : piece_names[game.last_hit],
game.laser_pos[1]+'A', game.laser_pos[0]+'0'); game.laser_pos[1]+'A', game.laser_pos[0]+'0');
break; break;
} }