diff --git a/Makefile b/Makefile index 7284d88..9634798 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,9 @@ MAN_DIR?=/usr/share/man/man6 CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\" LDFLAGS+= -lncurses -lm +COLORMODE:=FGCOLOR -ALL= jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel +ALL= jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel logik SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_scores darrt_scores all: $(ALL) @@ -53,9 +54,11 @@ redsquare: redsquare.c config.h $(CC) redsquare.c $(LDFLAGS) $(CFLAGS) -o ./redsquare darrt: darrt.c config.h common.h $(CC) darrt.c $(LDFLAGS) $(CFLAGS) -o ./darrt - snakeduel: snakeduel.c config.h $(CC) snakeduel.c $(LDFLAGS) $(CFLAGS) -o ./snakeduel +logik: logik.c + $(CC) $@.c -o $@ -D$(COLORMODE) + clean: rm $(ALL) uninstall: diff --git a/README.md b/README.md index 0789f94..f8b6328 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ The games include: * Redsquare (Conway's Game of Life made playable!) * Darrt (with original gameplay!) * Snakeduel +* Logik (or also known as Mastermind) The difficulty and/or dimensions are adjustable through simple command line options, you can play a minesweeper game that take hours to complete, or exprience hexadecimal sudoku and 8x8 fifteen-like puzzles! diff --git a/logik.c b/logik.c new file mode 100644 index 0000000..2607528 --- /dev/null +++ b/logik.c @@ -0,0 +1,148 @@ +#include +#include +#include +#include + + +#define NBHOLES 5 +#define NBLINES 10 +#define NBCOLORS 8 +#define NBMINUS 5 +unsigned char pion[] = "rgypmRGY"; + +int +convert(unsigned char a) { + + for(int i=0; i 0 ) { + inc[i] = convert(c); + i++; + stop = 0; + } + if( i > 0 & c == 'x' ) { /*aimed to backspace*/ + i--; + printf("\b"); + stop = 0; + } + if( c == 'Q' ) { + stop++; + if( stop == 2) + break; + } + } + printf("\t"); + + if( stop == 2 ) + break; + + black=0; white=0; + /* black section : x : is in the right place */ + for(int i=0; i 0) & (tmp[i] > 0) ) { + if( tmp[i] <= mix[i] ) + white += tmp[i]; + else if ( mix[i] < tmp[i] ) + white += mix[i]; + } + + /* fmt */ + for(int i=0; i < NBHOLES - white ; i++) + printf("-"); + + for(int i=0; i < black; i++) + printf("x"); + + for(int i=0; i < white - black; i++) + printf("o"); + + if( black == 5 ) { + system("/bin/stty cooked"); + printf("\n\tYOU WIN\n"); + return 0; + } + for(int i=0; i