mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
by popular request, stop giving away numeric letters. no more will the
appearance of 509 in a symbol name tell you what letter to guess first.
This commit is contained in:
parent
9b803ea906
commit
f005acd6ef
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.c,v 1.7 2015/02/07 01:37:30 miod Exp $ */
|
||||
/* $OpenBSD: extern.c,v 1.8 2015/02/07 03:26:20 tedu Exp $ */
|
||||
/* $NetBSD: extern.c,v 1.3 1995/03/23 08:32:41 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include "hangman.h"
|
||||
|
||||
bool Guessed[26];
|
||||
bool Guessed[26 + 10];
|
||||
|
||||
char Word[BUFSIZ], Known[BUFSIZ];
|
||||
const char *const Noose_pict[] = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: getguess.c,v 1.11 2015/02/07 03:07:02 tedu Exp $ */
|
||||
/* $OpenBSD: getguess.c,v 1.12 2015/02/07 03:26:20 tedu Exp $ */
|
||||
/* $NetBSD: getguess.c,v 1.5 1995/03/23 08:32:43 cgd Exp $ */
|
||||
|
||||
/*
|
||||
@ -59,6 +59,14 @@ getguess(void)
|
||||
ch);
|
||||
} else
|
||||
break;
|
||||
} else if (isdigit((unsigned char)ch)) {
|
||||
if (Guessed[ch - '0' + 26]) {
|
||||
move(MESGY, MESGX);
|
||||
clrtoeol();
|
||||
mvprintw(MESGY, MESGX, "Already guessed '%c'",
|
||||
ch);
|
||||
} else
|
||||
break;
|
||||
} else
|
||||
if (ch == CTRL('D'))
|
||||
die(0);
|
||||
@ -73,9 +81,12 @@ getguess(void)
|
||||
move(MESGY, MESGX);
|
||||
clrtoeol();
|
||||
|
||||
Guessed[ch - 'a'] = TRUE;
|
||||
if (isalpha((unsigned char)ch))
|
||||
Guessed[ch - 'a'] = TRUE;
|
||||
else
|
||||
Guessed[ch - '0' + 26] = TRUE;
|
||||
correct = FALSE;
|
||||
uch = toupper(ch);
|
||||
uch = toupper((unsigned char)ch);
|
||||
for (i = 0; Word[i] != '\0'; i++)
|
||||
if (Word[i] == ch) {
|
||||
Known[i] = ch;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ksyms.c,v 1.7 2015/02/07 03:07:02 tedu Exp $ */
|
||||
/* $OpenBSD: ksyms.c,v 1.8 2015/02/07 03:26:20 tedu Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Miodrag Vallat.
|
||||
@ -85,7 +85,7 @@ sym_getword()
|
||||
for (sym = Known; *sym != '\0'; sym++) {
|
||||
if (*sym == '-')
|
||||
*sym = '_'; /* try not to confuse player */
|
||||
if (isalpha((unsigned char)*sym))
|
||||
if (isalnum((unsigned char)*sym))
|
||||
*sym = '-';
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: playgame.c,v 1.9 2015/02/07 01:37:30 miod Exp $ */
|
||||
/* $OpenBSD: playgame.c,v 1.10 2015/02/07 03:26:20 tedu Exp $ */
|
||||
/* $NetBSD: playgame.c,v 1.3 1995/03/23 08:32:53 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -39,16 +39,15 @@
|
||||
void
|
||||
playgame(void)
|
||||
{
|
||||
bool *bp;
|
||||
int i;
|
||||
|
||||
if (syms)
|
||||
sym_getword();
|
||||
else
|
||||
getword();
|
||||
Errors = 0;
|
||||
bp = Guessed;
|
||||
while (bp < &Guessed[26])
|
||||
*bp++ = FALSE;
|
||||
for (i = 0; i < 26 + 10; i++)
|
||||
Guessed[i] = FALSE;
|
||||
while (Errors < MAXERRS && strchr(Known, '-') != NULL) {
|
||||
prword();
|
||||
prdata();
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: prdata.c,v 1.6 2009/10/27 23:59:25 deraadt Exp $ */
|
||||
/* $OpenBSD: prdata.c,v 1.7 2015/02/07 03:26:20 tedu Exp $ */
|
||||
/* $NetBSD: prdata.c,v 1.3 1995/03/23 08:32:54 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -39,13 +39,15 @@
|
||||
void
|
||||
prdata(void)
|
||||
{
|
||||
bool *bp;
|
||||
int i;
|
||||
|
||||
move(GUESSY, GUESSX + sizeof "Guessed: ");
|
||||
bp = Guessed;
|
||||
while (bp < &Guessed[26])
|
||||
if (*bp++)
|
||||
addch((bp - Guessed) + 'a' - 1);
|
||||
for (i = 0; i < 26; i++)
|
||||
if (Guessed[i])
|
||||
addch(i + 'a');
|
||||
for (i = 0; i < 10; i++)
|
||||
if (Guessed[i + 26])
|
||||
addch(i + '0');
|
||||
clrtoeol();
|
||||
mvprintw(NUMBERY, NUMBERX + sizeof "Word #: ", "%d", Wordnum);
|
||||
mvprintw(AVGY, AVGX + sizeof "Current Average: ", "%.3f",
|
||||
|
Loading…
Reference in New Issue
Block a user