|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T h
Length: 3095 (0xc17) Types: TextFile Names: »human.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Nobs/human.c«
#include "defs.h" #include "globs.h" #include "window.h" #ifdef BSD #include <ctype.h> #endif static char selected[6]; static int nselected; humandiscard(hand, mydeal) CARD hand[]; int mydeal; { int j, j1, j2; char k; for (j=0; j<6; j++) mvwaddch(Select, 0, 5*j+2, 'a'+j); wrefresh(Select); mvwprintw( Prompt, 0, 0, mydeal? "It is your crib.\n": "It is my crib.\n"); #ifdef GDISC mvwprintw(Prompt, 1, 0, "Select 2 cards. Type \"g\" to discard.\n"); #else mvwprintw(Prompt, 1, 0, "Select 2 cards. Type RETURN to discard.\n"); #endif if (hflag) { mvwprintw(Hscore, 0, 0, "Type \"h\" for hint\n"); wrefresh(Hscore); } for (j=0; j<6; j++) selected[j]=0; nselected = 0; for (;;) { mvwaddch(Prompt, 1, 41, '\n'); wmove(Prompt, 1, 41); wrefresh(Prompt); k = wgetch(Prompt); k = tolower(k); #ifdef GDISC if ('g'==k) { #else if ('\n'==k || '\r'==k) { #endif if (nselected == 2) break; beep(); continue; } if (hflag && k == 'h') { hint(hand, mydeal); continue; } if (k > 'f' || k < 'a') { beep(); continue; } nselected -= selected[k-'a']; nselected += (selected[k-'a'] ^= 1); mvwaddch(Humanhand, 2, 5*(k-'a')+3, selected[k-'a']? '*': ' '); wrefresh(Humanhand); } if (hflag) { werase(Hscore); wrefresh(Hscore); } werase(Select); werase(Prompt); wrefresh(Select); wrefresh(Prompt); for (j=0; j<6; j++) if (selected[j]) { j1 = j2; /* and you know Lint won't like this! */ j2 = j; } makediscard(hand, j1, j2); } hint(ihand, mydeal) { int a, b, k; bestdis(ihand, mydeal, &a, &b); for (k=0; k<6; k++) { selected[k] = k==a || k==b; mvwaddch(Humanhand, 2, 5*k+3, selected[k]? '*': ' '); } nselected = 2; werase(Hscore); wrefresh(Humanhand); wrefresh(Hscore); } humanplay() { char k; int sco; if (whosego == whoseturn) { /* * It is my go. Can I play? */ if (goodgo(whoseturn)) { SCOREUP(whoseturn, 1); resetgo(); handover = !nleft[0] && !nleft[1]; return; } else mvwprintw(Prompt, 1, 0, "Select a card.\n"); } else if (!nleft[whoseturn]) { handover = !nleft[0] && !nleft[1]; if (handover) SCOREUP(whoseturn, 1); return; } else if (whosego == !whoseturn) return; else mvwprintw(Prompt, 1, 0, "Select a card, or type \"g\" for go."); for (;;) { mvwaddch(Prompt, 1, 41, '\n'); wrefresh(Prompt); k = wgetch(Prompt); k = tolower(k); if (k == 'g') { if (goodgo(whoseturn)) { whosego = !whoseturn; return; } else beep(); } else if (k < 'a' || k > 'd') beep(); else if (goodplay(whoseturn, k-'a')) break; else beep(); } werase(Prompt); played[whoseturn][k-'a'] = 1; count += rankvalue[RANK(hand[whoseturn][k-'a'])]; go[gocount++] = hand[whoseturn][k-'a']; nleft[whoseturn] -= 1; sco = playscore(); showhplay(k-'a', sco); if (sco) SCOREUP(whoseturn, sco); handover = !nleft[0] && !nleft[1]; if (count==31) resetgo(); else if (handover) { mvwprintw(Prompt, 0, 0, "That's a Go\n"); SCOREUP(whoseturn, 1); } sleep(1); } /* * This is pre-defined in Vr2 curses, but I'll just define it anyway. */ beep() { putchar('\007'); }