by morags on Thu Oct 15, 2009 11:40 pm
Second half of the script for World of Warcraft Class Duels!
- Code: Select all
while ( playerOneTurn == false )
{
if ( p1.mana <= 0 )
{
p1.mana = 0;
}
if ( p1.health > 0 && p2.health <= 0 )
{
playerOneWinGame = true;
playerTwoWinGame = false;
break;
}
if ( p1.health <= 0 && p2.health > 0 )
{
playerOneWinGame = false;
playerTwoWinGame = true;
break;
}
playerTwoTurnIntro();
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana;
cout << "\n\n\n\tWhat would you like to do?"
<< "\n\n\t[1] Attack - Deals " << attackDamage << " damage."
<< "\n\n\t[2] Moonfire - Deals " << moonfireDamage << " damage, Costs " << moonfireMana << " mana."
<< "\n\n\t[3] Wrath - Deals " << wrathDamage << " damage, Costs " << wrathMana << " mana."
<< "\n\n\t[4] Starfire - Deals " << starfireDamage << " damage, Costs " << starfireMana << " mana."
<< "\n\n\t[5] Healing Touch - Heals " << healingtouchDamage << " health, Costs " << healingtouchMana << " mana."
<< "\n\n\t[6] Cyclone - Skips P1's turn, heals for " << cycloneHeal << ", Costs " << cycloneMana << " mana."
<< "\n\n\tChoice: ";
if (!( cin >> playerChoice ))
{
error();
continue;
}
if ( playerChoice != 1 && playerChoice != 2 && playerChoice != 3 && playerChoice != 4 && playerChoice != 5 && playerChoice != 6 )
{
error();
continue;
}
if ( playerChoice == 1 && p2.mana >= attackMana )
{
if ( criticalHit() == true )
{
( p1.health -= ( attackDamage * 2 ));
( p2.mana -= attackMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Attack critically hits " << playerOne << " for " << ( attackDamage * 2 ) << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
else
{
( p1.health -= attackDamage );
( p2.mana -= attackMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Attack hits " << playerOne << " for " << attackDamage << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
}
if ( playerChoice == 2 && p2.mana >= moonfireMana )
{
if ( criticalHit() == true )
{
( p1.health -= ( moonfireDamage * 2 ));
( p2.mana -= moonfireMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Moonfire critically hits " << playerOne << " for " << ( moonfireDamage * 2 ) << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
else
{
( p1.health -= moonfireDamage );
( p2.mana -= moonfireMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Moonfire hits " << playerOne << " for " << moonfireDamage << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
}
if ( playerChoice == 3 && p2.mana >= wrathMana )
{
if ( criticalHit() == true )
{
( p1.health -= ( wrathDamage * 2 ));
( p2.mana -= wrathMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Wrath critically hits " << playerOne << " for " << ( wrathDamage * 2 ) << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
else
{
( p1.health -= wrathDamage );
( p2.mana -= wrathMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Wrath hits " << playerOne << " for " << wrathDamage << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
}
if ( playerChoice == 4 && p2.mana >= starfireMana )
{
if ( criticalHit() == true )
{
( p1.health -= ( starfireDamage * 2 ));
( p2.mana -= starfireMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Starfire critically hits " << playerOne << " for " << ( starfireDamage * 2 ) << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
else
{
( p1.health -= starfireDamage );
( p2.mana -= starfireMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Starfire hits " << playerOne << " for " << starfireDamage << " damage.";
Sleep(2000);
playerOneTurn = true;
break;
}
}
if ( playerChoice == 5 && p2.mana >= healingtouchMana && p2.health != p2.maxHealth && p2.health <= ( p2.maxHealth - healingtouchDamage ))
{
if ( criticalHit() == true )
{
( p2.health += ( healingtouchDamage * 2 ));
( p2.mana -= healingtouchMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Healing Touch critically heals for " << ( healingtouchDamage * 2 ) << ".";
Sleep(2000);
playerOneTurn = true;
break;
}
else
{
( p2.health += healingtouchDamage );
( p2.mana -= healingtouchMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerOne << "'s Healing Touch heals for " << healingtouchDamage << ".";
Sleep(2000);
playerOneTurn = true;
break;
}
}
if ( playerChoice == 5 && p2.mana >= healingtouchMana && p2.health == p1.maxHealth )
{
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\tYour health is already full.";
Sleep(2000);
continue;
}
if ( playerChoice == 5 && p2.mana >= healingtouchMana && p2.health > ( p2.maxHealth - healingtouchDamage ))
{
int totalHeal = ( p2.maxHealth - p2.health );
( p2.health += totalHeal );
( p2.mana -= healingtouchMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Healing Touch heals for " << totalHeal << ".";
Sleep(2000);
playerOneTurn = true;
break;
}
if ( playerChoice == 6 && p2.mana >= cycloneMana && p2.health != p2.maxHealth && p2.health <= ( p2.maxHealth - cycloneHeal ))
{
( p2.health += cycloneHeal );
( p2.mana -= cycloneMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Cyclone heals for " << cycloneHeal << ".";
Sleep(2000);
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerOne << "'s Turn is missed due to the cyclone.";
Sleep(2000);
continue;
}
if ( playerChoice == 6 && p2.mana >= cycloneMana && p2.health != p2.maxHealth && p2.health > ( p2.maxHealth - cycloneHeal ))
{
int totalHealCyclone = ( p2.maxHealth - p2.health );
( p2.health += totalHealCyclone );
( p2.mana -= cycloneMana );
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerTwo << "'s Cyclone heals for " << totalHealCyclone << ".";
Sleep(2000);
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\t" << playerOne << "'s Turn is missed due to the cyclone.";
Sleep(2000);
continue;
}
if ( playerChoice == 6 && p2.mana >= cycloneMana && p2.health == p2.maxHealth )
{
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\tYour health is already full.";
Sleep(2000);
continue;
}
if ( p2.mana < attackMana || p2.mana < moonfireMana || p2.mana < wrathMana || p2.mana < starfireMana || p2.mana < healingtouchMana && p2.mana < cycloneMana )
{
system("cls");
cout << "\n\n\t" << playerOne
<< "\t\t\t\t\t" << playerTwo
<< "\n\n\tHealth: " << p1.health << " / " << p1.maxHealth
<< "\t\t\tHealth: " << p2.health << " / " << p2.maxHealth
<< "\n\tMana: " << p1.mana << " / " << p1.maxMana
<< "\t\t\tMana: " << p2.mana << " / " << p2.maxMana
<< "\n\n\n\tYou do not have enough mana to cast that spell.";
Sleep(1000);
continue;
}
}
continue;
}
if ( playerOneWinGame == true && playerTwoWinGame == false )
{
playerOneWin();
}
if ( playerOneWinGame == false && playerTwoWinGame == true )
{
playerTwoWin();
}
if ( playerOneWinGame == true && playerTwoWinGame == true )
{
playerDraw();
}
return 0;
}
void repeatGame()
{
char repeatGameChoice;
system("cls");
cout << "\n\tWould you like to play again?"
<< "\n\n\t(y/n): ";
if (!( cin >> repeatGameChoice ))
{
error();
repeatGame();
}
if ( repeatGameChoice != 'y' && repeatGameChoice != 'n' )
{
error();
repeatGame();
}
if ( repeatGameChoice == 'y' )
{
playGame = true;
main();
}
if ( repeatGameChoice == 'n' )
{
playGame = false;
}
}
string playerOneName()
{
while ( playGame == true )
{
playerOneTurnIntro();
system("cls");
string name;
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t Player One"
<< "\n\n\n\n\t\t\tPlease enter your character name: ";
if (!( cin >> name ))
{
error();
playerOneName();
}
return name;
}
return 0;
}
string playerTwoName()
{
while ( playGame == true )
{
playerTwoTurnIntro();
system("cls");
string name;
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t Player Two"
<< "\n\n\n\n\t\t\tPlease enter your character name: ";
if (!( cin >> name ))
{
error();
playerTwoName();
}
return name;
}
return 0;
}
void loadingGame()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tLoading";
Sleep(250);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tLoading.";
Sleep(250);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tLoading..";
Sleep(250);
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tLoading...";
Sleep(250);
system("cls");
}
void playerOneTurnIntro()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tPlayer 1";
Sleep(800);
system("cls");
}
void playerTwoTurnIntro()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tPlayer 2";
Sleep(800);
system("cls");
}
void playerOneWin()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\tCongratulations, Player One wins!";
Sleep(3000);
repeatGame();
}
void playerTwoWin()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\tCongratulations, Player Two wins!";
Sleep(3000);
repeatGame();
}
void playerDraw()
{
system("cls");
cout << "\n\n\n\n\n\n\n\n\n\n\t\t\tThe game is a draw!";
Sleep(3000);
repeatGame();
}
bool criticalHit()
{
int critHit = (rand()%100)+1;
if ( critHit >= 80 )
{
return true;
}
else
{
return false;
}
}
void error()
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}