예제 #1
0
파일: main.c 프로젝트: NatTuck/teg
/* Creates a new game */
void game_new()
{
	static int first_time = 1;

	countries_init();
	mission_init();
	pactos_flush();

	player_map( player_initplayer );
	player_all_set_status( PLAYER_STATUS_HABILITADO );
	g_game.playing = 0;
	

	g_game.turno = NULL;
	g_game.empieza_turno = NULL;
	g_game.estado = JUEGO_ESTADO_ESPERANDO;
	g_game.round_number = 1;

	if( first_time ) {
		first_time = 0;
		g_game.gamenumber = 0;
		g_game.seed = get_int_from_dev_random();
	} else {
		g_game.gamenumber++;
		g_game.seed = rand();
		srand( g_game.seed );
	}

	player_kick_unparent_robots();
}
예제 #2
0
파일: play.c 프로젝트: JeroenDeDauw/teg
/* To start the game */
TEG_STATUS token_start( int fd )
{
	char strout[PROT_MAX_LEN + PLAYERNAME_MAX_LEN  * TEG_MAX_PLAYERS + 200];
	PSPLAYER pJ;
	PLAY_DEBUG("token_start()\n");

	if( JUEGO_EMPEZADO || g_game.players < 2 )
		goto error;

	if( g_server.with_console && fd != CONSOLE_FD) {
		if( !SPLAYER_HABILITADO_P(fd,&pJ) || !pJ->is_player )
			goto error;
	}

	JUEGO_EN_EMPEZAR;

	g_game.playing = g_game.players;

	con_text_out(M_INF,_("Starting game number: %d with seed: %u\n"),g_game.gamenumber,g_game.seed);

	player_all_set_status ( PLAYER_STATUS_START );
	countries_repartir();

	if(turno_init() != TEG_STATUS_SUCCESS ) {
		con_text_out(M_ERR,_("Error, can't initialize a new turn\n"));
		goto error;
	}

	JUEGO_EN_FICHAS;

	g_game.turno->estado = PLAYER_STATUS_FICHAS;

	aux_token_stasta(strout, sizeof(strout) -1 );

	netall_printf( "%s=%s;%s=%d,%d;%s=%d,%d,%d,%d;%s=%d,%d\n"
			,TOKEN_START
			,strout			/* available players */
			,TOKEN_NEW_ROUND
			,g_game.turno->numjug 	/* who starts the new turn */
			,g_game.round_number	/* the round number */
			,TOKEN_MODALIDAD
			,g_game.mission	/* play with missions ? */
			,g_game.cmission	/* play with common mission */
			,g_game.fog_of_war	/* play with fog of war */
			,g_game.reglas		/* which rules ? */
			,TOKEN_FICHAS
			,g_game.turno->numjug,	/* who starts ? */
			g_game.fichas );	/* how many armies to place */
	return TEG_STATUS_SUCCESS;
error:
	net_print(fd,TOKEN_ERROR"="TOKEN_START"\n");
	return TEG_STATUS_PARSEERROR;
}