tell which color a killed piece had, some fixes in asciiart, added markings on the color-restricted squares
This commit is contained in:
parent
d860d50001
commit
c0395e561c
@ -12,30 +12,30 @@
|
|||||||
char asciiart_small_blank_board[] =
|
char asciiart_small_blank_board[] =
|
||||||
"red \n"
|
"red \n"
|
||||||
" | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n"
|
" | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--s--s--+--+--+--+--+--r--r--s--\n"
|
||||||
" A| | | | | | | | | | |A \n"
|
" A| | | | | | | | | | |A \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--s--+--+--+--+--+--r--s--s--\n"
|
||||||
" B| | | | | | | | | | |B \n"
|
" B| | | | | | | | | | |B \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--+--+--+--+--+--+--+--s--s--\n"
|
||||||
" C| | | | | | | | | | |C \n"
|
" C| | | | | | | | | | |C \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--+--+--+--+--+--+--+--s--s--\n"
|
||||||
" D| | | | | | | | | | |D \n"
|
" D| | | | | | | | | | |D \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--+--+--+--+--+--+--+--s--s--\n"
|
||||||
" E| | | | | | | | | | |E \n"
|
" E| | | | | | | | | | |E \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--+--+--+--+--+--+--+--s--s--\n"
|
||||||
" F| | | | | | | | | | |F \n"
|
" F| | | | | | | | | | |F \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--+--+--+--+--+--+--+--s--s--\n"
|
||||||
" G| | | | | | | | | | |G \n"
|
" G| | | | | | | | | | |G \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--r--s--+--+--+--+--+--r--s--s--\n"
|
||||||
" H| | | | | | | | | | |H \n"
|
" H| | | | | | | | | | |H \n"
|
||||||
"--+--+--+--+--+--+--+--+--+--+--+--\n"
|
"--r--s--s--+--+--+--+--+--r--r--s--\n"
|
||||||
" | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n"
|
" | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n"
|
||||||
" silver\n"
|
" silver\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
char asciiart_small_pieces[] =
|
char asciiart_small_pieces[] =
|
||||||
" " // NONE
|
" " // NONE
|
||||||
"SSSSSSSSRRRRRRRR"
|
"SSSSSSSSRRRRRRRR" // PHARAOH
|
||||||
",'`.,'`..\"\"..\"\"." // DJHED
|
",'`.,'`..\"\"..\"\"." // DJHED
|
||||||
"`/\\'/.,\\\"/\\\"/==\\" // PYRAMID
|
"`/\\'/.,\\\"/\\\"/==\\" // PYRAMID
|
||||||
". . . . = = = = " // OBELISK
|
". . . . = = = = " // OBELISK
|
||||||
@ -75,13 +75,16 @@ asciiart_small_draw_laserhit(char *buf, game_t *game)
|
|||||||
|
|
||||||
i = asciiart_small_square_index(x, y);
|
i = asciiart_small_square_index(x, y);
|
||||||
if (x == -1 || x == BOARD_WIDTH) {
|
if (x == -1 || x == BOARD_WIDTH) {
|
||||||
|
i += (x==-1) ? 2 : -1;
|
||||||
buf[i] = '#';
|
buf[i] = '#';
|
||||||
} else {
|
} else {
|
||||||
if (y == -1)
|
if (y == -1)
|
||||||
i += SMALL_WIDTH;
|
i += SMALL_WIDTH;
|
||||||
else if (y == BOARD_HEIGHT)
|
else if (y == BOARD_HEIGHT)
|
||||||
i -= SMALL_WIDTH;
|
i -= SMALL_WIDTH;
|
||||||
buf[i] = buf[i+1] = '#';
|
if (game->last_hit.piece!=OBELISK2)
|
||||||
|
buf[i] = '#';
|
||||||
|
buf[i+1] = '#';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,15 +77,15 @@ laser(game_t *game, int side) {
|
|||||||
case NONE:
|
case NONE:
|
||||||
break;
|
break;
|
||||||
case PHARAO:
|
case PHARAO:
|
||||||
game->last_hit = PHARAO;
|
game->last_hit = game->board[x][y];
|
||||||
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->last_hit = game->board[x][y];
|
||||||
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->last_hit = game->board[x][y];
|
||||||
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;
|
||||||
@ -94,8 +94,8 @@ laser(game_t *game, int side) {
|
|||||||
case PYRAMID:
|
case PYRAMID:
|
||||||
ddir = (game->board[x][y].dir - dir) & 3;
|
ddir = (game->board[x][y].dir - dir) & 3;
|
||||||
if (ddir & 2) {
|
if (ddir & 2) {
|
||||||
|
game->last_hit = game->board[x][y];
|
||||||
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;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* -*- c-basic-offset: 4 -*- */
|
||||||
|
|
||||||
#ifndef KHET_GAME_H
|
#ifndef KHET_GAME_H
|
||||||
#define KHET_GAME_H
|
#define KHET_GAME_H
|
||||||
|
|
||||||
@ -40,7 +42,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;
|
square_t last_hit;
|
||||||
} game_t;
|
} game_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -216,9 +216,13 @@ simple_game(void)
|
|||||||
net_all_printf("RED WINS!\n");
|
net_all_printf("RED WINS!\n");
|
||||||
return;
|
return;
|
||||||
case L_WALL:
|
case L_WALL:
|
||||||
|
net_all_printf("laser hits wall at %c%c\n",
|
||||||
|
game.laser_pos[1]+'A', game.laser_pos[0]+'0');
|
||||||
|
break;
|
||||||
case L_PIECE:
|
case L_PIECE:
|
||||||
net_all_printf("laser hits %s at %c%c\n",
|
net_all_printf("laser hits %s %s at %c%c\n",
|
||||||
r==L_WALL ? "wall" : pieceinfo[game.last_hit].name,
|
sideinfo[game.last_hit.side].name,
|
||||||
|
pieceinfo[game.last_hit.piece].name,
|
||||||
game.laser_pos[1]+'A', game.laser_pos[0]+'0');
|
game.laser_pos[1]+'A', game.laser_pos[0]+'0');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user