summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <Colomar.6.4.3@GMail.com>2018-09-01 05:00:54 +0200
committerGitHub <noreply@github.com>2018-09-01 05:00:54 +0200
commitbff93a26ff267b10a13c961988cebfd4df045a2f (patch)
tree0957d7ffba031894ffff743826de2d8d78db695f
parentd8c0ad1dd82b869c999a30687ea7aa14aad4dffe (diff)
V 3.b.2
- hi scores - save board with score
-rw-r--r--Makefile32
-rw-r--r--SETUP.cmd8
-rw-r--r--libalx/inc/alx_ncur.h3
-rw-r--r--libalx/src/alx_ncur.c81
-rw-r--r--modules/game/obj/Makefile2
-rw-r--r--modules/game/src/game.c2
-rw-r--r--modules/game/src/game_iface.c61
-rw-r--r--modules/menu/src/menu_tui.c4
-rw-r--r--modules/menu/src/parser.c1
-rw-r--r--modules/player/inc/player_clui.h21
-rw-r--r--modules/player/inc/player_iface.h2
-rw-r--r--modules/player/inc/player_tui.h2
-rw-r--r--modules/player/src/player_clui.c76
-rw-r--r--modules/player/src/player_iface.c26
-rw-r--r--modules/player/src/player_tui.c72
-rw-r--r--modules/save/inc/save.h7
-rw-r--r--modules/save/inc/score.h70
-rw-r--r--modules/save/obj/Makefile34
-rw-r--r--modules/save/src/save.c55
-rw-r--r--modules/save/src/score.c157
-rw-r--r--obj/Makefile2
-rw-r--r--src/main.c2
-rw-r--r--var/hiscores/boards_beginner/zxc.mine24
-rw-r--r--var/hiscores/boards_custom/zxc.mine24
-rw-r--r--var/hiscores/boards_expert/zxc.mine40
-rw-r--r--var/hiscores/boards_intermediate/zxc.mine40
-rw-r--r--var/hiscores/hiscores_beginner.mine1
-rw-r--r--var/hiscores/hiscores_expert.mine1
-rw-r--r--var/hiscores/hiscores_intermediate.mine1
29 files changed, 721 insertions, 130 deletions
diff --git a/Makefile b/Makefile
index a84ac47..915cd4c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
# License: GPL-2.0
# This Makefile has parts of the linux kernel Makefile code.
VERSION = 3
-PATCHLEVEL = a
-SUBLEVEL = 10
+PATCHLEVEL = b
+SUBLEVEL = 2
EXTRAVERSION =
NAME = instalable
@@ -103,15 +103,18 @@ export MAIN_DIR
export LIBALX_DIR
export MODULES_DIR
-
ifeq ($(OS), linux)
INSTALL_BIN_DIR = /usr/local/games/
INSTALL_SHARE_DIR = /usr/local/share/
SHARE_DIR = mine_sweeper/
+ INSTALL_VAR_DIR = /var/local/
+ VAR_DIR = mine_sweeper/
else ifeq ($(OS), win)
INSTALL_DIR = c:/Program files (x86)/
INSTALL_SHARE_DIR = $(INSTALL_DIR)/mine_sweeper/
SHARE_DIR = share/
+ INSTALL_VAR_DIR = $(INSTALL_DIR)/mine_sweeper/
+ VAR_DIR = var/
endif
export INSTALL_DIR
@@ -136,6 +139,8 @@ CFLAGS = -std=c11
CFLAGS += -D PROG_VERSION=\"$(PROGRAMVERSION)\"
CFLAGS += -D 'INSTALL_SHARE_DIR="$(INSTALL_SHARE_DIR)"'
CFLAGS += -D SHARE_DIR=\"$(SHARE_DIR)\"
+CFLAGS += -D 'INSTALL_VAR_DIR="$(INSTALL_VAR_DIR)"'
+CFLAGS += -D VAR_DIR=\"$(VAR_DIR)\"
ifeq ($(OS), linux)
CFLAGS += -D OS_LINUX
@@ -180,21 +185,34 @@ binary:
PHONY += install
install: uninstall
- $(Q)cp $(BIN_DIR)/mine_sweeper $(INSTALL_BIN_DIR)/
@echo "Copy mine_sweeper"
+ $(Q)cp $(BIN_DIR)/mine_sweeper $(INSTALL_BIN_DIR)/
@echo ""
- $(Q)mkdir $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
+
@echo "Create $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/"
- $(Q)cp -r ./share/* $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
+ $(Q)mkdir $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
@echo "Copy share/*"
+ $(Q)cp -r ./share/* $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
+
+ @echo "Create $(INSTALL_VAR_DIR)/$(VAR_DIR)/"
+ $(Q)mkdir $(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ @echo "Copy var/*"
+ $(Q)cp -r ./var/* $(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ @echo "Change owner"
+ $(Q)chown root:games -R $(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ @echo "Change permissions"
+ $(Q)chmod 664 -R $(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ $(Q)chmod +X -R $(INSTALL_VAR_DIR)/$(VAR_DIR)/
@echo ""
+
@echo "Done"
@echo ""
PHONY += uninstall
uninstall:
$(Q)rm -f $(INSTALL_BIN_DIR)/mine_sweeper
- $(Q)rm -f -r $(INSTALL_SHARE_DIR)/mine_sweeper//
+ $(Q)rm -f -r $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
+ $(Q)rm -f -r $(INSTALL_VAR_DIR)/$(VAR_DIR)/
@echo "Clean old installations"
@echo ""
diff --git a/SETUP.cmd b/SETUP.cmd
index bc06d15..4c6d3b6 100644
--- a/SETUP.cmd
+++ b/SETUP.cmd
@@ -15,8 +15,8 @@ mkdir "%ProgramFiles(x86)%\mine_sweeper\bin\"
echo "Create %ProgramFiles(x86)%/mine_sweeper/bin/"
mkdir "%ProgramFiles(x86)%\mine_sweeper\share\"
echo "Create %ProgramFiles(x86)%/mine_sweeper/share/"
-:: mkdir "%ProgramFiles(x86)%\mine_sweeper\var\"
-:: echo "Create %ProgramFiles(x86)%/mine_sweeper/var/"
+mkdir "%ProgramFiles(x86)%\mine_sweeper\var\"
+echo "Create %ProgramFiles(x86)%/mine_sweeper/var/"
echo ""
copy "%~dp0\UNINSTALL.cmd" "%ProgramFiles(x86)%\mine_sweeper"
@@ -29,8 +29,8 @@ copy "%~dp0\bin\mine_sweeper.exe" "%ProgramFiles(x86)%\mine_sweeper\bin"
echo "Copy bin/mine_sweeper.exe"
robocopy "%~dp0\share" "%ProgramFiles(x86)%\mine_sweeper\share" /e
echo "Copy share/*"
-::robocopy "%~dp0\var" "%ProgramFiles(x86)%\mine_sweeper\var" /e
-::echo "Copy var/*"
+robocopy "%~dp0\var" "%ProgramFiles(x86)%\mine_sweeper\var" /e
+echo "Copy var/*"
echo ""
echo "Done"
diff --git a/libalx/inc/alx_ncur.h b/libalx/inc/alx_ncur.h
index d9894a2..716448d 100644
--- a/libalx/inc/alx_ncur.h
+++ b/libalx/inc/alx_ncur.h
@@ -54,16 +54,15 @@
int w,
int r,
const char *title,
- const char *def,
const char *format,
...);
void alx_w_getfname (const char *fpath,
char *fname,
+ bool exist,
int w,
int r,
const char *title,
- const char *def,
const char *format,
...);
diff --git a/libalx/src/alx_ncur.c b/libalx/src/alx_ncur.c
index dd86eea..b30bd64 100644
--- a/libalx/src/alx_ncur.c
+++ b/libalx/src/alx_ncur.c
@@ -36,10 +36,10 @@ static double loop_w_getdbl (WINDOW *win,
double m, double def, double M);
static int64_t loop_w_getint (WINDOW *win,
double m, int64_t def, double M);
-static void loop_w_getstr (char *str, WINDOW *win,
- const char *def);
-static void loop_w_getfname (const char *fpath, char *fname,
- WINDOW *win, const char *def);
+static void loop_w_getstr (char *str, WINDOW *win);
+
+static void loop_w_getfname (const char *fpath, char *fname, bool exist,
+ WINDOW *win);
static void manage_w_error (WINDOW *win, int err);
@@ -80,6 +80,7 @@ void alx_end_curses (void)
void alx_win_del (WINDOW *win)
{
/* Delete window */
+ wbkgd(win, 0);
wclear(win);
wrefresh(win);
delwin(win);
@@ -271,8 +272,7 @@ int64_t alx_w_getint (int w, int r, const char *title,
void alx_w_getstr (char *str,
- const int w, const int r, const char *title,
- const char *def,
+ int w, int r, const char *title,
const char *format, ...)
{
/* Varargs */
@@ -285,24 +285,24 @@ void alx_w_getstr (char *str,
int w1;
int r1;
int c1;
+ h1 = 3;
+ w1 = w;
+ r1 = r;
+ c1 = (80 - w) / 2;
WINDOW *win2;
int h2;
int w2;
int r2;
int c2;
+ h2 = 1;
+ w2 = w1 - 4;
+ r2 = r1 + 3;
+ c2 = c1 + 2;
WINDOW *win3;
int h3;
int w3;
int r3;
int c3;
- h1 = 3;
- w1 = w;
- r1 = r;
- c1 = (80 - w) / 2;
- h2 = 1;
- w2 = w1 - 4;
- r2 = r1 + 3;
- c2 = c1 + 2;
h3 = 1;
w3 = w1 - 2;
r3 = r1 + 1;
@@ -318,7 +318,7 @@ void alx_w_getstr (char *str,
/* Help */
win2 = newwin(h2, w2, r2, c2);
if (format == NULL) {
- waddstr(win2, "Introduce a file path");
+ waddstr(win2, "Introduce a string");
} else {
vw_printw(win2, format, args);
}
@@ -328,7 +328,7 @@ void alx_w_getstr (char *str,
win3 = newwin(h3, w3, r3, c3);
wbkgd(win3, A_REVERSE);
wrefresh(win3);
- loop_w_getstr(str, win3, def);
+ loop_w_getstr(str, win3);
/* Delete window */
alx_win_del(win3);
@@ -340,9 +340,8 @@ void alx_w_getstr (char *str,
}
-void alx_w_getfname (const char *fpath, char *fname,
- const int w, const int r, const char *title,
- const char *def,
+void alx_w_getfname (const char *fpath, char *fname, bool exist,
+ int w, int r, const char *title,
const char *format, ...)
{
/* Varargs */
@@ -398,7 +397,7 @@ void alx_w_getfname (const char *fpath, char *fname,
win3 = newwin(h3, w3, r3, c3);
wbkgd(win3, A_REVERSE);
wrefresh(win3);
- loop_w_getfname(fpath, fname, win3, def);
+ loop_w_getfname(fpath, fname, exist, win3);
/* Delete window */
alx_win_del(win3);
@@ -548,7 +547,7 @@ static double loop_w_getdbl (WINDOW *win,
for (i = 0; i < MAX_TRIES; i++) {
echo();
- x = mvwgetstr(win, 0, 0, buff);
+ x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
noecho();
wclear(win);
wrefresh(win);
@@ -581,7 +580,7 @@ static int64_t loop_w_getint (WINDOW *win,
for (i = 0; i < MAX_TRIES; i++) {
echo();
- x = mvwgetstr(win, 0, 0, buff);
+ x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
noecho();
wclear(win);
wrefresh(win);
@@ -603,8 +602,7 @@ static int64_t loop_w_getint (WINDOW *win,
return Z;
}
-static void loop_w_getstr (char *str, WINDOW *win,
- const char *def)
+static void loop_w_getstr (char *str, WINDOW *win)
{
int i;
char buff [BUFF_SIZE];
@@ -613,7 +611,7 @@ static void loop_w_getstr (char *str, WINDOW *win,
for (i = 0; i < MAX_TRIES; i++) {
echo();
- x = mvwgetstr(win, 0, 0, buff);
+ x = mvwgetnstr(win, 0, 0, buff, BUFF_SIZE);
noecho();
wclear(win);
wrefresh(win);
@@ -625,14 +623,15 @@ static void loop_w_getstr (char *str, WINDOW *win,
}
manage_w_error(win, err);
- strcpy(buff, def);
}
- strcpy(str, buff);
+ if (!err) {
+ strcpy(str, buff);
+ }
}
-static void loop_w_getfname (const char *fpath, char *fname,
- WINDOW *win, const char *def)
+static void loop_w_getfname (const char *fpath, char *fname, bool exist,
+ WINDOW *win)
{
int i;
char buff [FILENAME_MAX];
@@ -643,7 +642,7 @@ static void loop_w_getfname (const char *fpath, char *fname,
for (i = 0; i < MAX_TRIES; i++) {
echo();
- x = mvwgetstr(win, 0, 0, buff);
+ x = mvwgetnstr(win, 0, 0, buff, FILENAME_MAX);
noecho();
wclear(win);
wrefresh(win);
@@ -655,19 +654,29 @@ static void loop_w_getfname (const char *fpath, char *fname,
strcat(file_path, buff);
fp = fopen(file_path, "r");
- if (fp == NULL) {
- err = ERR_FPTR;
+ if (exist) {
+ if (fp == NULL) {
+ err = ERR_FPTR;
+ } else {
+ fclose(fp);
+ break;
+ }
} else {
- fclose(fp);
- break;
+ if (fp != NULL) {
+ err = ERR_FPTR;
+ fclose(fp);
+ } else {
+ break;
+ }
}
}
manage_w_error(win, err);
- strcpy(buff, def);
}
- strcpy(fname, buff);
+ if (!err) {
+ strcpy(fname, buff);
+ }
}
static void manage_w_error (WINDOW *win, int err)
diff --git a/modules/game/obj/Makefile b/modules/game/obj/Makefile
index 5cd0760..c0053c8 100644
--- a/modules/game/obj/Makefile
+++ b/modules/game/obj/Makefile
@@ -30,7 +30,7 @@ GAME_INC_DIRS = -I $(INC_DIR) \
-I $(LIBALX_INC_DIR)
GAMEI_INC_PLAY = player_iface.h
-GAMEI_INC_SAVE = save.h
+GAMEI_INC_SAVE = save.h score.h
GAMEI_INC_XYZZY = xyzzy.h
GAMEI_INC = game_iface.h game.h
GAMEI_DEPS = $(SRC_DIR)/game_iface.c \
diff --git a/modules/game/src/game.c b/modules/game/src/game.c
index c149545..9587246 100644
--- a/modules/game/src/game.c
+++ b/modules/game/src/game.c
@@ -87,7 +87,7 @@ void game_init_rand (int rows, int cols, int mines,
void game_init_load (int *rows, int *cols)
{
- load_game_file();
+ load_game_file(NULL, NULL);
game_board.state = GAME_STATE_PLAYING;
diff --git a/modules/game/src/game_iface.c b/modules/game/src/game_iface.c
index 94a84ea..511c573 100644
--- a/modules/game/src/game_iface.c
+++ b/modules/game/src/game_iface.c
@@ -20,6 +20,8 @@
#include "player_iface.h"
/* save_game_file() */
#include "save.h"
+ /* save_score() */
+ #include "score.h"
/* xyzzy_...() */
#include "xyzzy.h"
@@ -50,7 +52,8 @@ static void game_iface_playing_act (void);
static void game_iface_xyzzy_act (void);
static void game_iface_cheated_act (void);
static void game_iface_pause_act (void);
-static void game_iface_end_act (void);
+static void game_iface_safe_act (void);
+static void game_iface_gameover_act (void);
/* Actions: game */
static void game_iface_act_game (void);
/* Actions: game_iface */
@@ -58,6 +61,7 @@ static void game_iface_pause (void);
static void game_iface_unpause (void);
static void game_iface_xyzzy_on (void);
static void game_iface_xyzzy_off (void);
+static void game_iface_save_score (void);
static void game_iface_quit (void);
/* Output */
static void game_iface_update_out (void);
@@ -93,6 +97,8 @@ void game_iface_init_load (void)
{
game_iface_init_cheated();
+ game_iface_out.rows = game_board.rows;
+ game_iface_out.cols = game_board.cols;
game_iface_out.mines = game_board.mines;
game_iface_update_out();
game_iface_clean_in();
@@ -156,8 +162,11 @@ static void game_iface_act (void)
break;
case GAME_IFACE_STATE_SAFE:
+ game_iface_safe_act();
+ break;
+
case GAME_IFACE_STATE_GAMEOVER:
- game_iface_end_act();
+ game_iface_gameover_act();
break;
}
}
@@ -178,7 +187,7 @@ static void game_iface_playing_act (void)
break;
case GAME_IFACE_ACT_SAVE:
- save_game_file();
+ save_game_file(saved_path);
break;
case GAME_IFACE_ACT_QUIT:
@@ -217,7 +226,7 @@ static void game_iface_xyzzy_act (void)
break;
case GAME_IFACE_ACT_SAVE:
- save_game_file();
+ save_game_file(saved_path);
wh = false;
break;
@@ -245,7 +254,7 @@ static void game_iface_cheated_act (void)
break;
case GAME_IFACE_ACT_SAVE:
- save_game_file();
+ save_game_file(saved_path);
break;
case GAME_IFACE_ACT_QUIT:
@@ -266,7 +275,7 @@ static void game_iface_pause_act (void)
break;
case GAME_IFACE_ACT_SAVE:
- save_game_file();
+ save_game_file(saved_path);
break;
case GAME_IFACE_ACT_QUIT:
@@ -275,7 +284,21 @@ static void game_iface_pause_act (void)
}
}
-static void game_iface_end_act (void)
+static void game_iface_safe_act (void)
+{
+ switch (game_iface_in.action) {
+ case GAME_IFACE_ACT_SAVE:
+ game_iface_save_score();
+ game_iface_quit();
+ break;
+
+ case GAME_IFACE_ACT_QUIT:
+ game_iface_quit();
+ break;
+ }
+}
+
+static void game_iface_gameover_act (void)
{
switch (game_iface_in.action) {
case GAME_IFACE_ACT_QUIT:
@@ -333,6 +356,30 @@ static void game_iface_xyzzy_off (void)
game_iface_out.state = GAME_IFACE_STATE_CHEATED;
}
+static void game_iface_save_score (void)
+{
+ switch (game_iface_score.level) {
+ case GAME_IFACE_LEVEL_BEGINNER:
+ save_game_file(var_boards_beginner_path);
+ save_score(&game_iface_score);
+ break;
+
+ case GAME_IFACE_LEVEL_INTERMEDIATE:
+ save_game_file(var_boards_intermediate_path);
+ save_score(&game_iface_score);
+ break;
+
+ case GAME_IFACE_LEVEL_EXPERT:
+ save_game_file(var_boards_expert_path);
+ save_score(&game_iface_score);
+ break;
+
+ case GAME_IFACE_LEVEL_CUSTOM:
+ save_game_file(var_boards_custom_path);
+ break;
+ }
+}
+
static void game_iface_quit (void)
{
game_iface_out.state = GAME_IFACE_STATE_QUIT;
diff --git a/modules/menu/src/menu_tui.c b/modules/menu/src/menu_tui.c
index fd23491..97df539 100644
--- a/modules/menu/src/menu_tui.c
+++ b/modules/menu/src/menu_tui.c
@@ -184,8 +184,8 @@ static void menu_tui_continue (void)
break;
case 4:
- alx_w_getfname(USER_SAVED_DIR, saved_name, w2, r2,
- txt[0], saved_name, NULL);
+ alx_w_getfname(USER_SAVED_DIR, saved_name, true, w2, r2,
+ txt[0], NULL);
alx_win_del(win);
break;
diff --git a/modules/menu/src/parser.c b/modules/menu/src/parser.c
index aecd766..20906d6 100644
--- a/modules/menu/src/parser.c
+++ b/modules/menu/src/parser.c
@@ -11,6 +11,7 @@
* * * * * * * * * */
#include <getopt.h>
#include <stdio.h>
+ /* exit() */
#include <stdlib.h>
#include <string.h>
diff --git a/modules/player/inc/player_clui.h b/modules/player/inc/player_clui.h
index f8509f6..6492054 100644
--- a/modules/player/inc/player_clui.h
+++ b/modules/player/inc/player_clui.h
@@ -47,16 +47,19 @@
/******************************************************************************
******* functions ************************************************************
******************************************************************************/
-void player_clui_start(const struct Player_Iface_Position *position,
- const char *title,
- const char *subtitle,
- int *action);
+void player_clui_start (const struct Player_Iface_Position *position,
+ const char *title,
+ const char *subtitle,
+ int *action);
-void player_clui (const struct Game_Iface_Out *board,
- const struct Player_Iface_Position *position,
- const char *title,
- const char *subtitle,
- int *action);
+void player_clui (const struct Game_Iface_Out *board,
+ const struct Player_Iface_Position *position,
+ const char *title,
+ const char *subtitle,
+ int *action);
+
+void player_clui_save_name (const char *filepath, char *filename);
+void player_clui_score_name (char *player_name);
/******************************************************************************
diff --git a/modules/player/inc/player_iface.h b/modules/player/inc/player_iface.h
index f5e4ae6..ac61d39 100644
--- a/modules/player/inc/player_iface.h
+++ b/modules/player/inc/player_iface.h
@@ -77,6 +77,8 @@ void player_iface_start (int *pos_row, int *pos_col);
void player_iface (const struct Game_Iface_Out *game_iface_out,
const struct Game_Iface_Score *game_iface_score,
struct Game_Iface_In *game_iface_in);
+void player_iface_save_name (const char *filepath, char *filename);
+void player_iface_score_name (char *player_name);
void player_iface_cleanup (void);
diff --git a/modules/player/inc/player_tui.h b/modules/player/inc/player_tui.h
index d5ede3c..4070147 100644
--- a/modules/player/inc/player_tui.h
+++ b/modules/player/inc/player_tui.h
@@ -103,6 +103,8 @@ int player_tui (const struct Game_Iface_Out *board,
const char *subtitle,
int *action);
+void player_tui_save_name (const char *filepath, char *filename);
+void player_tui_score_name (char *player_name);
void player_tui_cleanup (void);
diff --git a/modules/player/src/player_clui.c b/modules/player/src/player_clui.c
index a9347ee..d4742cb 100644
--- a/modules/player/src/player_clui.c
+++ b/modules/player/src/player_clui.c
@@ -61,22 +61,23 @@ static char set_char (int game_iface_visible);
/* Input */
static int usr_input (void);
/* Help */
-static void show_help (const struct Game_Iface_Out *board);
-static void show_help_start (void);
-static void show_help_play (void);
-static void show_help_pause (void);
-static void show_help_xyzzy (void);
-static void show_help_cheat (void);
-static void show_help_end (void);
+static void show_help (const struct Game_Iface_Out *board);
+static void show_help_start (void);
+static void show_help_play (void);
+static void show_help_pause (void);
+static void show_help_xyzzy (void);
+static void show_help_cheat (void);
+static void show_help_safe (void);
+static void show_help_gameover (void);
/******************************************************************************
******* main *****************************************************************
******************************************************************************/
-void player_clui_start(const struct Player_Iface_Position *position,
- const char *title,
- const char *subtitle,
- int *action)
+void player_clui_start (const struct Player_Iface_Position *position,
+ const char *title,
+ const char *subtitle,
+ int *action)
{
/* User action */
show_help_start();
@@ -86,11 +87,11 @@ void player_clui_start(const struct Player_Iface_Position *position,
oldaction = *action;
}
-void player_clui (const struct Game_Iface_Out *board,
- const struct Player_Iface_Position *position,
- const char *title,
- const char *subtitle,
- int *action)
+void player_clui (const struct Game_Iface_Out *board,
+ const struct Player_Iface_Position *position,
+ const char *title,
+ const char *subtitle,
+ int *action)
{
/* User action */
@@ -103,6 +104,18 @@ void player_clui (const struct Game_Iface_Out *board,
oldaction = *action;
}
+void player_clui_save_name (const char *filepath, char *filename)
+{
+ puts("File name:");
+ scanf(" %100c ", filename);
+}
+
+void player_clui_score_name (char *player_name)
+{
+ puts("Your name:");
+ scanf(" %100c ", player_name);
+}
+
/******************************************************************************
******* static functions *****************************************************
@@ -416,7 +429,7 @@ static int usr_input (void)
/* * * * * * * * * *
* * * Help * * * * * * *
* * * * * * * * * */
-static void show_help (const struct Game_Iface_Out *board)
+static void show_help (const struct Game_Iface_Out *board)
{
switch (board->state) {
case GAME_IFACE_STATE_PLAYING:
@@ -436,13 +449,16 @@ static void show_help (const struct Game_Iface_Out *board)
break;
case GAME_IFACE_STATE_SAFE:
+ show_help_safe();
+ break;
+
case GAME_IFACE_STATE_GAMEOVER:
- show_help_end();
+ show_help_gameover();
break;
}
}
-static void show_help_start (void)
+static void show_help_start (void)
{
puts("Move:");
/* hjkl */
@@ -471,7 +487,7 @@ static void show_help_start (void)
printf(" Enter\n");
}
-static void show_help_play (void)
+static void show_help_play (void)
{
puts("Move:");
/* hjkl */
@@ -512,7 +528,7 @@ static void show_help_play (void)
printf(" Enter\n");
}
-static void show_help_pause (void)
+static void show_help_pause (void)
{
puts("Continue:");
@@ -528,7 +544,7 @@ static void show_help_pause (void)
printf(" Enter\n");
}
-static void show_help_xyzzy (void)
+static void show_help_xyzzy (void)
{
puts("XYZZY:");
printf(" %c", '1');
@@ -574,7 +590,7 @@ static void show_help_xyzzy (void)
printf(" Enter\n");
}
-static void show_help_cheat (void)
+static void show_help_cheat (void)
{
puts("Move:");
/* hjkl */
@@ -612,7 +628,19 @@ static void show_help_cheat (void)
printf(" Enter\n");
}
-static void show_help_end (void)
+static void show_help_safe (void)
+{
+ puts("Save:");
+ printf(" %c\n", 's');
+
+ puts("Quit:");
+ printf(" %c\n", 'q');
+
+ puts("Confirm:");
+ printf(" Enter\n");
+}
+
+static void show_help_gameover (void)
{
puts("Quit:");
printf(" %c\n", 'q');
diff --git a/modules/player/src/player_iface.c b/modules/player/src/player_iface.c
index a9a498c..14009c9 100644
--- a/modules/player/src/player_iface.c
+++ b/modules/player/src/player_iface.c
@@ -181,6 +181,32 @@ void player_iface (const struct Game_Iface_Out *game_iface_out,
player_iface_act(game_iface_in, player_action);
}
+void player_iface_save_name (const char *filepath, char *filename)
+{
+ switch (player_iface_mode) {
+ case PLAYER_IFACE_CLUI:
+ player_clui_save_name(filepath, filename);
+ break;
+
+ case PLAYER_IFACE_TUI:
+ player_tui_save_name(filepath, filename);
+ break;
+ }
+}
+
+void player_iface_score_name (char *player_name)
+{
+ switch (player_iface_mode) {
+ case PLAYER_IFACE_CLUI:
+ player_clui_score_name(player_name);
+ break;
+
+ case PLAYER_IFACE_TUI:
+ player_tui_score_name(player_name);
+ break;
+ }
+}
+
void player_iface_cleanup (void)
{
switch (player_iface_mode) {
diff --git a/modules/player/src/player_tui.c b/modules/player/src/player_tui.c
index fead461..7f1745e 100644
--- a/modules/player/src/player_tui.c
+++ b/modules/player/src/player_tui.c
@@ -72,13 +72,14 @@ static void show_char (int row, int col, wchar_t wch);
/* Input */
static int usr_input (void);
/* Help */
-static void show_help (const struct Game_Iface_Out *board);
-static void show_help_start (void);
-static void show_help_play (void);
-static void show_help_pause (void);
-static void show_help_xyzzy (void);
-static void show_help_cheat (void);
-static void show_help_end (void);
+static void show_help (const struct Game_Iface_Out *board);
+static void show_help_start (void);
+static void show_help_play (void);
+static void show_help_pause (void);
+static void show_help_xyzzy (void);
+static void show_help_cheat (void);
+static void show_help_safe (void);
+static void show_help_gameover (void);
/******************************************************************************
@@ -161,6 +162,30 @@ int player_tui (const struct Game_Iface_Out *board,
*action = usr_input();
}
+void player_tui_save_name (const char *filepath, char *filename)
+{
+ /* Input box */
+ int w;
+ int r;
+ w = 60;
+ r = 10;
+
+ /* Request name */
+ alx_w_getfname(filepath, filename, false, w, r, "File name:", NULL);
+}
+
+void player_tui_score_name (char *player_name)
+{
+ /* Input box */
+ int w;
+ int r;
+ w = 60;
+ r = 10;
+
+ /* Request name */
+ alx_w_getstr(player_name, w, r, "Your name:", NULL);
+}
+
void player_tui_cleanup (void)
{
/* Del wins & return to terminal mode */
@@ -633,7 +658,7 @@ static int usr_input (void)
/* * * * * * * * * *
* * * Help * * * * * * *
* * * * * * * * * */
-static void show_help (const struct Game_Iface_Out *board)
+static void show_help (const struct Game_Iface_Out *board)
{
/* Clear */
werase(win_help);
@@ -656,8 +681,11 @@ static void show_help (const struct Game_Iface_Out *board)
break;
case GAME_IFACE_STATE_SAFE:
+ show_help_safe();
+ break;
+
case GAME_IFACE_STATE_GAMEOVER:
- show_help_end();
+ show_help_gameover();
break;
}
@@ -665,7 +693,7 @@ static void show_help (const struct Game_Iface_Out *board)
wrefresh(win_help);
}
-static void show_help_start (void)
+static void show_help_start (void)
{
int r;
int c;
@@ -707,7 +735,7 @@ static void show_help_start (void)
mvwprintw(win_help, r++, c, " %c", 'q');
}
-static void show_help_play (void)
+static void show_help_play (void)
{
int r;
int c;
@@ -761,7 +789,7 @@ static void show_help_play (void)
mvwprintw(win_help, r++, c, " %c", 'q');
}
-static void show_help_pause (void)
+static void show_help_pause (void)
{
int r;
int c;
@@ -781,7 +809,7 @@ static void show_help_pause (void)
mvwprintw(win_help, r++, c, " %c", 'q');
}
-static void show_help_xyzzy (void)
+static void show_help_xyzzy (void)
{
int r;
int c;
@@ -844,7 +872,7 @@ static void show_help_xyzzy (void)
mvwprintw(win_help, r++, c, " %c", 'q');
}
-static void show_help_cheat (void)
+static void show_help_cheat (void)
{
int r;
int c;
@@ -895,7 +923,21 @@ static void show_help_cheat (void)
mvwprintw(win_help, r++, c, " %c", 'q');
}
-static void show_help_end (void)
+static void show_help_safe (void)
+{
+ int r;
+ int c;
+
+ r = 0;
+ c = 0;
+ mvwaddstr(win_help, r++, c, "Save:");
+ mvwprintw(win_help, r++, c, " %c", 's');
+
+ mvwaddstr(win_help, r++, c, "Quit:");
+ mvwprintw(win_help, r++, c, " %c", 'q');
+}
+
+static void show_help_gameover (void)
{
int r;
int c;
diff --git a/modules/save/inc/save.h b/modules/save/inc/save.h
index f4689e1..7970950 100644
--- a/modules/save/inc/save.h
+++ b/modules/save/inc/save.h
@@ -28,7 +28,8 @@
# define USER_GAME_DIR ".mine_sweeper/"
# define USER_SAVED_DIR ".mine_sweeper/saved/"
- # define SAVED_NAME_DEFAULT "saved_000.mine"
+ # define SAVED_NAME_DEFAULT "saved"
+ # define FILE_EXTENSION ".mine"
/******************************************************************************
@@ -44,8 +45,8 @@ extern char saved_name [FILENAME_MAX];
******* functions ************************************************************
******************************************************************************/
void save_init (void);
-void load_game_file (void);
-void save_game_file (void);
+void load_game_file (char *filepath, char *filename);
+void save_game_file (char *filepath);
/******************************************************************************
diff --git a/modules/save/inc/score.h b/modules/save/inc/score.h
new file mode 100644
index 0000000..2a27d59
--- /dev/null
+++ b/modules/save/inc/score.h
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+# ifndef MSW_SCORE_H
+ # define MSW_SCORE_H
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+ /* FILENAME_MAX */
+ #include <stdio.h>
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
+ # if defined (OS_LINUX)
+ # define ENV_HOME "HOME"
+ # elif defined (OS_WIN)
+ # define ENV_HOME "USERPROFILE"
+ # endif
+
+ # define HISCORES_DIR "hiscores/"
+ # define BOARDS_BEGINNER_DIR "hiscores/boards_beginner/"
+ # define BOARDS_INTERMEDIATE_DIR "hiscores/boards_intermediate/"
+ # define BOARDS_EXPERT_DIR "hiscores/boards_expert/"
+ # define BOARDS_CUSTOM_DIR "hiscores/boards_custom/"
+ # define USER_SAVED_DIR ".mine_sweeper/saved/"
+ # define HISCORES_BEGINNER_NAME "hiscores_beginner.mine"
+ # define HISCORES_INTERMEDIATE_NAME "hiscores_intermediate.mine"
+ # define HISCORES_EXPERT_NAME "hiscores_expert.mine"
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+extern char var_path [FILENAME_MAX];
+extern char var_hiscores_path [FILENAME_MAX];
+extern char var_boards_beginner_path [FILENAME_MAX];
+extern char var_boards_intermediate_path [FILENAME_MAX];
+extern char var_boards_expert_path [FILENAME_MAX];
+extern char var_boards_custom_path [FILENAME_MAX];
+
+extern char var_hiscores_beginner_name [FILENAME_MAX];
+extern char var_hiscores_intermediate_name [FILENAME_MAX];
+extern char var_hiscores_expert_name [FILENAME_MAX];
+
+
+/******************************************************************************
+ ******* functions ************************************************************
+ ******************************************************************************/
+void score_init (void);
+void save_score (const struct Game_Iface_Score *game_iface_score);
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+# endif /* score.h */
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/modules/save/obj/Makefile b/modules/save/obj/Makefile
index bdcd284..e4cbf5d 100644
--- a/modules/save/obj/Makefile
+++ b/modules/save/obj/Makefile
@@ -5,22 +5,37 @@
# directories
GAME_INC_DIR = $(GAME_DIR)/inc/
+PLAY_INC_DIR = $(PLAY_DIR)/inc/
INC_DIR = $(SAVE_DIR)/inc/
SRC_DIR = $(SAVE_DIR)/src/
# dependencies
-_ALL = save.o
+_ALL = save.o score.o
ALL = $(_ALL) save_mod.o
-SAVE_INC_GAME = game.h
-SAVE_INC = save.h
-SAVE_DEPS = $(SRC_DIR)/save.c \
+SAVE_INC_PLAY = player_iface.h
+SAVE_INC_GAME = game.h
+SAVE_INC = save.h
+SAVE_DEPS = $(SRC_DIR)/save.c \
$(patsubst %,$(INC_DIR)/%,$(SAVE_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(SAVE_INC_GAME))
-SAVE_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR)
+ $(patsubst %,$(GAME_INC_DIR)/%,$(SAVE_INC_GAME)) \
+ $(patsubst %,$(PLAY_INC_DIR)/%,$(SAVE_INC_PLAY))
+SAVE_INC_DIRS = -I $(INC_DIR) \
+ -I $(GAME_INC_DIR) \
+ -I $(PLAY_INC_DIR)
+
+SCORE_INC_PLAY = player_iface.h
+SCORE_INC_GAME = game.h game_iface.h
+SCORE_INC = score.h
+SCORE_DEPS = $(SRC_DIR)/score.c \
+ $(patsubst %,$(INC_DIR)/%,$(SCORE_INC)) \
+ $(patsubst %,$(GAME_INC_DIR)/%,$(SCORE_INC_GAME)) \
+ $(patsubst %,$(PLAY_INC_DIR)/%,$(SCORE_INC_PLAY))
+SCORE_INC_DIRS = -I $(INC_DIR) \
+ -I $(GAME_INC_DIR) \
+ -I $(PLAY_INC_DIR)
# target: dependencies
# action
@@ -39,6 +54,11 @@ save.o: $(SAVE_DEPS)
@echo "\tCC $<"
@echo ""
+score.o: $(SCORE_DEPS)
+ $(Q)$(CC) $(CFLAGS) $(SCORE_INC_DIRS) -c $< -o $@ $(LIBS)
+ @echo "\tCC $<"
+ @echo ""
+
clean:
$(Q)rm -f *.o
diff --git a/modules/save/src/save.c b/modules/save/src/save.c
index e72e3da..c828eb8 100644
--- a/modules/save/src/save.c
+++ b/modules/save/src/save.c
@@ -27,6 +27,8 @@
* * * * * * * * * */
/* struct Game_Board */
#include "game.h"
+ /* player_iface_save_name() */
+ #include "player_iface.h"
#include "save.h"
@@ -58,6 +60,7 @@ void save_init (void)
strcat(saved_path, "/");
strcpy(saved_name, SAVED_NAME_DEFAULT);
+ strcat(saved_name, FILE_EXTENSION);
int err;
#if defined OS_LINUX
@@ -91,7 +94,7 @@ void save_init (void)
}
}
-void load_game_file (void)
+void load_game_file (char *filepath, char *filename)
{
char file_name [FILENAME_MAX];
FILE *fp;
@@ -99,8 +102,16 @@ void load_game_file (void)
int i;
int j;
- strcpy(file_name, saved_path);
- strcat(file_name, saved_name);
+ if (filepath == NULL) {
+ strcpy(file_name, saved_path);
+ } else {
+ strcpy(file_name, filepath);
+ }
+ if (filename == NULL) {
+ strcat(file_name, saved_name);
+ } else {
+ strcat(file_name, filename);
+ }
fp = fopen(file_name, "r");
if (fp) {
@@ -129,30 +140,52 @@ void load_game_file (void)
}
}
-void save_game_file (void)
+void save_game_file (char *filepath)
{
char file_name [FILENAME_MAX];
+ char file_num [6] = "";
FILE *fp;
int i;
int j;
- bool x;
- /* Look for an unused name of the type 'saved_XXX.mine'. */
- x = true;
+ /* Input box size */
+ int w;
+ int r;
+ w = 70;
+ r = 10;
+
+ /* Default name */
strcpy(saved_name, SAVED_NAME_DEFAULT);
+
+ /* Request file name */
+ player_iface_save_name(filepath, saved_name);
+
+ /* Look for an unused name of the type 'name_XXX.mine'. */
+ bool x;
+ x = true;
for (i = 0; x; i++) {
- strcpy(file_name, saved_path);
+ if (filepath == NULL) {
+ strcpy(file_name, saved_path);
+ } else {
+ strcpy(file_name, filepath);
+ }
strcat(file_name, saved_name);
+ strcat(file_name, file_num);
+ strcat(file_name, FILE_EXTENSION);
fp = fopen(file_name, "r");
if (fp) {
fclose(fp);
- saved_name[6] = '0' + ((i / 100) % 10);
- saved_name[7] = '0' + ((i / 10) % 10);
- saved_name[8] = '0' + (i % 10);
+ file_num[0] = '_';
+ file_num[1] = '0' + ((i / 100) % 10);
+ file_num[2] = '0' + ((i / 10) % 10);
+ file_num[3] = '0' + (i % 10);
+ file_num[4] = '\0';
} else {
x = false;
+ strcat(saved_name, file_num);
+ strcat(saved_name, FILE_EXTENSION);
}
}
diff --git a/modules/save/src/score.c b/modules/save/src/score.c
new file mode 100644
index 0000000..d2ba940
--- /dev/null
+++ b/modules/save/src/score.c
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+/* * * * * * * * * *
+ * * * Standard * * * * * *
+ * * * * * * * * * */
+ /* fscanf() & fprintf() & FILE & FILENAME_MAX */
+ #include <stdio.h>
+ /* exit() */
+ #include <stdlib.h>
+ /* strcpy() & strcat() */
+ #include <string.h>
+ /* time_t & time() & struct tm & localtime() */
+ #include <time.h>
+
+/* * * * * * * * * *
+ * * * Other * * * * * * *
+ * * * * * * * * * */
+ /* struct Game_Board */
+ #include "game.h"
+ /* enum Game_Iface_Level */
+ #include "game_iface.h"
+ /* player_iface_score_name() */
+ #include "player_iface.h"
+ /* saved_name */
+ #include "save.h"
+
+ #include "score.h"
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
+ # define BUFF_SIZE (1024)
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+char var_path [FILENAME_MAX];
+char var_hiscores_path [FILENAME_MAX];
+char var_boards_beginner_path [FILENAME_MAX];
+char var_boards_intermediate_path [FILENAME_MAX];
+char var_boards_expert_path [FILENAME_MAX];
+char var_boards_custom_path [FILENAME_MAX];
+
+char var_hiscores_beginner_name [FILENAME_MAX];
+char var_hiscores_intermediate_name [FILENAME_MAX];
+char var_hiscores_expert_name [FILENAME_MAX];
+
+
+/******************************************************************************
+ ******* main *****************************************************************
+ ******************************************************************************/
+void score_init (void)
+{
+ strcpy(var_path, INSTALL_VAR_DIR);
+ strcat(var_path, "/");
+ strcat(var_path, VAR_DIR);
+ strcat(var_path, "/");
+
+ strcpy(var_hiscores_path, var_path);
+ strcat(var_hiscores_path, "/");
+ strcat(var_hiscores_path, HISCORES_DIR);
+ strcat(var_hiscores_path, "/");
+
+ strcpy(var_boards_beginner_path, var_path);
+ strcat(var_boards_beginner_path, "/");
+ strcat(var_boards_beginner_path, BOARDS_BEGINNER_DIR);
+ strcat(var_boards_beginner_path, "/");
+
+ strcpy(var_boards_intermediate_path, var_path);
+ strcat(var_boards_intermediate_path, "/");
+ strcat(var_boards_intermediate_path, BOARDS_INTERMEDIATE_DIR);
+ strcat(var_boards_intermediate_path, "/");
+
+ strcpy(var_boards_expert_path, var_path);
+ strcat(var_boards_expert_path, "/");
+ strcat(var_boards_expert_path, BOARDS_EXPERT_DIR);
+ strcat(var_boards_expert_path, "/");
+
+ strcpy(var_boards_custom_path, var_path);
+ strcat(var_boards_custom_path, "/");
+ strcat(var_boards_custom_path, BOARDS_CUSTOM_DIR);
+ strcat(var_boards_custom_path, "/");
+
+ strcpy(var_hiscores_beginner_name, HISCORES_BEGINNER_NAME);
+ strcpy(var_hiscores_intermediate_name, HISCORES_INTERMEDIATE_NAME);
+ strcpy(var_hiscores_expert_name, HISCORES_EXPERT_NAME);
+}
+
+void save_score (const struct Game_Iface_Score *game_iface_score)
+{
+ /* File name */
+ char file_name [FILENAME_MAX];
+ strcpy(file_name, var_hiscores_path);
+ switch (game_iface_score->level) {
+ case GAME_IFACE_LEVEL_BEGINNER:
+ strcat(file_name, var_hiscores_beginner_name);
+ break;
+
+ case GAME_IFACE_LEVEL_INTERMEDIATE:
+ strcat(file_name, var_hiscores_intermediate_name);
+ break;
+
+ case GAME_IFACE_LEVEL_EXPERT:
+ strcat(file_name, var_hiscores_expert_name);
+ break;
+ }
+
+ /* Date & time */
+ time_t date_secs;
+ struct tm *date_format;
+ date_secs = time(NULL);
+ date_format = localtime(&date_secs);
+
+ /* Player name (foo is default) */
+ char player_name [BUFF_SIZE];
+ player_iface_score_name(player_name);
+
+ /* Write to a new file */
+ FILE *fp;
+ fp = fopen(file_name, "a");
+ if (fp) {
+ fprintf(fp, "\n");
+ fprintf(fp, "name %s\n", player_name);
+ fprintf(fp, "date %i\n", (int)date_secs);
+ fprintf(fp, "{\n");
+ fprintf(fp, " isdst %i\n", date_format->tm_isdst);
+ fprintf(fp, " yday %i\n", date_format->tm_yday);
+ fprintf(fp, " wday %i\n", date_format->tm_wday);
+ fprintf(fp, " year %i\n", date_format->tm_year);
+ fprintf(fp, " mon %i\n", date_format->tm_mon);
+ fprintf(fp, " mday %i\n", date_format->tm_mday);
+ fprintf(fp, " hour %i\n", date_format->tm_hour);
+ fprintf(fp, " min %i\n", date_format->tm_min);
+ fprintf(fp, " sec %i\n", date_format->tm_sec);
+ fprintf(fp, "}\n");
+ fprintf(fp, "time %i\n", game_iface_score->time);
+ fprintf(fp, "clicks %i\n", game_iface_score->clicks);
+ fprintf(fp, "file %s\n", saved_name);
+
+ fclose(fp);
+ } else {
+ exit(EXIT_FAILURE);
+ }
+}
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/obj/Makefile b/obj/Makefile
index b05a369..3a6f482 100644
--- a/obj/Makefile
+++ b/obj/Makefile
@@ -36,7 +36,7 @@ MAIN_INC_CTRL = start.h
MAIN_INC_GAME = game.h
MAIN_INC_MENU = parser.h menu_iface.h
MAIN_INC_PLAY = player_iface.h
-MAIN_INC_SAVE = save.h
+MAIN_INC_SAVE = save.h score.h
MAIN_DEPS = $(SRC_DIR)/main.c \
$(patsubst %,$(LIBALX_INC_DIR)/%,$(MAIN_INC_LIBALX)) \
$(patsubst %,$(ABOUT_INC_DIR)/%,$(MAIN_INC_ABOUT)) \
diff --git a/src/main.c b/src/main.c
index 61e5a4f..3559ef7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
#include "player_iface.h"
#include "parser.h"
#include "save.h"
+ #include "score.h"
#include "start.h"
@@ -72,6 +73,7 @@ void init_all (void)
game_init();
about_init();
save_init();
+ score_init();
/* Modes */
start_mode = START_FOO;
diff --git a/var/hiscores/boards_beginner/zxc.mine b/var/hiscores/boards_beginner/zxc.mine
new file mode 100644
index 0000000..189f897
--- /dev/null
+++ b/var/hiscores/boards_beginner/zxc.mine
@@ -0,0 +1,24 @@
+mine_sweeper saved game
+rows 8
+cols 8
+mines 10
+gnd
+0,0,0,0,0,2,11,2
+0,1,1,1,0,3,12,3
+1,2,10,1,0,2,11,2
+10,3,2,2,0,1,2,2
+1,2,11,2,1,0,1,10
+0,1,2,11,1,1,2,2
+0,0,2,2,2,1,10,1
+0,0,1,10,1,1,1,1
+usr
+1,1,1,1,1,1,2,1
+1,1,1,1,1,1,2,1
+1,1,2,1,1,1,2,1
+2,1,1,1,1,1,1,1
+1,1,2,1,1,1,1,2
+1,1,1,2,1,1,1,1
+1,1,1,1,1,1,2,1
+1,1,1,2,1,1,1,1
+flags 10
+cleared 54
diff --git a/var/hiscores/boards_custom/zxc.mine b/var/hiscores/boards_custom/zxc.mine
new file mode 100644
index 0000000..45a8118
--- /dev/null
+++ b/var/hiscores/boards_custom/zxc.mine
@@ -0,0 +1,24 @@
+mine_sweeper saved game
+rows 8
+cols 8
+mines 3
+gnd
+0,0,0,0,0,0,0,0
+0,0,0,0,0,0,0,0
+0,0,0,1,1,1,0,0
+0,0,0,1,10,1,0,0
+0,1,1,2,1,1,0,0
+0,1,10,1,0,0,0,0
+0,1,1,1,0,1,1,1
+0,0,0,0,0,1,10,1
+usr
+1,1,1,1,1,1,1,1
+1,1,1,1,1,1,1,1
+1,1,1,1,1,1,1,1
+1,1,1,1,0,1,1,1
+1,1,1,1,1,1,1,1
+1,1,0,1,1,1,1,1
+1,1,1,1,1,1,1,1
+1,1,1,1,1,1,0,1
+flags 0
+cleared 61
diff --git a/var/hiscores/boards_expert/zxc.mine b/var/hiscores/boards_expert/zxc.mine
new file mode 100644
index 0000000..ab834ed
--- /dev/null
+++ b/var/hiscores/boards_expert/zxc.mine
@@ -0,0 +1,40 @@
+mine_sweeper saved game
+rows 16
+cols 30
+mines 99
+gnd
+0,1,1,2,10,1,0,1,1,2,1,1,1,1,1,0,0,1,1,1,0,1,1,2,10,1,1,10,1,0
+1,3,12,3,1,1,0,1,10,2,10,1,1,10,1,0,0,2,11,2,0,1,10,2,2,2,2,1,1,0
+1,12,12,2,0,0,0,1,1,2,1,1,1,1,2,1,1,2,11,2,0,1,1,2,2,11,1,1,2,2
+1,2,2,1,0,0,1,1,1,1,2,2,1,0,1,11,2,2,1,1,1,2,2,2,11,2,1,1,11,11
+0,0,0,1,1,2,2,11,2,2,12,11,1,0,1,2,11,2,1,2,2,13,12,3,1,1,1,2,3,2
+1,1,0,1,10,2,11,2,2,12,4,3,1,0,1,2,3,3,12,3,13,5,13,2,0,1,2,11,1,0
+10,1,0,1,1,2,1,1,1,2,12,2,1,0,2,11,3,11,3,12,3,12,3,2,1,2,12,4,2,1
+1,1,0,0,0,1,2,2,1,2,4,13,2,0,2,12,5,3,4,2,3,2,3,12,3,4,13,4,11,1
+1,2,3,2,1,1,11,11,1,2,13,13,3,1,2,2,13,12,3,11,2,2,11,3,13,13,4,12,2,1
+2,13,13,12,1,2,3,3,1,2,13,4,3,10,1,2,4,13,4,3,12,2,1,2,4,13,4,2,2,1
+11,5,14,4,1,1,10,1,1,2,4,12,3,1,1,1,11,3,3,13,3,3,1,2,3,12,2,1,10,1
+1,3,11,2,0,2,2,2,1,10,4,12,3,0,0,1,1,2,11,3,11,2,10,2,11,2,1,1,2,2
+1,3,3,2,1,2,11,1,1,2,5,13,3,1,1,1,0,1,1,3,2,3,1,2,1,1,0,0,1,10
+1,11,11,1,1,11,3,2,1,2,13,13,2,1,10,2,1,2,1,2,11,2,1,0,0,0,0,0,1,1
+2,3,3,1,2,2,3,10,1,3,13,5,2,3,2,3,10,2,11,3,3,11,1,1,1,1,0,1,1,1
+1,10,1,0,1,10,2,1,1,2,11,3,10,2,10,2,1,2,2,11,2,1,1,1,10,1,0,1,10,1
+usr
+1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1
+1,1,2,1,1,1,1,1,2,1,2,1,1,2,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,1
+1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1
+1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,2,1,1,1,2,2
+1,1,1,1,1,1,1,2,1,1,2,2,1,1,1,1,2,1,1,1,1,2,2,1,1,1,1,1,1,1
+1,1,1,1,2,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,2,1,2,1,1,1,1,2,1,1
+2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,2,1,2,1,2,1,2,1,1,1,1,2,1,1,1
+1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,2,1,1,1,1,1,1,1,2,1,1,2,1,2,1
+1,1,1,1,1,1,2,2,1,1,2,2,1,1,1,1,2,2,1,2,1,1,2,1,2,2,1,2,1,1
+1,2,2,2,1,1,1,1,1,1,2,1,1,2,1,1,1,2,1,1,2,1,1,1,1,2,1,1,1,1
+2,1,2,1,1,1,2,1,1,1,1,2,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,2,1
+1,1,2,1,1,1,1,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,2,1,2,1,1,1,1,1
+1,1,1,1,1,1,2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2
+1,2,2,1,1,2,1,1,1,1,2,2,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1
+1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,2,1,1,2,1,1,1,1,1,1,1,1
+1,2,1,1,1,2,1,1,1,1,2,1,2,1,2,1,1,1,1,2,1,1,1,1,2,1,1,1,2,1
+flags 99
+cleared 381
diff --git a/var/hiscores/boards_intermediate/zxc.mine b/var/hiscores/boards_intermediate/zxc.mine
new file mode 100644
index 0000000..3cbbba1
--- /dev/null
+++ b/var/hiscores/boards_intermediate/zxc.mine
@@ -0,0 +1,40 @@
+mine_sweeper saved game
+rows 16
+cols 16
+mines 40
+gnd
+0,1,1,1,0,0,1,1,2,10,1,1,10,1,0,0
+0,1,10,1,0,1,2,12,3,2,2,2,2,2,1,1
+0,1,1,2,1,2,11,3,11,1,2,11,3,2,11,1
+0,1,1,2,10,2,1,2,1,1,2,11,3,11,2,1
+1,2,10,2,1,1,1,1,1,0,1,1,2,1,1,0
+10,3,2,3,1,1,1,11,2,1,0,0,0,0,0,0
+1,2,11,3,11,1,1,2,11,1,0,0,0,0,1,1
+0,1,3,13,3,1,0,1,1,1,1,1,1,1,3,12
+0,0,2,11,2,0,0,0,1,1,2,10,1,1,12,12
+0,0,1,1,2,1,2,1,2,10,3,2,2,1,3,3
+0,1,1,1,1,11,3,11,2,1,2,10,1,0,1,10
+1,2,11,1,1,3,13,3,1,0,1,2,2,1,1,1
+1,11,2,1,0,2,11,3,2,2,1,2,11,2,0,0
+1,1,1,0,1,2,2,2,11,11,2,3,12,2,0,0
+0,0,0,0,2,11,2,2,3,3,2,11,2,1,0,0
+0,0,0,0,2,11,2,1,10,1,1,1,1,0,0,0
+usr
+1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1
+1,1,2,1,1,1,1,2,1,1,1,1,1,1,1,1
+1,1,1,1,1,1,2,1,2,1,1,2,1,1,2,1
+1,1,1,1,2,1,1,1,1,1,1,2,1,2,1,1
+1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1
+2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1
+1,1,2,1,2,1,1,1,2,1,1,1,1,1,1,1
+1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2
+1,1,1,2,1,1,1,1,1,1,1,2,1,1,2,2
+1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1
+1,1,1,1,1,2,1,2,1,1,1,2,1,1,1,2
+1,1,2,1,1,1,2,1,1,1,1,1,1,1,1,1
+1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,1
+1,1,1,1,1,1,1,1,2,2,1,1,2,1,1,1
+1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1
+1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1
+flags 40
+cleared 216
diff --git a/var/hiscores/hiscores_beginner.mine b/var/hiscores/hiscores_beginner.mine
new file mode 100644
index 0000000..57b227d
--- /dev/null
+++ b/var/hiscores/hiscores_beginner.mine
@@ -0,0 +1 @@
+beginner times
diff --git a/var/hiscores/hiscores_expert.mine b/var/hiscores/hiscores_expert.mine
new file mode 100644
index 0000000..88ef3bf
--- /dev/null
+++ b/var/hiscores/hiscores_expert.mine
@@ -0,0 +1 @@
+expert times
diff --git a/var/hiscores/hiscores_intermediate.mine b/var/hiscores/hiscores_intermediate.mine
new file mode 100644
index 0000000..a1fd0ca
--- /dev/null
+++ b/var/hiscores/hiscores_intermediate.mine
@@ -0,0 +1 @@
+intermediate times