Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ll-xn!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games-request From: games-request@tekred.TEK.COM Newsgroups: comp.sources.games Subject: v03i088: cchess - corrispondence chess, Part03/05 Message-ID: <2234@tekred.TEK.COM> Date: 1 Mar 88 23:26:56 GMT Sender: billr@tekred.TEK.COM Lines: 2013 Approved: billr@tekred.TEK.COM Submitted by: Jan Wolter Comp.sources.games: Volume 3, Issue 88 Archive-name: cchess/Part03 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh cchess.h <<'END_OF_cchess.h' X/* C O R R E S P O N D E N C E C H E S S Version 1.00 X * X * Play chess with another player, with notification of moves by mail. X * X * (C) Apr 1986 - Jan Dithmar Wolter. X * X * This source code may be freely distributed and modified, but not X * sold or used for profit without the permission of the author. X */ X X#include X#include X#include X#include X#include X#include X#include X X#include "def.h" X X/* External declarations of all globals */ Xextern boolean newgame,moveok,kibitz,solo,hidden,eachgame; Xextern boolean commodore,incheck,inmate,repeated,stripped,interupt,bigboard; Xextern boolean istame,must_take; Xextern int myillmoves, illmoves, tamemoves, mvssize; Xextern short cx,cy; Xextern short msgarea; Xextern short wfr,wfc,wtr,wtc,bfr,bfc,btr,btc; Xextern schar promote; Xextern schar ib[R_SIZE][C_SIZE],b[R_SIZE][C_SIZE],bc[R_SIZE][C_SIZE]; Xextern schar order,mycolor,toplay,taken; Xextern boolean wcck, wccq, bcck, bccq; Xextern int movecnt,playcnt; Xextern int hisuid,myuid; Xextern int consmade,consmoves; Xextern char status; Xextern char *version, *copyright,file_version[]; Xextern char *resltname[], *captname[HI_CAPTURE+1],*typename[],*langname[]; Xextern char **piecename,*chessname[HI_NAMES+1][PIECES+1],pc[2*PIECES+2]; Xextern char hisid[20],myid[20]; Xextern char cbuffer[CB_LEN+1],*mbuffer,*sbuffer; Xextern char mb1[MB_LEN+1],mb2[MB_LEN+1]; Xextern char blankstr[BLANK_LEN+1]; Xextern char option[OPTIONS],maxopt[OPTIONS]; Xextern char defopt[HI_GAME+1][OPTIONS]; Xextern int errcode; Xextern char bs_char; Xextern char fname[50]; Xextern long lastday; Xextern FILE *rfp; Xextern FILE *wfp; Xextern jmp_buf jmpenv; Xextern boolean issmart,erases,cleardown,scrolled; Xextern int LINES, COLS; X X#ifndef LSIGNAL Xextern jmp_buf susp_env; Xextern boolean susp1_flg, susp2_flg; X#endif LSIGNAL X X#ifdef DEBUG Xextern boolean debugon; X#endif X X/* Declarations of routines */ Xextern struct passwd *getpwnam(), *getpwuid(), *getpwent(); Xextern char enter(), enterd(), xenter(), xenterd(), *getenv(), *fgetl(); Xextern boolean check(), legal(), cart(), diag(), canmove(), place(),forces(); Xextern boolean isrepeat(), compare(),checkbd(), enterdyn(), enteryn(); Xextern boolean editbd(); Xextern char *index(), *strcpy(), *strcat(), *malloc(), *gpwuid(); Xextern char *pcol(), *pcapcol(), *pman(), *pcolman(), *yorn(), *cday(); Xextern char *sprintf(), *strncpy(); Xextern schar compkib(); Xextern long day(), atol(); Xextern int mprintf(); Xextern FILE *upopen(); Xextern int fseek(); X Xextern struct direct *readdir(); END_OF_cchess.h if test 2560 -ne `wc -c init.c <<'END_OF_init.c' X/* CCHESS CHALLENGE ROUTINES version 1.00 X * X * (C) Copyright - Jan D. Wolter - Apr 1986 X * X * Mostly routines to make and accept game challenges. X */ X X#include "cchess.h" X X#ifndef NOTERMCAP Xextern char *DL; X#endif NOTERMCAP X X/* CHALLENGE() X * X * Make a challenge. User is prompted for options. Challenge line is X * written in the game file. The flag counter is set if this is a X * counter challenge to a previous challenge. X */ X Xdochallenge(counter) Xboolean counter; X{ Xregister int i; Xchar ch,var; X X /* Choose colors */ X X wprint("\nWhat color would you like "); X if (counter) X { X wprintf("[%s]? ",pcol(mycolor)); X ch = enterd("WB",(mycolor==WHITE)?'W':'B'); X } X else X { X wprint("(B/W)? "); X ch = enter("WB"); X } X if (ch == 'W') X { X wprint("hite"); X mycolor = WHITE; X } X else X { X wprint("lack"); X mycolor = BLACK; X } X if (order == (schar) -1) X Firstwhite = (ch == 'B'); X else X Firstwhite = (ch == 'W'); X X wprint("\nDo you wish to play a variant game "); X if (counter) X { X ch = (Game_type != TY_CHESS); X wprintf("[%s]? ",yorn(ch)); X ch = enterdyn(ch); X } X else X { X wprint("(Y/N)? "); X ch = enteryn(); X } X X if (ch) X { X wprint("\nVariants games are:\n"); X wprint(" (A) Chess - Standard modern game\n"); X wprint(" (B) Kriegspiel - Other player's moves hidden\n"); X wprint(" (C) Shatranj - 6th century Persian game\n"); X wprint(" (D) Courier - 13th century 12x8 board game\n"); X wprint(" (E) Halfboard - Standard game on 4x8 board\n"); X wprint(" (F) Karma Chess - Capturing men promoted to victim's rank\n"); X wprint(" (G) Rifle Chess - Capture without moving\n"); X wprint(" (H) Kamikazi Chess - Capturing men lost\n"); X wprint(" (I) Double Chess - Make two moves per turn\n"); X wprint(" (J) Steamroller - White pawns and king move twice\n"); X wprint(" (K) Progressive - One more move every turn\n"); X wprint(" (L) Maharajah - White has only maharajah piece\n"); X wprint(" (M) Losing Chess - First one to lose all his men wins.\n"); X wprint(" (N) Conversion Chess - Combination of Karma and Rifle Chess\n"); X /* If you add to the menu above, add letter to string below */ X if (counter && Game_type == TY_MIXED) X wprint(" (Z) Mixed Game - Same custom game you were challenged to\n"); X wprintf("\nWhich would you like to play [%s]? ", X typename[counter ? Game_type : TY_CHESS]); X ch = xenterd("ZABCDEFGHIJKLMN" + (!counter || Game_type != TY_MIXED), X counter?((Game_type == TY_MIXED)? 'Z': Game_type+'A'-1):'A'); X X var = (ch == 'Z') ? TY_MIXED : ch - 'A' + 1; X wprintf("%c - %s",ch,typename[var]); X X if (var != TY_MIXED) X { X /* Set up default options */ X for (i=1;i