/* Informs that a player has surrender */ TEG_STATUS clitok_surrender( char *str ) { int numjug; PCPLAYER pJ; numjug = atoi( str ); if( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS) { /* no lo tengo en la base */ textmsg( M_IMP,_("Player %d abandoned the game"), numjug ); return TEG_STATUS_SUCCESS; } textmsg( M_IMP,_("Player %s(%s) abandoned the game"), pJ->name, _(g_colores[pJ->color]) ); if( pJ->numjug == WHOAMI() ) { ESTADO_SET(PLAYER_STATUS_GAMEOVER); gui_sensi(); } out_countries(); gui_surrender(numjug); return TEG_STATUS_SUCCESS; }
TEG_STATUS fichasc_restore_from_error() { ESTADO_SET( PLAYER_STATUS_FICHASC ); fichas_reset(); aux_draw_all_countries(); gui_sensi(); return TEG_STATUS_SUCCESS; }
/* someone is placing the continents armies */ TEG_STATUS clitok_fichasc( char *str) { int numjug; int cant,tot_cant; unsigned long conts; PCPLAYER j; PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; p.igualador = &igualador; p.separador = &separador; p.data = str; if( strlen(str)==0 ) goto error; if( parser_call( &p ) && p.hay_otro ) { numjug = atoi( p.token ); } else goto error; if( parser_call( &p ) && p.hay_otro ) { conts = atoi( p.token ); } else goto error; if( parser_call( &p ) && !p.hay_otro ) { cant = atoi( p.token ); } else goto error; if( player_whois( numjug, &j) != TEG_STATUS_SUCCESS) goto error; attack_unshow(); g_game.whos_turn = numjug; gui_sensi(); tot_cant = cont_tot( conts ) + cant; out_countries(); if( numjug == g_game.numjug ) { ESTADO_SET(PLAYER_STATUS_FICHASC); fichas_init( tot_cant, conts ); gui_fichas(cant,conts); } else { textmsg(M_INF,_("Player %s(%s) is placing %d armies"), j->name, _(g_colores[j->color]), cant); } return TEG_STATUS_SUCCESS; error: textmsg(M_ERR,"Error in clitok_fichasc()"); return TEG_STATUS_ERROR; }
/* a player won the game */ TEG_STATUS clitok_winner( char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int numjug; int mission; PCPLAYER pJ; p.igualador = &igualador; p.separador = &separador; p.data = str; if( strlen(str)==0 ) goto error; if( parser_call( &p ) && p.hay_otro ) { numjug = atoi( p.token ); } else goto error; if( parser_call( &p ) && !p.hay_otro ) { mission = atoi( p.token ); } else goto error; if( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS) goto error; if( mission == -1 ) mission = 0; if( mission < 0 || mission >= missions_cant() ) goto error; textmsg( M_IMP,_("Player %s(%s) is the WINNER"), pJ->name, _(g_colores[pJ->color]) ); gui_winner( pJ->numjug, mission ); ESTADO_SET( PLAYER_STATUS_HABILITADO ); gui_sensi(); game_finalize(); return TEG_STATUS_SUCCESS; error: textmsg(M_ERR,"Error in clitok_winner()"); return TEG_STATUS_ERROR; }
/* says who starts the round and the round number */ TEG_STATUS clitok_new_round( char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int numjug, round_number; PCPLAYER pJ; p.igualador = &igualador; p.separador = &separador; p.data = str; if( strlen(str)==0 ) goto error; if( parser_call( &p ) && p.hay_otro ) { numjug = atoi( p.token ); } else goto error; if( parser_call( &p ) && !p.hay_otro ) { round_number = atoi( p.token ); } else goto error; if( round_number >=0 && numjug >= 0 ) { g_game.round_number = round_number; g_game.who_started_round = numjug; } else goto error; if( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS) { /* no lo tengo en la base */ textmsg( M_IMP,_("Player %d started round number: %d"), numjug, round_number ); } else { textmsg( M_IMP,_("Player %s(%s) started round number: %d"), pJ->name, _(g_colores[pJ->color]), round_number ); } gui_sensi(); return TEG_STATUS_SUCCESS; error: textmsg(M_ERR,"Error in clitok_new_round()"); return TEG_STATUS_ERROR; }