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
|
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;
enum DiceSideT {PEASANT, SQUIRE, KNIGHT, BOMB, NO_SIDE};
enum PlayerLocationT {OUTER_WARD, BARBICAN, MOTE, OUTER_GATE, MIDDLE_WARD, GATE_HOUSE, INNER_WARD, MAIN_DOOR, ENTRANCE_HALL, MAIN_HALL};
//enum
const int DICE_SIDES = 8;
string IdentifySide(int sides);
char GetUserLevel(void);
int GetUserStartingDice(void);
int RollDice(void);
int InitalizeDice(void);
int main(){
srand(time(NULL));
InitalizeDice();
//while(PlayPrompt()){
int gamesPlayed = 0;
int maxDice;
int sides;
maxDice = GetUserStartingDice();
cout << "Good, you will start with " << maxDice << " dice." << endl;
RollDice();
IdentifySide(sides);
gamesPlayed++;
// PlayPrompt();
// }
return 0;
}
int GetUserStartingDice(void){
char level;
int maxDice;
level = GetUserLevel();
switch (level){
case 'H':
case 'h':
maxDice = 8;
break;
case 'M':
case 'm':
maxDice = 10;
break;
case 'E':
case 'e':
maxDice = 15;
break;
default:
maxDice = 10;
}
return maxDice;
}
char GetUserLevel(void){
char choice;
do{
cout << "Please enter a letter for a difficulty!" << endl;
cout << "h ..... Hard" << endl;
cout << "m ..... Medium" << endl;
cout << "e ..... Easy" << endl;
cout << "}> ";
cin >> choice;
choice = tolower(choice);
} while (choice != 'h' and choice != 'm' and choice != 'e');
return choice;
}
int InitalizeDice(void){
int choice;
do{
cout << "Please enter a random number for the computer." << endl;
cout << "}> ";
cin >> choice;
} while (choice < INT_MIN and choice > INT_MAX);
return choice;
}
int RollDice(void){
string IdentifySide(DiceSideT);
string diceValue;
int randomNumber;
int diceRolled;
int maxDice;
int choice;
int sides;
do{
cout << "Please enter the number of dice you wish to roll." << endl;
cout << "}> ";
choice = rand();
sides = choice % DICE_SIDES;
diceRolled--;
diceValue = IdentifySide(DiceSideT);
cout << "You got a " << IdentifySide(DiceSideT) << endl;
}while (diceRolled <= maxDice && diceRolled > 0);
return 0;
}
string IdentifySide(DiceSideT, int sides){
switch (sides){
case PEASANT: return "Peasant";
case SQUIRE: return "Squire";
case KNIGHT: return "Knight";
case BOMB: return "Bomb";
case NO_SIDE:
default: return "No Side";
}
}
|