39 char *valid; |
39 char *valid; |
40 unsigned long int time, port; |
40 unsigned long int time, port; |
41 uint8_t timeunit = 60; |
41 uint8_t timeunit = 60; |
42 size_t len; |
42 size_t len; |
43 |
43 |
44 for (int opt ; (opt = getopt(argc, argv, "a:bhp:rst:")) != -1 ;) { |
44 for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rst:")) != -1 ;) { |
45 switch (opt) { |
45 switch (opt) { |
|
46 case 'c': |
|
47 settings->continuepgn = optarg; |
|
48 break; |
46 case 'b': |
49 case 'b': |
47 settings->gameinfo.servercolor = BLACK; |
50 settings->gameinfo.servercolor = BLACK; |
48 break; |
51 break; |
49 case 'r': |
52 case 'r': |
50 settings->gameinfo.servercolor = rand() & 1 ? WHITE : BLACK; |
53 settings->gameinfo.servercolor = rand() & 1 ? WHITE : BLACK; |
106 Settings default_settings() { |
109 Settings default_settings() { |
107 Settings settings; |
110 Settings settings; |
108 memset(&settings, 0, sizeof(Settings)); |
111 memset(&settings, 0, sizeof(Settings)); |
109 settings.gameinfo.servercolor = WHITE; |
112 settings.gameinfo.servercolor = WHITE; |
110 settings.port = "27015"; |
113 settings.port = "27015"; |
|
114 settings.continuepgn = NULL; |
111 return settings; |
115 return settings; |
112 } |
116 } |
113 |
117 |
114 void dump_gameinfo(GameInfo *gameinfo) { |
118 void dump_gameinfo(GameInfo *gameinfo) { |
115 int serverwhite = gameinfo->servercolor == WHITE; |
119 int serverwhite = gameinfo->servercolor == WHITE; |
145 return 1; |
149 return 1; |
146 } |
150 } |
147 |
151 |
148 if (settings.printhelp) { |
152 if (settings.printhelp) { |
149 printf( |
153 printf( |
150 "Usage: terminal-chess [OPTION]... [HOST]\n" |
154 "Usage: terminal-chess [OPTION]... [HOST]\n" |
151 "Starts/joins a network chess game\n" |
155 "Starts/joins a network chess game\n" |
152 "\nGeneral options\n" |
156 "\nGeneral options\n" |
153 " -h This help page\n" |
157 " -h This help page\n" |
154 " -p TCP port to use (default: 27015)\n" |
158 " -p TCP port to use (default: 27015)\n" |
155 "\nServer options\n" |
159 "\nServer options\n" |
156 " -a <time> Specifies the time to add after each move\n" |
160 " -a <time> Specifies the time to add after each move\n" |
157 " -b Server plays black pieces (default: white)\n" |
161 " -b Server plays black pieces (default: white)\n" |
158 " -r Distribute color randomly\n" |
162 // TODO: implement and activate feature |
159 " -s Single machine mode\n" |
163 //" -c <PGN file> Continue the specified game\n" |
160 " -t <time> Specifies time limit (default: no limit)\n" |
164 " -r Distribute color randomly\n" |
161 "\nNotes\n" |
165 " -s Single machine mode\n" |
162 "The time unit for -a is seconds and for -t minutes by default. To " |
166 // TODO: implement and activate feature |
163 "specify\nseconds for the -t option, use the s suffix.\n" |
167 //" -S <PGN file> Compute and print statistics for the specified game\n" |
164 "Example: -t 150s\n" |
168 " -t <time> Specifies time limit (default: no limit)\n" |
|
169 "\nNotes\n" |
|
170 "The time unit for -a is seconds and for -t minutes by default. To " |
|
171 "specify\nseconds for the -t option, use the s suffix.\n" |
|
172 "Example: -t 150s\n\n" |
|
173 "Use '-' for PGN files to read PGN data from standard input\n" |
165 ); |
174 ); |
166 return EXIT_SUCCESS; |
175 return EXIT_SUCCESS; |
167 } |
176 } |
168 initscr(); |
177 initscr(); |
169 halfdelay(1); |
178 halfdelay(1); |