SCCS-vsn: games/cribbage/crib.c 1.14
SCCS-vsn: games/cribbage/io.c 1.8
SCCS-vsn: games/cribbage/support.c 1.10
SCCS-vsn: games/cribbage/cribbage.h 1.3
SCCS-vsn: games/cribbage/cribcur.h 1.3
SCCS-vsn: games/cribbage/extern.c 1.2
signal(SIGINT, bye);
crmode();
noecho();
signal(SIGINT, bye);
crmode();
noecho();
- Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, SCORE_SZ);
- Tablewin = subwin(stdscr, TABLE_Y, TABLE_X, 0, PLAY_X + SCORE_SZ);
- Compwin = subwin(stdscr, COMP_Y, COMP_X, 0, TABLE_X + PLAY_X + SCORE_SZ);
+ Playwin = subwin(stdscr, PLAY_Y, PLAY_X, 0, X_SCORE_SZ);
+ Tablewin = subwin(stdscr, TABLE_Y, TABLE_X, 0, PLAY_X + X_SCORE_SZ);
+ Compwin = subwin(stdscr, COMP_Y, COMP_X, 0, TABLE_X + PLAY_X + X_SCORE_SZ);
+ Msgwin = subwin(stdscr, MSG_Y, MSG_X, Y_SCORE_SZ + 1, 0);
leaveok(Playwin, TRUE);
leaveok(Tablewin, TRUE);
leaveok(Compwin, TRUE);
leaveok(Playwin, TRUE);
leaveok(Tablewin, TRUE);
leaveok(Compwin, TRUE);
+ clearok(stdscr, FALSE);
if (!quiet) {
msg("Do you need instructions for cribbage? ");
if (!quiet) {
msg("Do you need instructions for cribbage? ");
BOOLEAN compcrib;
makeboard();
BOOLEAN compcrib;
makeboard();
makedeck(deck);
shuffle(deck);
if (gamecount == 0) {
makedeck(deck);
shuffle(deck);
if (gamecount == 0) {
extern char Msgbuf[];
werase(Compwin);
extern char Msgbuf[];
werase(Compwin);
- wrefresh(Compwin);
- move(CRIB_Y, SCORE_SZ);
- clrtobot();
- mvaddstr(LINES - 1, 0, Msgbuf);
knownum = 0;
deckpos = deal(mycrib);
knownum = 0;
deckpos = deal(mycrib);
prcrib(mycrib, blank)
BOOLEAN mycrib, blank;
{
prcrib(mycrib, blank)
BOOLEAN mycrib, blank;
{
if (mycrib)
cardx = CRIB_X;
else
if (mycrib)
cardx = CRIB_X;
else
mvaddstr(CRIB_Y, cardx + 1, "CRIB");
prcard(stdscr, CRIB_Y + 1, cardx, turnover, blank);
mvaddstr(CRIB_Y, cardx + 1, "CRIB");
prcard(stdscr, CRIB_Y + 1, cardx, turnover, blank);
+
+ if (mycrib)
+ cardx = X_SCORE_SZ;
+ else
+ cardx = CRIB_X;
+
+ for (y = CRIB_Y; y <= CRIB_Y + 5; y++)
+ mvaddstr(y, cardx, " ");
sum = 0;
mego = ugo = FALSE;
Tcnt = 0;
sum = 0;
mego = ugo = FALSE;
Tcnt = 0;
sum = 0;
mego = ugo = FALSE;
Tcnt = 0;
sum = 0;
mego = ugo = FALSE;
Tcnt = 0;
}
}
else { /* player plays */
}
}
else { /* player plays */
mego = ugo = FALSE;
Tcnt = 0;
last = FALSE; /* disable last flag */
mego = ugo = FALSE;
Tcnt = 0;
last = FALSE; /* disable last flag */
}
if (!pnum && !cnum)
break; /* both done */
}
if (!pnum && !cnum)
break; /* both done */
extern BOOLEAN explain; /* player mistakes explained */
extern BOOLEAN rflag; /* if all cuts random */
extern BOOLEAN quiet; /* if suppress random mess */
extern BOOLEAN explain; /* player mistakes explained */
extern BOOLEAN rflag; /* if all cuts random */
extern BOOLEAN quiet; /* if suppress random mess */
-extern BOOLEAN Hasread; /* has had chance to read msg */
extern BOOLEAN playing; /* currently playing game */
extern char expl[]; /* string for explanation */
extern BOOLEAN playing; /* currently playing game */
extern char expl[]; /* string for explanation */
# define COMP_X 12
# define SCORE_Y 0 /* starting position of scoring board */
# define SCORE_X 0
# define COMP_X 12
# define SCORE_Y 0 /* starting position of scoring board */
# define SCORE_X 0
-# define SCORE_SZ 41 /* X size of score board */
+# define Y_SCORE_SZ 11 /* X size of score board */
+# define X_SCORE_SZ 41 /* X size of score board */
# define CRIB_Y 17 /* position of crib (cut card) */
# define CRIB_Y 17 /* position of crib (cut card) */
-# define CRIB_X (PLAY_X + TABLE_X + SCORE_SZ)
+# define CRIB_X (PLAY_X + TABLE_X + X_SCORE_SZ)
+# define MSG_Y (LINES - (Y_SCORE_SZ + 1))
+# define MSG_X X_SCORE_SZ
# define PEG '*' /* what a peg looks like on the board */
# define PEG '*' /* what a peg looks like on the board */
+extern WINDOW *Compwin; /* computer's hand window */
+extern WINDOW *Msgwin; /* message window */
extern WINDOW *Playwin; /* player's hand window */
extern WINDOW *Tablewin; /* table window */
extern WINDOW *Playwin; /* player's hand window */
extern WINDOW *Tablewin; /* table window */
-extern WINDOW *Compwin; /* computer's hand window */
# include "deck.h"
# include "cribbage.h"
# include "deck.h"
# include "cribbage.h"
-bool iwon = FALSE; /* if comp won last game */
-bool explain = FALSE; /* player mistakes explained */
-bool rflag = FALSE; /* if all cuts random */
-bool quiet = FALSE; /* if suppress random mess */
-bool Hasread = TRUE; /* if has read msg */
+bool explain = FALSE; /* player mistakes explained */
+bool iwon = FALSE; /* if comp won last game */
+bool quiet = FALSE; /* if suppress random mess */
+bool rflag = FALSE; /* if all cuts random */
-char expl[128]; /* explanation */
+char expl[128]; /* explanation */
-int knownum = 0; /* number of cards we know */
-int pscore = 0; /* player score in this game */
-int cscore = 0; /* comp score in this game */
-int pgames = 0; /* number games player won */
-int cgames = 0; /* number games comp won */
-int gamecount = 0; /* number games played */
-int glimit = LGAME; /* game playe to glimit */
+int cgames = 0; /* number games comp won */
+int cscore = 0; /* comp score in this game */
+int gamecount = 0; /* number games played */
+int glimit = LGAME; /* game playe to glimit */
+int knownum = 0; /* number of cards we know */
+int pgames = 0; /* number games player won */
+int pscore = 0; /* player score in this game */
-CARD deck[CARDS]; /* a deck */
-CARD phand[FULLHAND]; /* player's hand */
-CARD chand[FULLHAND]; /* computer's hand */
-CARD crib[CINHAND]; /* the crib */
-CARD turnover; /* the starter */
-CARD known[CARDS]; /* cards we have seen */
+CARD chand[FULLHAND]; /* computer's hand */
+CARD crib[CINHAND]; /* the crib */
+CARD deck[CARDS]; /* a deck */
+CARD known[CARDS]; /* cards we have seen */
+CARD phand[FULLHAND]; /* player's hand */
+CARD turnover; /* the starter */
-WINDOW *Playwin; /* player's hand window */
-WINDOW *Tablewin; /* table window */
-WINDOW *Compwin; /* computer's hand window */
+WINDOW *Compwin; /* computer's hand window */
+WINDOW *Msgwin; /* messages for the player */
+WINDOW *Playwin; /* player's hand window */
+WINDOW *Tablewin; /* table window */
# include <unctrl.h>
# include "deck.h"
# include "cribbage.h"
# include <unctrl.h>
# include "deck.h"
# include "cribbage.h"
+# ifdef CTRL
+# undef CTRL
+# endif
# define CTRL(X) ('X' - 'A' + 1)
# ifndef attron
# define CTRL(X) ('X' - 'A' + 1)
# ifndef attron
c = readchar();
if (islower(c))
c = toupper(c);
c = readchar();
if (islower(c))
c = toupper(c);
- /*
- * if the string is "", just clear the line
- */
- if (*fmt == '\0') {
- move(LINES - 1, 0);
- clrtoeol();
- Mpos = 0;
- Hasread = TRUE;
- return;
- }
- /*
- * otherwise add to the message and flush it out
- */
doadd(fmt, &args);
endmsg();
}
doadd(fmt, &args);
endmsg();
}
- * Display a new msg (giving him a chance to see the previous one
- * if it is up there with the --More--)
- if (!Hasread) {
- move(LINES - 1, Mpos);
- addstr("--More--");
- refresh();
- wait_for(' ');
- }
+ register int len;
+ register char *mp, *omp;
+ static int lineno = 0;
+
/*
* All messages should start with uppercase, except ones that
* start with a pack addressing character
*/
if (islower(Msgbuf[0]) && Msgbuf[1] != ')')
Msgbuf[0] = toupper(Msgbuf[0]);
/*
* All messages should start with uppercase, except ones that
* start with a pack addressing character
*/
if (islower(Msgbuf[0]) && Msgbuf[1] != ')')
Msgbuf[0] = toupper(Msgbuf[0]);
- mvaddstr(LINES - 1, 0, Msgbuf);
- clrtoeol();
+ mp = Msgbuf;
+ len = strlen(mp);
+ if (len / MSG_X + lineno > MSG_Y)
+ lineno = 0;
+ do {
+ mvwaddstr(Msgwin, lineno, 0, mp);
+ if ((len = strlen(mp)) > MSG_X) {
+ omp = mp;
+ for (mp = &mp[MSG_X-1]; *mp != ' '; mp--)
+ continue;
+ while (*mp == ' ')
+ mp--;
+ mp++;
+ wmove(Msgwin, lineno, mp - omp);
+ wclrtoeol(Msgwin);
+ }
+ if (++lineno >= MSG_Y)
+ lineno = 0;
+ } while (len > MSG_X);
+ wclrtoeol(Msgwin);
Mpos = Newpos;
Newpos = 0;
Mpos = Newpos;
Newpos = 0;
wrefresh(curscr);
goto over;
}
wrefresh(curscr);
goto over;
}
if (c == '\r')
return '\n';
else
if (c == '\r')
return '\n';
else
{
register char *sp;
register int c, oy, ox;
{
register char *sp;
register int c, oy, ox;
+ oscr = stdscr;
+ stdscr = Msgwin;
getyx(stdscr, oy, ox);
refresh();
/*
getyx(stdscr, oy, ox);
refresh();
/*
c = toupper(c);
*sp++ = c;
addstr(unctrl(c));
c = toupper(c);
*sp++ = c;
addstr(unctrl(c));
-/*###366 [cc] Mpos undefined %%%*/
j = scorehand(h, turnover, CINHAND, FALSE, FALSE);
prhand(h, CINHAND, Compwin, FALSE);
j = scorehand(h, turnover, CINHAND, FALSE, FALSE);
prhand(h, CINHAND, Compwin, FALSE);
msg("My %s scores %d", s, (j == 0 ? 19 : j));
return chkscr(&cscore, j);
}
msg("My %s scores %d", s, (j == 0 ? 19 : j));
return chkscr(&cscore, j);
}