copy in from cvs; cvs2svn fucked up big time

git-svn-id: file:///srv/svn/joey/trunk/src/packages/bsdgames@9775 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
2003-12-19 19:12:08 +00:00
parent 351c8ca204
commit 51eabc017b
310 changed files with 7852 additions and 5005 deletions

View File

@@ -1,6 +1,8 @@
# $NetBSD: Makefile,v 1.10 1998/02/18 22:37:31 jtc Exp $
# $NetBSD: Makefile,v 1.12 1999/02/13 02:54:21 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
.include <bsd.own.mk>
PROG= cribbage
DPADD= ${LIBCURSES}
LDADD= -lcurses
@@ -8,8 +10,10 @@ SRCS= extern.c crib.c cards.c instr.c io.c score.c support.c
MAN= cribbage.6
HIDEGAME=hidegame
SETGIDGAME=yes
.if ${MKSHARE} != "no"
FILES= cribbage.n
FILESNAME=cribbage.instr
FILESDIR=/usr/share/games
.endif
.include <bsd.prog.mk>

View File

@@ -1,4 +1,30 @@
# Makefrag - makefile fragment for cribbage
#
# Copyright (c) 1997, 1998 Joseph Samuel Myers.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
cribbage_DIRS := $(GAMESDIR) $(MAN6DIR) $(shell dirname $(CRIBBAGE_INSTRFILE))

View File

@@ -1,4 +1,4 @@
/* $NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $ */
/* $NetBSD: cards.c,v 1.6 1999/09/30 18:01:32 jsm Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)cards.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: cards.c,v 1.4 1997/10/10 12:32:22 lukem Exp $");
__RCSID("$NetBSD: cards.c,v 1.6 1999/09/30 18:01:32 jsm Exp $");
#endif
#endif /* not lint */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: crib.c,v 1.10 1998/08/30 09:19:37 veego Exp $ */
/* $NetBSD: crib.c,v 1.16 2001/12/06 11:59:45 blymn Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: crib.c,v 1.10 1998/08/30 09:19:37 veego Exp $");
__RCSID("$NetBSD: crib.c,v 1.16 2001/12/06 11:59:45 blymn Exp $");
#endif
#endif /* not lint */
@@ -76,6 +76,8 @@ main(argc, argv)
f = fopen(_PATH_LOG, "a");
if (f == NULL)
warn("fopen %s", _PATH_LOG);
if (f != NULL && fileno(f) < 3)
exit(1);
/* Revoke setgid privileges */
setregid(getgid(), getgid());
@@ -110,7 +112,7 @@ main(argc, argv)
initscr();
(void)signal(SIGINT, rint);
crmode();
cbreak();
noecho();
Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, 0);
@@ -130,7 +132,7 @@ main(argc, argv)
mvcur(0, COLS - 1, LINES - 1, 0);
fflush(stdout);
instructions();
crmode();
cbreak();
noecho();
clear();
refresh();
@@ -194,8 +196,6 @@ makeboard()
void
gamescore()
{
extern int Lastscore[];
if (pgames || cgames) {
mvprintw(SCORE_Y + 1, SCORE_X + 28, "Games: %3d", pgames);
mvprintw(SCORE_Y + 7, SCORE_X + 28, "Games: %3d", cgames);

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: cribbage.6,v 1.5 1997/10/10 12:32:26 lukem Exp $
.\" $NetBSD: cribbage.6,v 1.10 2002/09/30 12:43:22 wiz Exp $
.\"
.\" Copyright (c) 1980, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -45,9 +45,9 @@
.Sh DESCRIPTION
.Nm
plays the card game cribbage, with the program playing one hand
and the user the other. The program will initially ask the user if
the rules of the game are needed \- if so, it will print out
the appropriate section from
and the user the other.
The program will initially ask the user if the rules of the game are
needed \(en if so, it will print out the appropriate section from
.Em According to Hoyle
with
.Xr more 1 .
@@ -57,10 +57,10 @@ options include:
.Bl -tag -width indent
.It Fl e
When the player makes a mistake scoring his hand or crib, provide an
explanation of the correct score. (This is especially useful for
beginning players.)
explanation of the correct score.
(This is especially useful for beginning players.)
.It Fl q
Print a shorter form of all messages \- this is only recommended for
Print a shorter form of all messages \(en this is only recommended for
users who have played the game without specifying this option.
.It Fl r
Instead of asking the player to cut the deck, the program will randomly
@@ -72,24 +72,23 @@ first asks the player whether he wishes to play a short game (
.Dq once around ,
to 61) or a long game (
.Dq twice around ,
to 121). A
response of
to 121).
A response of
.Sq Ic s
will result in a short game, any other response will
play a long game.
will result in a short game, any other response will play a long game.
.Pp
At the start of the first game, the program
asks the player to cut the deck to determine who gets the
first crib. The user should respond with a number between 0 and
51, indicating how many cards down the deck is to be cut. The player
who cuts the lower ranked card gets the first crib.
asks the player to cut the deck to determine who gets the first crib.
The user should respond with a number between 0 and
51, indicating how many cards down the deck is to be cut.
The player who cuts the lower ranked card gets the first crib.
If more than one game is played, the
loser of the previous game gets the first crib in the current game.
.Pp
For each hand, the program first prints the player's hand,
whose crib it is, and then asks the player
to discard two cards into the crib. The cards are prompted for
one per line, and are typed as explained below.
to discard two cards into the crib.
The cards are prompted for one per line, and are typed as explained below.
.Pp
After discarding, the program cuts the deck (if it is the player's
crib) or asks the player to cut the deck (if it's its crib); in the latter
@@ -98,11 +97,12 @@ how far down the remaining 40 cards are to be cut.
.Pp
After cutting the deck, play starts with the non-dealer (the person
who doesn't have the crib) leading the first card.
Play continues, as per cribbage, until all cards are exhausted. The
program keeps track of the scoring of all points and the total of
Play continues, as per cribbage, until all cards are exhausted.
The program keeps track of the scoring of all points and the total of
the cards on the table.
.Pp
After play, the hands are scored. The program requests the player to
After play, the hands are scored.
The program requests the player to
score his hand (and the crib, if it is his) by printing out the
appropriate cards (and the cut card enclosed in brackets).
Play continues until one player reaches the game limit (61 or 121).
@@ -111,7 +111,8 @@ A carriage return when a numeric input is expected is equivalent
to typing the lowest legal value; when cutting the deck this
is equivalent to choosing the top card.
.Pp
Cards are specified as rank followed by suit. The ranks may be specified
Cards are specified as rank followed by suit.
The ranks may be specified
as one of:
.Sq a ,
.Sq 2 ,
@@ -140,9 +141,9 @@ or alternatively, one of:
.Sq ten ,
.Sq jack ,
.Sq queen ,
and
and
.Sq king .
Suits may be specified as:
Suits may be specified as:
.Sq s ,
.Sq h ,
.Sq d ,
@@ -154,16 +155,17 @@ or alternatively as:
.Sq diamonds ,
and
.Sq clubs .
A card may be specified as:
A card may be specified as:
.Dq Ao rank Ac \ Aq suit ,
or:
or:
.Dq Ao rank Ac of Aq suit .
If the single letter rank and suit designations are used, the space
separating the suit and rank may be left out. Also, if only one card
separating the suit and rank may be left out.
Also, if only one card
of the desired rank is playable, typing the rank is sufficient.
For example, if your hand was
For example, if your hand was
.Dq 2H, 4D, 5C, 6H, JC, and KD
and it was desired to discard the king of diamonds, any of
and it was desired to discard the king of diamonds, any of
the following could be typed:
.Sq k ,
.Sq king ,
@@ -177,7 +179,7 @@ the following could be typed:
.Sq king diamonds ,
.Sq king of diamonds .
.Sh FILES
.Bl -tag -width @gamesdir@/cribbage -compact
.Bl -tag -width @cribbage_instrfile@ -compact
.It Pa @gamesdir@/cribbage
.It Pa @cribbage_scorefile@
.It Pa @cribbage_instrfile@

View File

@@ -1,4 +1,4 @@
/* $NetBSD: cribbage.h,v 1.4 1998/09/13 15:27:27 hubertf Exp $ */
/* $NetBSD: cribbage.h,v 1.8 2002/12/06 01:48:24 thorpej Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -59,9 +59,10 @@ extern BOOLEAN rflag; /* if all cuts random */
extern BOOLEAN quiet; /* if suppress random mess */
extern BOOLEAN playing; /* currently playing game */
extern char expl[]; /* string for explanation */
extern char explan[]; /* string for explanation */
void addmsg __P((const char *, ...));
void addmsg __P((const char *, ...))
__attribute__((__format__(__printf__, 1, 2)));
int adjust __P((const CARD [], CARD));
int anymove __P((const CARD [], int, int));
int anysumto __P((const CARD [], int, int, int));
@@ -89,7 +90,8 @@ int is_one __P((CARD, const CARD [], int));
void makeboard __P((void));
void makedeck __P((CARD []));
void makeknown __P((const CARD [], int));
void msg __P((const char *, ...));
void msg __P((const char *, ...))
__attribute__((__format__(__printf__, 1, 2)));
int msgcard __P((CARD, BOOLEAN));
int msgcrd __P((CARD, BOOLEAN, const char *, BOOLEAN));
int number __P((int, int, const char *));

View File

@@ -1,4 +1,4 @@
/* $NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $ */
/* $NetBSD: extern.c,v 1.6 2002/12/06 01:48:24 thorpej Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: extern.c,v 1.4 1997/10/10 12:32:29 lukem Exp $");
__RCSID("$NetBSD: extern.c,v 1.6 2002/12/06 01:48:24 thorpej Exp $");
#endif
#endif /* not lint */
@@ -52,7 +52,7 @@ BOOLEAN iwon = FALSE; /* if comp won last game */
BOOLEAN quiet = FALSE; /* if suppress random mess */
BOOLEAN rflag = FALSE; /* if all cuts random */
char expl[128]; /* explanation */
char explan[128]; /* explanation */
int cgames = 0; /* number games comp won */
int cscore = 0; /* comp score in this game */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: instr.c,v 1.7 1997/10/11 02:44:31 lukem Exp $ */
/* $NetBSD: instr.c,v 1.9 1999/11/09 15:06:32 drochner Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)instr.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: instr.c,v 1.7 1997/10/11 02:44:31 lukem Exp $");
__RCSID("$NetBSD: instr.c,v 1.9 1999/11/09 15:06:32 drochner Exp $");
#endif
#endif /* not lint */
@@ -90,7 +90,7 @@ instructions()
_exit(1);
}
execl("/bin/sh", "sh", "-c", path, NULL);
warn("%s", "");
warn(NULL);
_exit(1);
default:
do {

View File

@@ -1,4 +1,4 @@
/* $NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $ */
/* $NetBSD: io.c,v 1.15 2002/05/26 00:12:11 wiz Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,24 +38,19 @@
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: io.c,v 1.10 1997/10/10 12:32:32 lukem Exp $");
__RCSID("$NetBSD: io.c,v 1.15 2002/05/26 00:12:11 wiz Exp $");
#endif
#endif /* not lint */
#include <ctype.h>
#include <curses.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "deck.h"
#include "cribbage.h"
#include "cribcur.h"
@@ -392,21 +387,11 @@ int Mpos = 0;
static int Newpos = 0;
void
#if __STDC__
msg(const char *fmt, ...)
#else
msg(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsprintf(&Msgbuf[Newpos], fmt, ap);
Newpos = strlen(Msgbuf);
va_end(ap);
@@ -418,21 +403,11 @@ msg(fmt, va_alist)
* Add things to the current message
*/
void
#if __STDC__
addmsg(const char *fmt, ...)
#else
addmsg(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsprintf(&Msgbuf[Newpos], fmt, ap);
Newpos = strlen(Msgbuf);
va_end(ap);
@@ -612,7 +587,7 @@ getline()
void
rint(signo)
int signo __attribute__((unused));
int signo __attribute__((__unused__));
{
bye();
exit(1);

View File

@@ -1,4 +1,4 @@
/* $NetBSD: score.c,v 1.6 1998/08/30 09:19:37 veego Exp $ */
/* $NetBSD: score.c,v 1.9 2002/12/06 01:48:24 thorpej Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: score.c,v 1.6 1998/08/30 09:19:37 veego Exp $");
__RCSID("$NetBSD: score.c,v 1.9 2002/12/06 01:48:24 thorpej Exp $");
#endif
#endif /* not lint */
@@ -122,7 +122,7 @@ scorehand(hand, starter, n, crb, do_explain)
CARD h[(CINHAND + 1)];
char buf[32];
expl[0] = '\0'; /* initialize explanation */
explan[0] = '\0'; /* initialize explanation */
score = 0;
flag = TRUE;
k = hand[0].suit;
@@ -132,29 +132,29 @@ scorehand(hand, starter, n, crb, do_explain)
if (hand[i].suit == starter.suit) {
score++;
if (do_explain)
strcat(expl, "His Nobs");
strcat(explan, "His Nobs");
}
h[i] = hand[i];
}
if (flag && n >= CINHAND) {
if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
if (do_explain && explan[0] != '\0')
strcat(explan, ", ");
if (starter.suit == k) {
score += 5;
if (do_explain)
strcat(expl, "Five-flush");
strcat(explan, "Five-flush");
} else
if (!crb) {
score += 4;
if (do_explain && expl[0] != '\0')
strcat(expl, ", Four-flush");
if (do_explain && explan[0] != '\0')
strcat(explan, ", Four-flush");
else
strcpy(expl, "Four-flush");
strcpy(explan, "Four-flush");
}
}
if (do_explain && expl[0] != '\0')
strcat(expl, ", ");
if (do_explain && explan[0] != '\0')
strcat(explan, ", ");
h[n] = starter;
sorthand(h, n + 1); /* sort by rank */
i = 2 * fifteens(h, n + 1);
@@ -162,9 +162,9 @@ scorehand(hand, starter, n, crb, do_explain)
if (do_explain) {
if (i > 0) {
(void) sprintf(buf, "%d points in fifteens", i);
strcat(expl, buf);
strcat(explan, buf);
} else
strcat(expl, "No fifteens");
strcat(explan, "No fifteens");
}
i = pairuns(h, n + 1);
score += i;
@@ -172,9 +172,9 @@ scorehand(hand, starter, n, crb, do_explain)
if (i > 0) {
(void) sprintf(buf, ", %d points in pairs, %d in runs",
pairpoints, runpoints);
strcat(expl, buf);
strcat(explan, buf);
} else
strcat(expl, ", No pairs/runs");
strcat(explan, ", No pairs/runs");
}
return (score);
}
@@ -354,7 +354,7 @@ pegscore(crd, tbl, n, sum)
int
adjust(cb, tnv)
const CARD cb[];
CARD tnv __attribute__((unused));
CARD tnv __attribute__((__unused__));
{
long scr;
int i, c0, c1;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $ */
/* $NetBSD: support.c,v 1.6 2002/12/06 01:48:25 thorpej Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)support.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: support.c,v 1.4 1997/10/10 12:32:36 lukem Exp $");
__RCSID("$NetBSD: support.c,v 1.6 2002/12/06 01:48:25 thorpej Exp $");
#endif
#endif /* not lint */
@@ -152,7 +152,7 @@ plyrhand(hand, s)
msg("You should have taken %d, not %d!", i, j);
}
if (explain)
msg("Explanation: %s", expl);
msg("Explanation: %s", explan);
do_wait();
} else
win = chkscr(&pscore, i);