From 34a5b0777798ec2b689709f32403e374c4b9435b Mon Sep 17 00:00:00 2001 From: girst Date: Sat, 3 Mar 2018 17:08:19 +0100 Subject: [PATCH] add game won emoticon, move them to schemes.h --- mines_2017.c | 8 +++++--- schemes.h | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mines_2017.c b/mines_2017.c index 8b7039f..da3fdf4 100644 --- a/mines_2017.c +++ b/mines_2017.c @@ -37,6 +37,7 @@ #define CLAMP(a,m,M) (aM?M:a)) #define printm(num, str) for (int i = 0; i < num; i++) fputs (str, stdout) #define print(str) fputs (str, stdout) +#define EMOT(e) op.scheme->emoticons[EMOT_ ## e] struct minecell { unsigned m:2; /* mine?1:killmine?2:0 */ @@ -425,7 +426,7 @@ int wait_mouse_up (int l, int c) { int l2, c2; /* show :o face */ - move (1, field2screen_c (f.w/2)-1); print (":o"); + move (1, field2screen_c (f.w/2)-1); print (EMOT(OHH)); if (!(l < 0 || l >= f.h || c < 0 || c >= f.w)) { /* show a pushed-in button if cursor is on minefield */ @@ -443,7 +444,7 @@ int wait_mouse_up (int l, int c) { } } - move (1, field2screen_c (f.w/2)-1); print (":D"); + move (1, field2screen_c (f.w/2)-1); print (EMOT(SMILE)); if (!(l < 0 || l >= f.h || c < 0 || c >= f.w)) { partial_show_minefield (l, c, NORMAL); } @@ -648,7 +649,8 @@ void show_minefield (int mode) { print (op.scheme->border_status_l); printf("[%03d]", f.f); printm (f.w*op.scheme->cell_width/2-6, " "); - printf ("%s", mode==SHOWMINES?":C":":D"); + printf ("%s", mode==SHOWMINES?everything_opened()? + EMOT(WON) : EMOT(DEAD) : EMOT(SMILE)); printm (f.w*op.scheme->cell_width/2-6-4, " "); printf ("[%c] [%03d]", modechar[f.s], dtime); print (op.scheme->border_status_r); diff --git a/schemes.h b/schemes.h index 554ac54..36c3379 100644 --- a/schemes.h +++ b/schemes.h @@ -4,6 +4,14 @@ contains color/monchrome schemes for tty-mines. #ifndef __SCHEMES_H__ #define __SCHEMES_H__ +enum e_emoticons { + EMOT_SMILE, + EMOT_DEAD, + EMOT_WON, + EMOT_OHH, + NUM_EMOT, +}; + struct minescheme { char* number[9]; char* field_closed; @@ -15,6 +23,8 @@ struct minescheme { char* mine_wrongf; char* mine_wrongq; + char* emoticons[NUM_EMOT]; + char* border_top_l; char* border_top_m; char* border_top_r; @@ -51,6 +61,8 @@ struct minescheme symbols_mono = { .mine_wrongf = "/", .mine_wrongq = "\", + .emoticons = {":)", "X(", "8)", ":o"}, + .border_top_l = "╔═", .border_top_m = "═", .border_top_r = "═╗", @@ -84,6 +96,8 @@ struct minescheme symbols_col1 = { .mine_wrongf = "/", .mine_wrongq = "\", + .emoticons = {":D", ":C", "8)", ":o"}, + .border_top_l = "╔═", .border_top_m = "═", .border_top_r = "═╗", @@ -118,6 +132,8 @@ struct minescheme symbols_doublewidth = { .mine_wrongf = "\033[1m/\033[0m", .mine_wrongq = "\033[1m\\\033[0m", + .emoticons = {":)", "X(", "8)", ":o"}, + .border_top_l = "\033#6\x6c", .border_top_m = "\x71", .border_top_r = "\x6b", -- 2.39.3