Example #1
0
/* the mouse is over a country */
TEG_STATUS attack_enter( PCOUNTRY p )
{
	if( attack_check() != TEG_STATUS_SUCCESS ) {
		return TEG_STATUS_UNEXPECTED;
	}

	if( country_origen == -1 ) {
		if(p->numjug == WHOAMI()) {
			if( p->ejercitos >1 ) {
				if( !(p->selected & COUNTRY_SELECT_ATTACK_ENTER)) {
					p->selected |= COUNTRY_SELECT_ATTACK_ENTER;
					gui_country_select(p->id);
				}
			}
		}
	} else if( country_destino == -1 ) {
		if(p->numjug != WHOAMI() ) {
			if( countries_eslimitrofe(country_origen, p->id) ) {
				if( !(p->selected & COUNTRY_SELECT_ATTACK_ENTER)) {
					p->selected |= COUNTRY_SELECT_ATTACK_ENTER;
					gui_country_select(p->id);
				}
			}
		}
	}
	return TEG_STATUS_SUCCESS;
}
Example #2
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;
}
Example #3
0
/* reset the status of the attack */
void attack_reset()
{
	if( country_origen != -1 ) {
		g_countries[country_origen].selected &= ~COUNTRY_SELECT_ATTACK;
		gui_country_select(country_origen);
		country_origen = -1;
	}

	if( country_destino != -1 ) {
		g_countries[country_destino].selected &= ~COUNTRY_SELECT_ATTACK;
		gui_country_select(country_destino);
		country_destino = -1;
	}
}
Example #4
0
/* unshow the attack shown with attack_show() */
TEG_STATUS attack_unshow()
{

	if( show_src != -1 ) {
		g_countries[show_src].selected &= ~COUNTRY_SELECT_ATTACK_SRC;
		gui_country_select(show_src);
		show_src = -1;
	}

	if( show_dst != -1 ) {
		g_countries[show_dst].selected &= ~COUNTRY_SELECT_ATTACK_DST;
		gui_country_select(show_dst);
		show_dst = -1;
	}

	return TEG_STATUS_SUCCESS;
}
Example #5
0
/* shows attack an attack from srt to dst */
TEG_STATUS attack_show( int src, int dst )
{
	attack_unshow();

	if( src >= 0 && src < COUNTRIES_CANT ) {
		show_src = src;
		g_countries[src].selected |= COUNTRY_SELECT_ATTACK_SRC;
		gui_country_select(src);
	}

	if( dst >= 0 && dst < COUNTRIES_CANT ) {
		show_dst = dst;
		g_countries[dst].selected |= COUNTRY_SELECT_ATTACK_DST;
		gui_country_select(dst);
	}


	return TEG_STATUS_SUCCESS;
}
Example #6
0
TEG_STATUS attack_leave( PCOUNTRY p )
{
	if( attack_check() != TEG_STATUS_SUCCESS ) {
		return TEG_STATUS_UNEXPECTED;
	}
	if( p->selected & COUNTRY_SELECT_ATTACK_ENTER ) {
		p->selected &= ~COUNTRY_SELECT_ATTACK_ENTER;
		gui_country_select(p->id);
	}
	return TEG_STATUS_SUCCESS;
}
Example #7
0
File: fichas.c Project: NatTuck/teg
TEG_STATUS fichas_leave( PCOUNTRY p )
{
	if( fichas_check() != TEG_STATUS_SUCCESS ) {
		return TEG_STATUS_ERROR;
	}

	if( p->numjug == WHOAMI() ) {
		p->selected &= ~COUNTRY_SELECT_FICHAS_IN;
		p->selected &= ~COUNTRY_SELECT_FICHAS_OUT;
		gui_country_select( p->id );
	}
	return TEG_STATUS_SUCCESS;
}
Example #8
0
File: fichas.c Project: NatTuck/teg
TEG_STATUS fichas_enter( PCOUNTRY p )
{
	if( fichas_check() != TEG_STATUS_SUCCESS ) {
		return TEG_STATUS_ERROR;
	}

	if( p->numjug == WHOAMI() ) {
		if( fichas_tot >= wanted_tot )  {
			if(!( p->selected & COUNTRY_SELECT_FICHAS_OUT )) {
				p->selected &= ~COUNTRY_SELECT_FICHAS_IN;
				p->selected |= COUNTRY_SELECT_FICHAS_OUT;
				gui_country_select( p->id );
			}
		} else {
			if(!( p->selected & COUNTRY_SELECT_FICHAS_IN )) {
				p->selected &= ~COUNTRY_SELECT_FICHAS_OUT;
				p->selected |= COUNTRY_SELECT_FICHAS_IN;
				gui_country_select( p->id );
			}
		}
	}
	return TEG_STATUS_SUCCESS;
}