1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include <iostream>
#include "Player.h"
#include "TicTacToe.h"
void Player::PlayersTurn()
{
/* i want to be able to call TicTacToe.h's function member to set a letter in the board array and to show the current pieces on the board */
}
void startTTT(Player*,Player*,TicTacToe*,int *);
int winCheckTTT(TicTacToe*);
int main()
{
char again;
char letterChoice;
int *winner = new int;
*winner = 0;
Player *player1 = new Player;
Player *player2 = new Player;
TicTacToe *TTTgame = new TicTacToe;
do
{
std::cout<<"\t\tHiimnew Games"<<std::endl;
std::cout<<"\tDefault will be TicTacToe for now."<<std::endl;
do
{
std::cout<<"Player 1 Please choose your letter (X/O) ";
std::cin>>letterChoice;
if (letterChoice == 'x' || letterChoice == 'X')
{
letterChoice = 'X';
player1->assignLetter(letterChoice);
player2->assignLetter('O');
}
else if ((letterChoice == 'o') ^ (letterChoice == 'O'))
{
letterChoice = 'O';
player1->assignLetter(letterChoice);
player2->assignLetter('X');
}
else
std::cout<<"\nBad letter choice, please try again!\n\n";
} while ((letterChoice != 'X') && (letterChoice != 'O'));
std::cout<<"Player 1 has been assigned "<<player1->getLetter()<<" and Player 2 has been assigned "<<player2->getLetter()<<"!"<<std::endl;
startTTT(player1,player2,TTTgame,winner);
if (*winner == 45) //player 1 wins
{
std::cout<<"Player 1 Wins!"<<std::endl;
player1->addPoint();
}
else if (*winner == 67) //player 2 wins
{
std::cout<<"Player 2 Wins!"<<std::endl;
player2->addPoint();
}
else if (*winner == 90) //tie
{
std::cout<<"Tie!"<<std::endl;
}
else
{
std::cout<<"Error!"<<std::endl;
}
std::cout<<"Play again? (y/n) ";
std::cin>>again;
} while ((again == 'y') ^ (again == 'Y'));
return 0;
}
void startTTT(Player *player1,Player *player2, TicTacToe *TTTgame, int *winner)
{
//Determines who goes first based on who has more points default is player 1 goes first
if (player1->getScore() == 0 && player2->getScore() == 0)
{
//playersturn member function calls for player 1 and 2 here
}
else if (player1->getScore() < player2->getScore())
{
//playersturn member function calls for player 1 and 2 here
}
else if (player1->getScore() > player2->getScore())
{
//playersturn member function calls for player 1 and 2 here
}
else
{
std::cout<<"ERROR @ line 57"<<std::endl;
}
do
{
//playersturn member function calls for player 1 here
*winner = winCheckTTT(TTTgame);
//playersturn member function calls for player 2 here
*winner = winCheckTTT(TTTgame);
} while (*winner == 0);
}
int winCheckTTT(TicTacToe *TTTgame)
{
return 0;
//under construction, uses and algorithm to check to see if anyone wins or if its a tie,
//then returns 1 of 4 values Player1 won, player 2 won, tie, & default to continue the game
}
/*compare 3 letters 123
456
789
123 456 789 159 357 147 258 369*/
|