mirror of
https://github.com/abakh/nbsdgames.git
synced 2025-01-03 14:56:23 -05:00
Revert "Merge pull request #21 from philrandom/master"
This reverts commit7566162a57
, reversing changes made to2bf050d2e5
.
This commit is contained in:
parent
7566162a57
commit
83c215cc19
7
Makefile
7
Makefile
@ -9,9 +9,8 @@ MAN_DIR?=/usr/share/man/man6
|
|||||||
CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\"
|
CFLAGS+= -Wno-unused-result -D SCORES_DIR=\"$(SCORES_DIR)\"
|
||||||
LDFLAGS+= -lncurses -lm
|
LDFLAGS+= -lncurses -lm
|
||||||
|
|
||||||
COLORMODE:=FGCOLOR
|
|
||||||
|
|
||||||
ALL= jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel logik
|
ALL= jewels sudoku mines reversi checkers battleship rabbithole sos pipes fifteen memoblocks fisher muncher miketron redsquare darrt snakeduel
|
||||||
SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_scores darrt_scores
|
SCORE_FILES= pipes_scores jewels_scores miketron_scores muncher_scores fisher_scores darrt_scores
|
||||||
|
|
||||||
all: $(ALL)
|
all: $(ALL)
|
||||||
@ -54,11 +53,9 @@ redsquare: redsquare.c config.h
|
|||||||
$(CC) redsquare.c $(LDFLAGS) $(CFLAGS) -o ./redsquare
|
$(CC) redsquare.c $(LDFLAGS) $(CFLAGS) -o ./redsquare
|
||||||
darrt: darrt.c config.h common.h
|
darrt: darrt.c config.h common.h
|
||||||
$(CC) darrt.c $(LDFLAGS) $(CFLAGS) -o ./darrt
|
$(CC) darrt.c $(LDFLAGS) $(CFLAGS) -o ./darrt
|
||||||
|
|
||||||
snakeduel: snakeduel.c config.h
|
snakeduel: snakeduel.c config.h
|
||||||
$(CC) snakeduel.c $(LDFLAGS) $(CFLAGS) -o ./snakeduel
|
$(CC) snakeduel.c $(LDFLAGS) $(CFLAGS) -o ./snakeduel
|
||||||
logik: logik.c
|
|
||||||
$(CC) $@.c -o $@ -D$(COLORMODE)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(ALL)
|
rm $(ALL)
|
||||||
uninstall:
|
uninstall:
|
||||||
|
@ -29,7 +29,6 @@ The games include:
|
|||||||
* Redsquare (Conway's Game of Life made playable!)
|
* Redsquare (Conway's Game of Life made playable!)
|
||||||
* Darrt (with original gameplay!)
|
* Darrt (with original gameplay!)
|
||||||
* Snakeduel
|
* 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!
|
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!
|
||||||
|
148
logik.c
148
logik.c
@ -1,148 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
|
||||||
#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<NBCOLORS; i++)
|
|
||||||
if( a == pion[i] )
|
|
||||||
return i;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
colorize(int a) {
|
|
||||||
return a % NBMINUS + 31;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
bold(int a) {
|
|
||||||
return a <= 'Z';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
pastel(unsigned char a) {
|
|
||||||
if( convert(a) < 0 )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
#ifdef BGCOLOR
|
|
||||||
/* if you want bg color define the macro BGCOLOR: */
|
|
||||||
printf("\033[0;%dm%c\033[0m", bold(a)*10 + colorize(convert(a)), a);
|
|
||||||
#else
|
|
||||||
printf("\033[%d;%dm%c\033[0m", bold(a), colorize(convert(a)), a);
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void) {
|
|
||||||
|
|
||||||
printf("\033[22;34m====================\n\r LOGIK \n\r====================\033[0m\n");
|
|
||||||
|
|
||||||
printf("\rcolors\t");
|
|
||||||
for( int i=0; i<NBCOLORS; i++)
|
|
||||||
pastel( pion[i] );
|
|
||||||
printf("\n\rx is backspace\n\rQQ to exit");
|
|
||||||
|
|
||||||
|
|
||||||
int sol[NBHOLES], mix[NBCOLORS];
|
|
||||||
srand( getpid() * ( 1 + getppid() ) + time(NULL) );
|
|
||||||
for(int i=0; i<NBMINUS; i++)
|
|
||||||
sol[i] = rand() % NBCOLORS;
|
|
||||||
printf("\r");
|
|
||||||
|
|
||||||
for(int i=0; i<NBCOLORS; i++)
|
|
||||||
mix[i]=0;
|
|
||||||
|
|
||||||
for(int i=0; i<NBHOLES; i++)
|
|
||||||
mix[sol[i]]++;
|
|
||||||
|
|
||||||
/* ----- */
|
|
||||||
char c;
|
|
||||||
char inc[NBHOLES], stop=0;
|
|
||||||
int black, white;
|
|
||||||
int tmp[NBCOLORS];
|
|
||||||
system("/bin/stty raw");
|
|
||||||
for(int l=1; l <= NBLINES; l++) {
|
|
||||||
printf("\n\r%d\t",l); /*due to stty raw*/
|
|
||||||
for( int i=0; i < NBHOLES ; ) {
|
|
||||||
c = getchar();
|
|
||||||
if( pastel(c) > 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<NBHOLES; i++)
|
|
||||||
if( inc[i] == sol[i] )
|
|
||||||
black++;
|
|
||||||
|
|
||||||
/* white section : o : the color is right but placed */
|
|
||||||
for(int i=0; i<NBCOLORS; i++)
|
|
||||||
tmp[i]=0;
|
|
||||||
|
|
||||||
for(int i=0; i<NBHOLES; i++)
|
|
||||||
tmp[(int) inc[i]] += 1;
|
|
||||||
|
|
||||||
white = 0;
|
|
||||||
for(int i=0; i<NBCOLORS; i++)
|
|
||||||
if( (mix[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<NBHOLES; inc[i++]=-1)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
system("/bin/stty cooked");
|
|
||||||
printf("\n\rYOU LOOSE\n\r");
|
|
||||||
|
|
||||||
for(int i=0; i<NBHOLES; i++)
|
|
||||||
pastel(pion[sol[i]]);
|
|
||||||
printf("\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
29
man/logik.6
29
man/logik.6
@ -1,29 +0,0 @@
|
|||||||
.TH "LOGIK" "" "May 2021" "" ""
|
|
||||||
.SH "NAME"
|
|
||||||
\fBlogik\fR
|
|
||||||
.SH "CONTROLS"
|
|
||||||
rgypmRGY : put a specific color
|
|
||||||
.P
|
|
||||||
QQ : quit
|
|
||||||
.P
|
|
||||||
x : backspace
|
|
||||||
.SH "GAMEPLAY"
|
|
||||||
The computer generate random pattern of 5 colors
|
|
||||||
that you must guess\. You have 8 colors, and 10 lines
|
|
||||||
to guess with each 5 holes\. After you entered your 5
|
|
||||||
colors the computer will print you a hint, to help you:
|
|
||||||
.P
|
|
||||||
\'-\' : one of the colors doesn't match with the correct answere\.
|
|
||||||
.P
|
|
||||||
\'x\' : one of the colors is on the right place\.
|
|
||||||
.P
|
|
||||||
\'o\' : one of the colors match but is missplaced\.
|
|
||||||
.SH "HISTORY"
|
|
||||||
This is game is known as
|
|
||||||
.B
|
|
||||||
Logik
|
|
||||||
in the eastern block (USSR),
|
|
||||||
and
|
|
||||||
.B
|
|
||||||
Mastermind
|
|
||||||
in the west block (USA)\.
|
|
Loading…
Reference in New Issue
Block a user