From c0395e561ce126cc789b4c5fab3d1f06a7005707 Mon Sep 17 00:00:00 2001 From: oysteini Date: Fri, 10 Oct 2008 09:47:55 +0000 Subject: [PATCH] tell which color a killed piece had, some fixes in asciiart, added markings on the color-restricted squares --- src/asciiart.c | 25 ++++++++++++++----------- src/game.c | 8 ++++---- src/game.h | 4 +++- src/server.c | 8 ++++++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/asciiart.c b/src/asciiart.c index b5b6042..935d969 100644 --- a/src/asciiart.c +++ b/src/asciiart.c @@ -12,30 +12,30 @@ char asciiart_small_blank_board[] = "red \n" " | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--s--s--+--+--+--+--+--r--r--s--\n" " A| | | | | | | | | | |A \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--s--+--+--+--+--+--r--s--s--\n" " B| | | | | | | | | | |B \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--+--+--+--+--+--+--+--s--s--\n" " C| | | | | | | | | | |C \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--+--+--+--+--+--+--+--s--s--\n" " D| | | | | | | | | | |D \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--+--+--+--+--+--+--+--s--s--\n" " E| | | | | | | | | | |E \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--+--+--+--+--+--+--+--s--s--\n" " F| | | | | | | | | | |F \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--+--+--+--+--+--+--+--s--s--\n" " G| | | | | | | | | | |G \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--r--s--+--+--+--+--+--r--s--s--\n" " H| | | | | | | | | | |H \n" - "--+--+--+--+--+--+--+--+--+--+--+--\n" + "--r--s--s--+--+--+--+--+--r--r--s--\n" " | 0| 1| 2| 3| 4| 5| 6| 7| 8| 9| \n" " silver\n" ; char asciiart_small_pieces[] = " " // NONE - "SSSSSSSSRRRRRRRR" + "SSSSSSSSRRRRRRRR" // PHARAOH ",'`.,'`..\"\"..\"\"." // DJHED "`/\\'/.,\\\"/\\\"/==\\" // PYRAMID ". . . . = = = = " // OBELISK @@ -75,13 +75,16 @@ asciiart_small_draw_laserhit(char *buf, game_t *game) i = asciiart_small_square_index(x, y); if (x == -1 || x == BOARD_WIDTH) { + i += (x==-1) ? 2 : -1; buf[i] = '#'; } else { if (y == -1) i += SMALL_WIDTH; else if (y == BOARD_HEIGHT) i -= SMALL_WIDTH; - buf[i] = buf[i+1] = '#'; + if (game->last_hit.piece!=OBELISK2) + buf[i] = '#'; + buf[i+1] = '#'; } } diff --git a/src/game.c b/src/game.c index ff0fed0..e0733c5 100644 --- a/src/game.c +++ b/src/game.c @@ -77,15 +77,15 @@ laser(game_t *game, int side) { case NONE: break; case PHARAO: - game->last_hit = PHARAO; + game->last_hit = game->board[x][y]; lreturn(SILVER_WINS + 1-game->board[x][y].side); /* GAME OVER */ case OBELISK2: + game->last_hit = game->board[x][y]; game->board[x][y].piece = OBELISK; - game->last_hit = OBELISK; lreturn(L_PIECE); case OBELISK: + game->last_hit = game->board[x][y]; game->board[x][y].piece = NONE; - game->last_hit = OBELISK; lreturn(L_PIECE); case DJHED: ddir = (game->board[x][y].dir - dir) & 3; @@ -94,8 +94,8 @@ laser(game_t *game, int side) { case PYRAMID: ddir = (game->board[x][y].dir - dir) & 3; if (ddir & 2) { + game->last_hit = game->board[x][y]; game->board[x][y].piece = NONE; - game->last_hit = PYRAMID; lreturn(L_PIECE); } dir=(dir + 1 - 2*(ddir & 1)) & 3; diff --git a/src/game.h b/src/game.h index 08ed859..a5bd371 100644 --- a/src/game.h +++ b/src/game.h @@ -1,3 +1,5 @@ +/* -*- c-basic-offset: 4 -*- */ + #ifndef KHET_GAME_H #define KHET_GAME_H @@ -40,7 +42,7 @@ typedef struct { int winner; square_t board[BOARD_WIDTH][BOARD_HEIGHT]; int laser_pos[2]; - int last_hit; + square_t last_hit; } game_t; typedef struct { diff --git a/src/server.c b/src/server.c index 31c9ad7..0638c99 100644 --- a/src/server.c +++ b/src/server.c @@ -216,9 +216,13 @@ simple_game(void) net_all_printf("RED WINS!\n"); return; 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: - net_all_printf("laser hits %s at %c%c\n", - r==L_WALL ? "wall" : pieceinfo[game.last_hit].name, + net_all_printf("laser hits %s %s at %c%c\n", + sideinfo[game.last_hit.side].name, + pieceinfo[game.last_hit.piece].name, game.laser_pos[1]+'A', game.laser_pos[0]+'0'); break; }