Ejemplo n.º 1
0
/* 半荘の初期化 */
void gameinit(GameTable* gameStat, GameTypeID gameType, const std::string& ServerAddress, const std::array<int, 4>& PositionArray, unsigned ClientNumber) {
    gameStat = initializeGameTable(gameType);
    gameStat->PlayerID = PositionArray[ClientNumber];
    haifu::haifubufinit();
    chat::initchat(ServerAddress.c_str(), ClientNumber);
    yaku::yakuCalculator::init(); // 役カタログの初期化
    aiscript::initscript(); // AIの初期化
    return;
}
Ejemplo n.º 2
0
int main(){
	setlocale(LC_ALL, "ptb");//Set pt-br locale
	initscr();//Initialize cursor mode
	start_color();//Initialize color mode
	getmaxyx(stdscr,row,col);//Get screen dimensions
	attron(A_BOLD);

	//Configure color pairs
	init_pair(1, COLOR_WHITE, COLOR_BLACK);//Our default
	init_pair(2, COLOR_BLUE, COLOR_BLACK);//For Player 1
	init_pair(3, COLOR_RED, COLOR_BLACK);//For Player 2
	//Set default color pair
	wbkgd(stdscr, COLOR_PAIR(1));
	//Refresh screen to apply
	refresh();

	//Splash screen
	splashScreen();

	//wclear(stdscr);

	//Ready!

	char playAgain = 's';//Answer to the play again question on the end
	//Restart the game while play again answer is positive
	while(playAgain == 's'){
		initializeGameTable();//Initialize game table
		showHeader();//Show header with only title
		requestPlayerNames();//Request players for typing their names
		showHeader();//Show header with the title and players names
		refreshGame();//Show the game table
		//Print a divisor line after a blank line
		printw("\n");
		for(short int i = 0; i < col; i++){
			printw("-");
		}

		/* Here is the game, we'll request a match and refresh the game table while the game is not won or tied (tied is defined by number of matches) */
		//Matches counter
		int matchesCounter = 1;
		//Disable cursor
		curs_set(0);
		//While the game is not won and matches counter is under/equal 9
		while(checkWin() == 0 && matchesCounter <= 9){
			//Request match
			requestMatch();
			//Refresh the game table
			refreshGame();
			//Increase matches counter
			matchesCounter++;
		}

		//Clear line 13
		move(13,0);
		clrtoeol();
		//Check who won, or if the game tied
		if(checkWin() == 1){
			//Player 1 won
			//Increase score
			player1Score++;
			//Show congratulations on player color
			attron(COLOR_PAIR(2));
			mvprintw(13, 0, "Parabéns %s, você ganhou!\n", player1);
			attron(COLOR_PAIR(1));
		}
		if(checkWin() == 2){
			if(!strcmp(player2, "")){
				//PC won
				//Increase score
				player2Score++;
				//Show congratulations on player color
				attron(COLOR_PAIR(3));
				mvprintw(13, 0, "O PC ganhou!\n", player2);
				attron(COLOR_PAIR(1));
			}else{
				//Player2 won
				//Increase score
				player2Score++;
				//Show congratulations on player color
				attron(COLOR_PAIR(3));
				mvprintw(13, 0, "Parabéns %s, você ganhou!\n", player2);
				attron(COLOR_PAIR(1));
			}
		}
		if(checkWin() == 0){
			//Game tied
			mvprintw(13, 0, "Deu velha! O jogo terminou em empate.\n");
		}

		//Refresh scores
		refreshScores();

		//Reset play again var
		playAgain = ' ';
		//Enable cursor
		curs_set(1);
		//Validate play again answer
		while(!(playAgain == 's' | playAgain == 'n')){
			//Clear line 15, removing possible wrong answers from screen
			move(15, 0);
			clrtoeol();
			//Ask user
			printw("Desejam jogar novamente?[s/n] ");
			playAgain = getch();
		}
	}

	
	//Disable cursor
	curs_set(0);
	//Clear screen and show the header
	showHeader();
	//Print the thanks on center
	mvprintw(6, (col-strlen("Obrigado por jogar!"))/2,"Obrigado por jogar!\n");
	//Delay
	refresh(); delay(600);
	//Print the credits
	mvprintw(9, 0, "Desenvolvido por:\n");
	printw("Renan Galeno <*****@*****.**>\n");
	printw("Marcos Antuanny <*****@*****.**>\n");
	printw("Victor Patrick <*****@*****.**>\n");
	printw("\n");
	//Delay
	refresh(); delay(600);
	printw("Este trabalho está licenciado sob uma Licença Creative Commons Atribuição-CompartilhaIgual 4.0 Internacional.\nPara ver uma cópia desta licença, visite http://creativecommons.org/licenses/by-sa/4.0/.\n\n");
	//Delay
	refresh(); delay(1000);
	//Print the press anything to exit message
	printw("Pressione qualquer tecla para sair.");
	getch();


	//End curses mode
	endwin();

	//Return 0, as the program had no errors
	return(0);
}