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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#include <iostream>
using namespace std;
/*
Name: Zander Cherry
Date: 10/11/2013
Project: make a Rock_Paper_Scissors game
*/
/*
rock
paper
scissors
r | p | s
---------
r > s done player 1 wins; battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'S' || battleOptionP2 == 's'
r < p done player 2 wins; battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'P' || battleOptionP2 == 'p'
r = r done no winner; battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'R' || battleOptionP2 == 'r'
p < s done player 2 wins; battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'S' || battleOptionP2 == 's'
p = p done no winner; battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'P' || battleOptionP2 == 'p'
p > r done player 1 wins; battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'R' || battleOptionP2 == 'r'
s = s done no winner; battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'S' || battleOptionP2 == 's'
s > p done player 1 wins; battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'P' || battleOptionP2 == 'p'
s < r done player 2 wins;
*/
int main()
{
char playGame, battleOption, battleOptionP2;
int playTime/*will be used*/, tie/*will be used*/, playAgain;
do
{
cout << "Ready to play?[y]/[n]: ";
cin >> playGame;
if(playGame == 'n' || playGame == 'N')
{
system("cls");
cout << "Maybe later :[?" << endl;
return 0;
}
cout << " " << endl;
cout << "Rules:" << endl;
cout << "1. Choose a battle option." << endl;
cout << "2. Choose from [R]ock, [P]aper, or [S]cissors." << endl;
cout << "3. Only type what is in the brakets" << endl;
cout << " " << endl;
do
{
cout << "Player one, choose your battle option: ";
cin >> battleOption;
system("cls");
cout << "Player two, choose your battle option: ";
cin >> battleOptionP2;
system("cls");
//rock
if((battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'S' || battleOptionP2 == 's')) // rock beats scissors; r > s
{
cout << "Player 1 Wins" << endl;
}
else if((battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'P' || battleOptionP2 == 'p')) // rock looses over paper; r < p
{
cout << "Player 2 Wins" << endl;
}
else if((battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'R' || battleOptionP2 == 'r')) // rock ties rock; r = r
{
cout << "Oops, It seems to be a tie" << endl;
}
//paper
else if((battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'S' || battleOptionP2 == 's')) // paper looses over scissors; p < s
{
cout << "Player 2 Wins" << endl;
}
else if((battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'P' || battleOptionP2 == 'p')) // paper ties paper; p = p
{
cout << "Oops, It seems to be a tie" << endl;
}
else if((battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'R' || battleOptionP2 == 'r')) // paper beats rock; p > r
{
cout << "Player 1 Wins" << endl;
}
//scissors
else if((battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'S' || battleOptionP2 == 's')) // scissors ties scissors; s = s
{
cout << "Oops, It seems to be a tie" << endl;
}
else if((battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'P' || battleOptionP2 == 'p')) // scissors beats paper; s > p
{
cout << "Player 1 Wins" << endl;
}
else if((battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'R' || battleOptionP2 == 'r')) // scissors looses over rock; s < r
{
cout << "Player 2 Wins" << endl;
}
cout << " " << endl;
cout << "Stats:" << endl;
cout << "------------------" << endl;
cout << "Player 1 choose: " << battleOption << endl;
cout << "Player 2 choose: " << battleOptionP2 << endl;
cout << " " << endl;
}
while(((battleOption == 'R' || battleOption == 'r') && (battleOptionP2 == 'R' || battleOptionP2 == 'r')) || ((battleOption == 'P' || battleOption == 'p') && (battleOptionP2 == 'P' || battleOptionP2 == 'p')) || ((battleOption == 'S' || battleOption == 's') && (battleOptionP2 == 'S' || battleOptionP2 == 's')));
cout << "Would you like to play again? [y]es, [n]o: ";
cin >> playAgain;
}
while(playAgain == 'y' || playAgain == 'Y');
}
|