/* Place 2 armies in the card's country. The player must own the country */ STATIC TEG_STATUS token_ejer2( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int country; PSPLAYER j; PLAY_DEBUG("token_ejer2()\n"); if( strlen(str)==0) goto error; if( player_whoisfd( fd, &j ) != TEG_STATUS_SUCCESS ) goto error; if( j->estado != PLAYER_STATUS_TARJETA ) goto error; p.igualador = &igualador; p.separador = &separador; p.data = str; if( parser_call( &p ) && !p.hay_otro ) { country = atoi( p.token ); } else goto error; if( country >= COUNTRIES_CANT || country < 0 ) { goto error; } if( tarjeta_es_usada( &g_countries[ country ].tarjeta )) goto error; if( g_countries[ country ].numjug == j->numjug && g_countries[ country ].tarjeta.numjug == j->numjug ) { g_countries[ country ].ejercitos += 2; j->tot_armies += 2; tarjeta_usar( &g_countries[ country ].tarjeta ); if( ! g_game.fog_of_war ) netall_printf("%s=%d,%d,%d\n", TOKEN_COUNTRY ,country ,g_countries[ country ].numjug ,g_countries[ country ].ejercitos); else fow_netall_printf( country, "%s=%d,%d,%d\n", TOKEN_COUNTRY ,country ,g_countries[ country ].numjug ,g_countries[ country ].ejercitos); } return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_EJER2"\n"); return TEG_STATUS_PARSEERROR; }
/** * @fn TEG_STATUS ejer2_out( int country ) * Pone 2 ejercitos por la tarjeta que saco */ TEG_STATUS ejer2_out( int country ) { if( g_countries[ country ].numjug == WHOAMI() ) { if( ESTADO_ES( PLAYER_STATUS_TARJETA ) ) { if( !tarjeta_es_usada( &g_countries[ country ].tarjeta )) { tarjeta_usar( &g_countries[ country ].tarjeta ); last_country = country; net_printf(g_game.fd,TOKEN_EJER2"=%d\n",country); return TEG_STATUS_SUCCESS; } else { textmsg( M_ERR,_("Error, the 2 armies where placed before")); return TEG_STATUS_ERROR; } } else { textmsg( M_ERR,_("Error, it's not the time to put 2 armies.")); return TEG_STATUS_ERROR; } } else { textmsg(M_ERR,_("Error, '%s' isnt one of your countries"),g_countries[country].name); return TEG_STATUS_ERROR; } }