Esempio n. 1
0
/* a players lost the connection of just quit the game */
TEG_STATUS clitok_exit( 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 exit the game"), numjug );
		return TEG_STATUS_SUCCESS;
	}

	textmsg( M_IMP,_("Player %s(%s) exit the game"),
				pJ->name,
				_(g_colores[pJ->color])
				);

	/* dont delete the player, I need the status */
	/* player_del( pJ ); */

	if( WHOAMI() == numjug ) {
		/* por alguna razon el server quiere que abandone el game */
		teg_disconnect();
	}

	return TEG_STATUS_SUCCESS;
}
Esempio n. 2
0
/* Servers's Protocol version. HIVER MUST be equal, otherwise wont work */
TEG_STATUS clitok_pversion( char *str)
{
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	int hi,lo;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( strlen(str)==0 )
		goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		hi = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		lo = atoi( p.token );
	} else goto error;

	if( hi != PROTOCOL_HIVER ) {
		textmsg(M_ERR,_("Aborting: Different protocols version. Server:%d Client:%d"),hi,PROTOCOL_HIVER);
		teg_disconnect();
		return TEG_STATUS_ERROR;
	}

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_pversion()");
	return TEG_STATUS_ERROR;
}
Esempio n. 3
0
/* 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;
}
Esempio n. 4
0
/* I reconnected to the server */
TEG_STATUS clitok_reconnect( char *str)
{
	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 ) {
		strncpy( g_game.myname, p.token, sizeof(g_game.myname)-1);
		g_game.myname[sizeof(g_game.myname)-1]=0;
	} else goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		g_game.numjug = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		g_game.mycolor  = atoi( p.token );	
	} else goto error;


	ESTADO_SET(PLAYER_STATUS_IDLE);

	textmsg( M_IMP,_("Successful reconnection. I'm player number:%d"),g_game.numjug );

	{
		/* insert myself in the list of players */
		CPLAYER j;
		PCPLAYER pJ;

		if( player_whois( g_game.numjug, &pJ ) != TEG_STATUS_SUCCESS ) {
			memset(&j,0,sizeof(j));
			j.color = g_game.mycolor;
			j.numjug = g_game.numjug;
			strncpy(j.name,g_game.myname,sizeof(j.name)-1);
			j.name[sizeof(j.name)-1]=0;
			player_ins(&j);
		}
	}

	out_status();
	out_countries();
	out_enum_cards();
	out_get_typeofgame();
	out_new_round();

	gui_reconnected();

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_reconnect()");
	return TEG_STATUS_ERROR;
}
Esempio n. 5
0
/* 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;
}
Esempio n. 6
0
File: fichas.c Progetto: NatTuck/teg
/**
 * @fn TEG_STATUS fichas_out()
 * Envia las fichas al server. Usada por FICHAS, FICHAS2 y FICHASC
 */
TEG_STATUS fichas_out()
{
	char buf[2000];
	char tmp[100];
	int *ptr;
	int i;
	int first_time;
	PLAYER_STATUS e;

	if( fichas_check() != TEG_STATUS_SUCCESS ) {
		textmsg( M_ERR,_("Error, its not the time to send armies"));
		return TEG_STATUS_ERROR;
	}

	if( fichas_finish( &ptr ) != TEG_STATUS_SUCCESS )  {
		fichas_reset();
		textmsg( M_ERR,_("Error, put the correct number of armies"));
		return TEG_STATUS_ERROR;
	}

	buf[0]=0;
	tmp[0]=0;

	first_time = 1;

	for(i=0;i<COUNTRIES_CANT;i++) {
		if( ptr[i]>0 ) {
			if( first_time )
				sprintf(tmp,"%d:%d",i,ptr[i]);
			else
				sprintf(tmp,",%d:%d",i,ptr[i]);
			strcat(buf,tmp);
			first_time = 0;
		}
	}

	e = ESTADO_GET();
	switch(e) {
	case PLAYER_STATUS_FICHAS:
		net_printf(g_game.fd,TOKEN_FICHAS"=%s\n",buf);
		ESTADO_SET( PLAYER_STATUS_POSTFICHAS);
		break;
	case PLAYER_STATUS_FICHAS2:
		net_printf(g_game.fd,TOKEN_FICHAS2"=%s\n",buf);
		ESTADO_SET( PLAYER_STATUS_POSTFICHAS2);
		break;
	case PLAYER_STATUS_FICHASC:
		net_printf(g_game.fd,TOKEN_FICHASC"=%s\n",buf);
		ESTADO_SET( PLAYER_STATUS_POSTFICHASC);
		break;
	default:
		textmsg( M_ERR,_("Error, its not the moment to send your armies"));
		return TEG_STATUS_ERROR;
	}
	return TEG_STATUS_SUCCESS;
}
Esempio n. 7
0
/* server version */
TEG_STATUS clitok_sversion( char *str)
{
	if( strlen(str)==0 )
		goto error;

	textmsg(M_ALL,"%s",str);
	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_pversion()");
	return TEG_STATUS_ERROR;
}
Esempio n. 8
0
/* a new player enters the game */
TEG_STATUS clitok_newplayer( char *str)
{
	char name[PLAYERNAME_MAX_LEN];
	int color,numjug;
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	CPLAYER j;
	PCPLAYER pJ;

	if( strlen(str)==0 )
		goto error;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( parser_call( &p ) && p.hay_otro ) {
		strncpy( name, p.token, sizeof(name)-1 );
		name[sizeof(name)-1]=0;
	} else goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		numjug = atoi( p.token );		
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		color = atoi( p.token );
	} else goto error;

	if( player_whois( numjug, &pJ ) != TEG_STATUS_SUCCESS ) {
		memset(&j,0,sizeof(j));
		j.color = color;
		j.numjug = numjug;
		strncpy(j.name,name,sizeof(j.name)-1);
		j.name[sizeof(j.name)-1]=0;
		player_ins(&j);
	} else
		pJ->color =  color;

	if( numjug == WHOAMI() ) {
		g_game.mycolor = color;
		ESTADO_SET( PLAYER_STATUS_HABILITADO );
		textmsg( M_IMP,_("My color is: %s"),_(g_colores[color]) );
	} else {
		textmsg(M_IMP,_("Player[%d] '%s' is connected with color %s"),numjug,name,_(g_colores[color]));
	}
	gui_habilitado( numjug );

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_newplayer()");
	return TEG_STATUS_ERROR;
}
Esempio n. 9
0
/* src is attacking dst */
TEG_STATUS clitok_attack( char *str)
{
	int src,dst;
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	PCPLAYER pJsrc, pJdst;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( strlen(str)==0 )
		goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		src = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		dst = atoi( p.token );
	} else goto error;

	/* countries are allowed to be -1 (unknown in fog of war) */
	if( src<-1 || src>=COUNTRIES_CANT || dst<-1 || dst>=COUNTRIES_CANT )
		goto error;

	pJsrc = NULL;
	if( src >=0 )
		player_whois( g_countries[src].numjug, &pJsrc );

	pJdst = NULL;
	if( dst >=0 )
		player_whois( g_countries[dst].numjug, &pJdst );

	if( src >= 0 && g_countries[src].numjug == WHOAMI() ) {
		attack_reset();
	} else {
		attack_show( src, dst );
	}

	if( pJsrc && pJdst )
		textmsg(M_INF,_("%s(%s) is attacking %s(%s)"), countries_get_name(src), _(g_colores[pJsrc->color])
				,countries_get_name(dst), _(g_colores[pJdst->color]) );
	else
		textmsg(M_INF,_("%s is attacking %s"),countries_get_name(src), countries_get_name(dst) );

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_attack()");
	return TEG_STATUS_ERROR;
}
Esempio n. 10
0
TEG_STATUS attack_click( PCOUNTRY p )
{
	if( attack_check() != TEG_STATUS_SUCCESS ) {
		textmsg(M_ERR,_("Error, It's not the time to attack"));
		return TEG_STATUS_UNEXPECTED;
	}

	if( country_origen == -1 ) {
		if(p->numjug == WHOAMI()) {
			if( p->ejercitos >1 ) {
				p->selected &= ~COUNTRY_SELECT_ATTACK_ENTER;
				p->selected |= COUNTRY_SELECT_ATTACK;
				gui_country_select(p->id);
				country_origen = p->id;
				textmsg(M_INF,_("Source country: '%s'. Now select the destination country"),countries_get_name(p->id));
			} else {
				textmsg(M_ERR,_("Error, '%s' must have at least 2 armies"),countries_get_name(p->id));
				return TEG_STATUS_UNEXPECTED;
			}
		} else {
			textmsg(M_ERR,_("Error, '%s' isn't one of your countries"),countries_get_name(p->id));
			return TEG_STATUS_UNEXPECTED;
		}
	} else if( country_destino == -1 ) {
		if( country_origen == p->id ) {
			textmsg(M_INF,_("Source country is the same as the destination. Resetting the attack..."));
			attack_reset();
			return TEG_STATUS_SUCCESS;
		}

		if(p->numjug != WHOAMI() ) {
			if( countries_eslimitrofe(country_origen, p->id) ) {
				p->selected &= ~COUNTRY_SELECT_ATTACK_ENTER;
				p->selected |= COUNTRY_SELECT_ATTACK;
				gui_country_select(p->id);
				country_destino = p->id;
				textmsg(M_INF,_("Destination country: '%s'. Attacking..."),countries_get_name(p->id));
				attack_out();
			} else {
				textmsg(M_ERR,_("Error, '%s' isn't frontier with '%s'"),countries_get_name(p->id),countries_get_name(country_origen));
				attack_reset();
				return TEG_STATUS_UNEXPECTED;
			}
		} else {
			textmsg(M_ERR,_("Error, you can't attack your own countries ('%s')"),countries_get_name(p->id));
			attack_reset();
			return TEG_STATUS_UNEXPECTED;
		}
	} else {
		attack_reset();
		textmsg(M_ERR,_("Error, unexpected error in attack_click(). Report this bug!"));
		return TEG_STATUS_UNEXPECTED;
	}

	return TEG_STATUS_SUCCESS;
}
Esempio n. 11
0
/* who am i, and available colors */
TEG_STATUS clitok_playerid( char *str)
{
	char c[TEG_MAX_PLAYERS];
	PARSER p;
	int i;
	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 ) {
		strncpy( g_game.myname, p.token, sizeof(g_game.myname)-1);
		g_game.myname[sizeof(g_game.myname)-1]=0;
	} else goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		g_game.numjug = atoi( p.token );
	} else goto error;

	for(i=0;i<TEG_MAX_PLAYERS-1;i++ ) {

		if( parser_call( &p ) && p.hay_otro ) {
			c[i] = atoi( p.token );	
		} else goto error;
	}

	if( parser_call( &p ) && !p.hay_otro ) {
		c[i] = atoi( p.token );	
	} else goto error;


	ESTADO_SET(PLAYER_STATUS_CONNECTED);

	out_status();
	if( g_game.observer )
		out_countries();

	gui_connected( c );

	textmsg( M_IMP,_("I'm player number:%d"),g_game.numjug );
	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_playerid()");
	return TEG_STATUS_ERROR;
}
Esempio n. 12
0
/* 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;
}
Esempio n. 13
0
/* I'm receiving the card I've requested after finishing my turn */
TEG_STATUS clitok_tarjeta(char *str)
{
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	int country,used;

	if( strlen(str)==0 )
		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( parser_call( &p ) && !p.hay_otro ) {
		used = atoi( p.token );		
	} else goto error;

	if( country < 0 || country >= COUNTRIES_CANT )
		goto error;

	ESTADO_SET(PLAYER_STATUS_TARJETA);

	InsertTailList( &g_game.tarjetas_list, (PLIST_ENTRY) &g_countries[ country ].tarjeta );
	g_game.tarjetas_cant++;

	if( used )
		tarjeta_usar( &g_countries[ country ].tarjeta );
	g_countries[ country ].tarjeta.numjug = WHOAMI();

	if( used ) {
		textmsg(M_IMP,_("You received card: '%s' and 2 armies where placed there"), countries_get_name( country ) );
	} else {
		textmsg(M_IMP,_("You received card: '%s'"), countries_get_name( country ) );
	}

	gui_tarjeta( country );
	return TEG_STATUS_SUCCESS;

error:
	textmsg(M_ERR,"Error in clitok_tarjeta()");
	return TEG_STATUS_ERROR;
}
Esempio n. 14
0
/* tells what is your secret mission */
TEG_STATUS clitok_mission(char *str)
{
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	int mission;

	if( strlen(str)==0 )
		goto error;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( parser_call( &p ) && !p.hay_otro ) {
		mission = atoi( p.token );
	} else goto error;

	if( mission < 0 || mission >= missions_cant() )
		goto error;

	g_game.secret_mission = mission;
	gui_mission();
	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_mission()");
	return TEG_STATUS_ERROR;
}
Esempio n. 15
0
/* you can move some armies to the conquered country */
TEG_STATUS clitok_tropas( char *str)
{
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };
	int src,dst,cant;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( strlen(str)==0 )
		goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		src = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		dst = atoi( p.token );
	} else goto error;

	if( parser_call( &p ) && !p.hay_otro ) {
		cant = atoi( p.token );
	} else goto error;

	ESTADO_SET(PLAYER_STATUS_TROPAS);

	gui_tropas( src,dst,cant);

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_tropas()");
	return TEG_STATUS_ERROR;
}
Esempio n. 16
0
/* a new message has arrived */
TEG_STATUS clitok_message( char *str)
{
	char name[PLAYERNAME_MAX_LEN];
	int numjug;
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ ',', ',', ',' };

	if( strlen(str) == 0 )
		goto error;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	if( parser_call( &p ) && p.hay_otro ) {
		strncpy( name, p.token, sizeof(name)-1);
		name[sizeof(name)-1]=0;
	} else goto error;

	if( parser_call( &p ) && p.hay_otro ) {
		numjug = atoi( p.token );		
	} else goto error;

	/* I dont care if there is one more or not */

	if( g_game.msg_show & M_MSG ) {
		gui_textplayermsg(name,numjug,p.data);
	}
	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_message()");
	return TEG_STATUS_ERROR;
}
Esempio n. 17
0
/* the game have just started */
TEG_STATUS clitok_start(char *str)
{
	CPLAYER j;
	PARSER p;
	DELIM igualador={ ':', ':', ':' };
	DELIM separador={ '/', '/', '/' };
	int i;

	if( strlen(str)==0 )
		goto error;

	p.igualador = &igualador;
	p.separador = &separador;
	p.data = str;

	player_flush();
	do {
		if( (i=parser_call( &p )) ) {
			if( aux_status( &j, p.token ) != TEG_STATUS_SUCCESS )
				goto error;

			player_ins( &j );
		}
	} while( i && p.hay_otro);

	ESTADO_SET(PLAYER_STATUS_START);

	out_countries();
	gui_start();
	return TEG_STATUS_SUCCESS;

error:
	textmsg(M_ERR,"Error in clitok_start()");
	return TEG_STATUS_ERROR;
}
Esempio n. 18
0
/* all the countries that a players has */
TEG_STATUS clitok_countries( char *str)
{
	int numjug;
	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;

	/* XXX: numjug == -1 in fog of war. Need to check if in FOW */
	if( numjug == -1 || player_whois( numjug, &j) == TEG_STATUS_SUCCESS)
		return aux_countries( numjug, p.data );
error:
	textmsg(M_ERR,"Error in clitok_countries()");
	return TEG_STATUS_ERROR;
}
Esempio n. 19
0
/* it's someone turn */
TEG_STATUS clitok_turno( char *str)
{
	int numjug;
	PCPLAYER pJ;
	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( player_whois( numjug, &pJ) != TEG_STATUS_SUCCESS)
		goto error;

	g_game.whos_turn = numjug;

	attack_unshow();
	out_countries();

	if( numjug == g_game.numjug ) {
		ESTADO_SET(PLAYER_STATUS_ATAQUE);
		/* cosas a hacer cuando yo comienzo un nuevo turno */
		reagrupe_bigreset();
		attack_init();
		textmsg(M_INF,_("It's your turn to attack!!"));
	} else  {
		/* No es mi turno, entonces yo tengo que estar en idle */
		textmsg(M_IMP,_("Player %s(%s) has the turn to attack!"),
				pJ->name,
				_(g_colores[pJ->color]) );
		ESTADO_SET(PLAYER_STATUS_IDLE);
	}
	gui_turn( pJ );

	return TEG_STATUS_SUCCESS;
error:
	textmsg(M_ERR,"Error in clitok_turno()");
	return TEG_STATUS_ERROR;
}
Esempio n. 20
0
/* 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;
}
Esempio n. 21
0
/* Sends to server a request for a 'get card' */
TEG_STATUS out_tarjeta()
{
    if( ESTADO_MENOR(PLAYER_STATUS_ATAQUE) || ESTADO_MAYOR_IGUAL(PLAYER_STATUS_TARJETA) ) {
        textmsg( M_ERR,_("Error, it's not the moment to get a card"));
        return TEG_STATUS_ERROR;
    }

    net_printf(g_game.fd,TOKEN_TARJETA"\n");
    return TEG_STATUS_SUCCESS;
}
Esempio n. 22
0
/* ask server the countries' status */
TEG_STATUS out_countries()
{
    if( ESTADO_MENOR(PLAYER_STATUS_CONNECTED) ) {
        textmsg( M_ERR,_("Error, you must be connected"));
        return TEG_STATUS_NOTCONNECTED;
    }

    net_printf(g_game.fd,TOKEN_COUNTRIES"=-1\n");

    return TEG_STATUS_SUCCESS;
}
Esempio n. 23
0
TEG_STATUS out_new_round()
{
    if( ESTADO_MENOR(PLAYER_STATUS_CONNECTED) ) {
        textmsg( M_ERR,_("Error, you must be connected"));
        return TEG_STATUS_NOTCONNECTED;
    }

    net_printf(g_game.fd,TOKEN_NEW_ROUND"\n");

    return TEG_STATUS_SUCCESS;
}
Esempio n. 24
0
TEG_STATUS out_enum_cards()
{
    if( ESTADO_MENOR(PLAYER_STATUS_CONNECTED) ) {
        textmsg( M_ERR,_("Error, you must be connected"));
        return TEG_STATUS_NOTCONNECTED;
    }

    net_printf(g_game.fd,TOKEN_ENUM_CARDS"\n");

    return TEG_STATUS_SUCCESS;
}
Esempio n. 25
0
File: fichas.c Progetto: NatTuck/teg
/**
 * @fn TEG_STATUS sub_fichas( PCOUNTRY p )
 * llamada desde la 'gui' y recuerda los countries que se fueron agregando
 * @params p country que se esta agregando
 */
TEG_STATUS fichas_sub( PCOUNTRY p )
{
	if( fichas_check() != TEG_STATUS_SUCCESS ) {
		textmsg(M_ERR,_("Error, you cant sub armies now"));
		return TEG_STATUS_UNEXPECTED;
	}

	if(p->numjug == WHOAMI() ) {
		if( aFichas[p->id] ) {
			fichas_tot--;
			p->ejercitos--;
			aFichas[p->id]--;
			aConts[p->continente]--;
			fichas_enter( p );
			return TEG_STATUS_SUCCESS;
		} else return TEG_STATUS_UNEXPECTED;
	} else {
		textmsg(M_ERR,_("Error, '%s' isnt one of your countries"),countries_get_name(p->id));
		return TEG_STATUS_UNEXPECTED;
	}
}
Esempio n. 26
0
/* your last request has an error */
TEG_STATUS clitok_error( char *str)
{
	int i;
	if( strlen(str)==0 )
		goto error;


	for(i = 0; i < NRERRCLITOKENS; i++) {
		if(strcasecmp( str, err_tokens[i].label )==0 ){
			if (err_tokens[i].func)
				return( (err_tokens[i].func)());
			textmsg(M_ERR,_("The server report an error in '%s'"),str);
			return TEG_STATUS_TOKENNULL;
		}
	}
	return TEG_STATUS_SUCCESS;

error:
	textmsg(M_ERR,"Error in clitok_error()");
	return TEG_STATUS_ERROR;
}
Esempio n. 27
0
File: ejer2.c Progetto: NatTuck/teg
/**
 * @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;
	}
}
Esempio n. 28
0
/* request the server my secret mission */
TEG_STATUS out_missions()
{
    PLAYER_STATUS e;

    e = ESTADO_GET();
    if( e >= PLAYER_STATUS_START ) {
        net_printf(g_game.fd,TOKEN_MISSION"\n");
    } else {
        textmsg( M_ERR,_("Error, the game is not started"));
        return TEG_STATUS_ERROR;
    }
    return TEG_STATUS_SUCCESS;
}
Esempio n. 29
0
/* request the type of game */
TEG_STATUS out_get_typeofgame()
{
    PLAYER_STATUS e;

    e = ESTADO_GET();
    if( e >= PLAYER_STATUS_START ) {
        net_printf(g_game.fd,TOKEN_MODALIDAD"\n");
    } else {
        textmsg( M_ERR,_("Error, the game is not started"));
        return TEG_STATUS_ERROR;
    }
    return TEG_STATUS_SUCCESS;
}
Esempio n. 30
0
/*
 * 	code that interprets which fn to call
 */
static TEG_STATUS client_lookup( int fd, PARSER *p )
{
	int i;

	for(i = 0; i < NRCLITOKENS; i++) {
		if(strcasecmp( p->token, tokens[i].label )==0 ){
			if (tokens[i].func)
				return( (tokens[i].func)(p->value));
			return TEG_STATUS_TOKENNULL;
		}
	}
	textmsg( M_ERR, _("Token '%s' not found"),p->token);
	return TEG_STATUS_TOKENNOTFOUND;
}