Add -r option to man and readme and make reset option actually prompt. Remove hardcoded merge_goal value.
This commit is contained in:
parent
40f6419c55
commit
2d9af767d1
20
README.md
20
README.md
|
@ -13,7 +13,7 @@ create a .c file which implements all the functions in gfx.h and add a Makefile
|
|||
git clone https://github.com/Tiehuis/2048-cli.git
|
||||
make
|
||||
|
||||
You can easily install this on el >= 5 (CentOS, RedHat Enterprise Linux,
|
||||
You can also easily install this on el >= 5 (CentOS, RedHat Enterprise Linux,
|
||||
Scientific Linux, Oracle) and Fedora >= 19 using the package-manager:
|
||||
|
||||
sudo yum install 2048-cli[-nocurses]
|
||||
|
@ -22,15 +22,19 @@ For el you will need to have the
|
|||
[EPEL-repository](https://fedoraproject.org/wiki/EPEL/FAQ#How_can_I_install_the_packages_from_the_EPEL_software_repository.3F)
|
||||
enabled.
|
||||
|
||||
### Run
|
||||
./2048
|
||||
## Controls
|
||||
hjkl and wasd Default movement keys
|
||||
q Quit the current game
|
||||
|
||||
## Options
|
||||
-s <size> Set the grid border length
|
||||
-b <rate> Set the block spawn rate
|
||||
-r Resets hiscore. Will prompt user
|
||||
-c Enables color support (ncurses version only)
|
||||
-C Disables color support (ncurses version only)
|
||||
-h Print the program usage
|
||||
-C Disable color support (default).
|
||||
-c Enable color support if supported.
|
||||
-a Enable animations (default).
|
||||
-A Disable animations.
|
||||
-r Reset highscore. Will prompt user.
|
||||
-s SIZE Set the size of the playing field.
|
||||
-b RATE Set the rate at which blocks spawn per turn.
|
||||
|
||||
Fonts used in SDL version can be found [here](http://www.openfontlibrary.org).
|
||||
|
||||
|
|
11
man/2048.1
11
man/2048.1
|
@ -29,16 +29,19 @@ Quit the current game.
|
|||
Print the program usage.
|
||||
.TP
|
||||
.BR \-c
|
||||
Turn on color support (default).
|
||||
Enable color support if supported.
|
||||
.TP
|
||||
.BR \-C
|
||||
Turn off color support.
|
||||
Disable color support (default).
|
||||
.TP
|
||||
.BR \-a
|
||||
Turn on animations (default).
|
||||
Enable animations (default).
|
||||
.TP
|
||||
.BR \-A
|
||||
Turn off animations.
|
||||
Disable animations.
|
||||
.TP
|
||||
.BR \-r
|
||||
Reset highscore. Will prompt user.
|
||||
.TP
|
||||
.BR \-s " " \fISIZE\fR
|
||||
Set the size of the playing field. Default is 4. Maximum value is 16, minimum is 4.
|
||||
|
|
|
@ -44,7 +44,34 @@ static const char* highscore_retrieve_file(void)
|
|||
void highscore_reset(void)
|
||||
{
|
||||
const char *hsfile = highscore_retrieve_file();
|
||||
const size_t resp_length = 16;
|
||||
char resp[resp_length];
|
||||
|
||||
printf("Are you sure you want to reset your scores? Y(es) or N(o)\n");
|
||||
|
||||
while (1) {
|
||||
fgets(resp, resp_length, stdin);
|
||||
const size_t sl = strlen(resp);
|
||||
if (sl < resp_length)
|
||||
resp[sl - 1] = '\0';
|
||||
|
||||
if (!strncmp(resp, "Yes", resp_length) ||
|
||||
!strncmp(resp, "Y", resp_length) ||
|
||||
!strncmp(resp, "yes", resp_length) ||
|
||||
!strncmp(resp, "y", resp_length) )
|
||||
goto reset_scores;
|
||||
|
||||
else
|
||||
if (!strncmp(resp, "No", resp_length) ||
|
||||
!strncmp(resp, "N", resp_length) ||
|
||||
!strncmp(resp, "no", resp_length) ||
|
||||
!strncmp(resp, "n", resp_length) )
|
||||
return;
|
||||
|
||||
printf("Please enter Yes or No\n");
|
||||
}
|
||||
|
||||
reset_scores:;
|
||||
FILE *fd = fopen(hsfile, "w+");
|
||||
fprintf(fd, "%d", 0);
|
||||
fclose(fd);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "assert.h"
|
||||
#include "merge.h"
|
||||
|
||||
#define MERGE_GOAL 11
|
||||
#define MERGE_GOAL (int)(sizeof(merge_values)/sizeof(merge_values[0]))
|
||||
|
||||
const long merge_values[] = {
|
||||
0, 2, 4, 8, 16, 32, 64, 128, 256, 512,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* This should return the value of a given index. 0 should default to 0 (empty) */
|
||||
long merge_value(const int v1);
|
||||
|
||||
/* This should return the goal value */
|
||||
/* This should return the goal index value */
|
||||
long merge_goal(void);
|
||||
|
||||
/* Return if a merge is possible between two indices */
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#include "assert.h"
|
||||
#include "merge.h"
|
||||
|
||||
#define MERGE_GOAL 17
|
||||
#define MERGE_GOAL (int)(sizeof(merge_values)/sizeof(merge_values[0]))
|
||||
|
||||
const long merge_values[] = {
|
||||
0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,
|
||||
233, 377, 610, 987, 1597, 2584
|
||||
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,
|
||||
233, 377, 610, 987, 1597
|
||||
};
|
||||
|
||||
inline long merge_value(const int v1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user