src/main.c

changeset 78
ceb9197b3c6d
parent 75
b0b8bf3c536e
equal deleted inserted replaced
77:808a7324b467 78:ceb9197b3c6d
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 * 27 *
28 */ 28 */
29 29
30 #include "terminal-chess.h" 30 #define PROGRAM_VERSION "0.9 beta"
31
31 #include "game.h" 32 #include "game.h"
32 #include "input.h" 33 #include "input.h"
34 #include "network.h"
33 #include "colors.h" 35 #include "colors.h"
34 #include <string.h> 36 #include <string.h>
35 #include <time.h> 37 #include <time.h>
36 #include <getopt.h> 38 #include <getopt.h>
37 #include <locale.h> 39 #include <locale.h>
158 settings.port = "27015"; 160 settings.port = "27015";
159 settings.unicode = !!setlocale(LC_CTYPE, "C.UTF-8"); 161 settings.unicode = !!setlocale(LC_CTYPE, "C.UTF-8");
160 return settings; 162 return settings;
161 } 163 }
162 164
163 void dump_gameinfo(GameInfo *gameinfo) {
164 int serverwhite = gameinfo->servercolor == WHITE;
165 attron(A_UNDERLINE);
166 printw("Game details\n");
167 attroff(A_UNDERLINE);
168 printw(" Server: %s\n Client: %s\n",
169 serverwhite?"White":"Black", serverwhite?"Black":"White"
170 );
171 if (gameinfo->timecontrol) {
172 if (gameinfo->time % 60) {
173 printw(" Time limit: %ds + %ds\n",
174 gameinfo->time, gameinfo->addtime);
175 } else {
176 printw(" Time limit: %dm + %ds\n",
177 gameinfo->time/60, gameinfo->addtime);
178 }
179 } else {
180 printw(" No time limit\n");
181 }
182 refresh();
183 }
184
185 void dump_moveinfo(GameState *gamestate) {
186 int i = 1;
187 for (MoveList *movelist = gamestate->movelist ;
188 movelist ; movelist = movelist->next) {
189 if (++i % 2 == 0) {
190 printw("%d. %s", i/2, movelist->move.string);
191 } else {
192 printw(" %s", movelist->move.string);
193 }
194 if (i % 20) {
195 addch(' ');
196 } else {
197 addch('\n');
198 }
199 }
200 refresh();
201 }
202
203 int main(int argc, char **argv) { 165 int main(int argc, char **argv) {
204 srand(time(NULL)); 166 srand(time(NULL));
205 167
206 Settings settings = default_settings(); 168 Settings settings = default_settings();
207 if (get_settings(argc, argv, &settings)) { 169 if (get_settings(argc, argv, &settings)) {

mercurial