-/* $OpenBSD: db_hangman.c,v 1.8 1996/10/21 05:11:47 deraadt Exp $ */
+/* $OpenBSD: db_hangman.c,v 1.9 1996/11/28 19:01:49 niklas Exp $ */
/*
* Copyright (c) 1996 Theo de Raadt, Michael Shalayeff
* 4. The name of the authors may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#include <dev/cons.h>
#include <dev/rndvar.h>
-#define TOLOWER(c) (('A'<=(c)&&(c)<='Z')?(c)-'a'+'A':(c))
+#define TOLOWER(c) (('A'<=(c)&&(c)<='Z')?(c)-'A'+'a':(c))
#define ISALPHA(c) (('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='Z'))
-static __inline size_t db_random __P((size_t));
-static __inline char *db_randomsym __P((size_t *));
-static void db_hang __P((int, char *, char *));
-static int db_hangon __P((void));
+static __inline size_t db_random __P((size_t));
+static __inline char *db_randomsym __P((size_t *));
+void db_hang __P((int, char *, char *));
+int db_hangon __P((void));
+
+static int skill;
static __inline size_t
db_random( mod )
return ret % mod;
}
-static int skill;
-
static __inline char *
db_randomsym(lenp)
size_t *lenp;
return q;
}
+static char hangpic[]=
+ "\n88888 \r\n"
+ "9 7 6 \r\n"
+ "97 5 \r\n"
+ "9 423\r\n"
+ "9 2 \r\n"
+ "9 1 0\r\n"
+ "9\r\n"
+ "9 ";
+static char substchar[]="\\/|\\/O|/-|";
-static void
+void
db_hang(tries, word, abc)
int tries;
register char *word;
{
register char *p;
- cnputc(' ');
+ for(p=hangpic; *p; p++) {
+ if(*p>='0' && *p<='9')
+ {
+ if(tries<=(*p)-'0')
+ cnputc(substchar[(*p)-'0']);
+ else
+ cnputc(' ');
+ } else
+ cnputc(*p);
+ }
+
for (p = word; *p; p++)
if (ISALPHA(*p))
cnputc(abc[TOLOWER(*p) - 'a']);
cnputc(' ');
cnputc('(');
- cnputc('0' + tries);
- cnputc(' ');
for (p = abc; *p; p++)
if (*p == '_')
}
-static int
+int
db_hangon(void)
{
static size_t len;
}
if (tries && len)
- return db_hangon();
+ return 1;
if (!tries && skill > 2)
{