|
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 d
Length: 4745 (0x1289) Types: TextFile Names: »doother.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/X/Xgo/doother.c«
/* * $Header: doother.c,v 1.4 88/02/19 13:48:33 hale Exp $ */ /* Copyright 1987 Greg Hale Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ #include "go.h" DoOther() { extern int beepflg,lastx,lasty; int x,y,cur; RECV(buf); if (!strcmp(buf,MSCORE)) { doscore(); } else if (!strcmp(buf,MACCEPT)) { Score(); } else if (!strcmp(buf,MEXIT)) { addmes("- bye bye!"); SetStat(EXIT); } else if (!strcmp(buf,MDECLINE)) { addmes("- Other player has declined."); addmes("- Please resume play."); disable = 0; dodecline(); } else if (!strcmp(buf,MQUIT)) { DoQuit(); } else if (!strcmp(buf,MCANCEL)) { docancel(); } else if (!strcmp(buf,MPLAY)) { doplay(); } else if (!strcmp(buf,MMOVE)) { if (beepflg) Beep(); savelast(); GetCoord(&x,&y); readint(&cur); lastx=x; lasty=y; setboard(x,y,cur+1); Kill(x,y,cur+1); Plt(&board,x,y); REFRESH(); blink(x,y,cur+1); NextPlr(); saveboard0(); } else if (!strcmp(buf,MLOAD)) { readint(&hama[0]); readint(&hama[1]); readint(&curplr); readint(&dimensions); MAXX = MAXY = dimensions; doclearboard(); } else if (!strcmp(buf,MDELETE)) { GetCoord(&x,&y); deletes(x,y); } else if (!strcmp(buf,MCLEAR)) { doclear(); } else if (!strcmp(buf,MPASS)) { addmes("- Other player passed."); NextPlr(); } else if (!strcmp(buf,MMESSAGE)) { RECV(buf); if (beepflg) Beep(); addtalk(buf); } else if (!strcmp(buf,MHANDICAP)) { GetCoord(&x,&y); readint(&cur); if ( cur != b(x,y) ) { b(x,y)=cur; Plt(&board,x,y); } } else if (!strcmp(buf,MSWITCH)) { doswitch(); } else if (!strcmp(buf,MRESIGN)) { doresign(false); } } doresign(isme) int isme; { iwon = !isme; savestr(); if (iwon) { addmes("--------------------------"); addmes("The other player resigned."); addmes("--------------------------"); GetAKey(); printf("\nYou won by resignation.\n"); } else { addmes("-------------"); addmes("You resigned."); addmes("-------------"); GetAKey(); printf("\nYou lost by resignation.\n"); } Exit(); } setcurplr() { int x,y; for (x=0; x<MAXX; x++) for (y=0; y<MAXY; y++) if (b(x,y)) { curplr = 1; return(0); } } /* print out the messages to start scoring */ scoremes() { addmes(""); addmes("- Please score now."); addmes(" - Cancel returns to play."); addmes(" - Select dead groups."); addmes(" - Quit determines winner."); } dosave() { savegame(); fprintf(stderr,"\n\nGame saved.\n"); SEND(MEXIT); Exit(); } doplay() { extern int loadflg; addmes("- Please begin play."); ClrStat(HANDICAP); SetStat(PLAY); if (!loadflg) { hama[0]=hama[1]=0; setcurplr(); } } doscorehit(x,y) int x,y; { if (b(x,y)) { deletes(x,y); SEND(MDELETE); SendCoord(x,y); } else Beep(); } doswitch() { player = !player; printscore(); initmesg(); } dodecline() { restboard(); ClrStat(SCORE); SetStat(PLAY); PrintBoard(&board); } docancel() { restboard(); ClrStat(SCORE); SetStat(PLAY); PrintBoard(&board); refresh(); addmes("- Scoring is cancelled."); addmes("- Resume play."); } doscore() { SetStat(SCORE); scoremes(); saveboard(); } dodemo(x,y,bu) int x,y,bu; { static curhand=0; switch (bu & 3) { WHEN 2: /* left */ DoHand(x,y,curhand=0); WHEN 1: /* middle */ if (!b(x,y)) { curhand = !curhand; DoHand(x,y,curhand); } else { DoHand(x,y,b(x,y)-1); } WHEN 0: /* right */ DoHand(x,y,curhand=1); OTHERWISE: ; } } doclear() { int x,y; for (y=0; y<dimensions; y++) for (x=0; x<dimensions; x++) if (b(x,y)) { b(x,y)=0; Plt(&board,x,y); } curplr = 0; } doclearboard() { CLEAR(); InitBoard(&board); PrintBoard(&board); } /* * $Log: doother.c,v $ * Revision 1.4 88/02/19 13:48:33 hale * Added io changes for loading games. * Load game is cleaned up. Variable board * sizes and formats available in save game * as well as printed comments. * * Revision 1.3 88/02/14 00:22:51 hale * Added load file option during game to restore game to starting * state. Also, clear board operation. Restoring game puts current * player in sync. With the demo mode, this is invaluable. * * Revision 1.2 88/02/13 12:47:04 hale * centralized all shared routines possible (eg, dosave, dohandicap, * doxxx.) Also added responses for load option. * */