|
@ -11,6 +11,17 @@ |
|
|
#define INTERVAL 1000
|
|
|
#define INTERVAL 1000
|
|
|
#define FLAG_INTERVAL 250
|
|
|
#define FLAG_INTERVAL 250
|
|
|
|
|
|
|
|
|
|
|
|
Spell spellBook[] = { |
|
|
|
|
|
Spell("Spanish Inquisition", 1, 111111, 0), |
|
|
|
|
|
Spell("Mana Bolt", 1, 5, 1), |
|
|
|
|
|
Spell("Flame Bolt", 1, 8, 2), |
|
|
|
|
|
Spell("Mana Flare", 1, 10, 3), |
|
|
|
|
|
Spell("Ice Spear", 1, 13, 4), |
|
|
|
|
|
Spell("Mana Misile", 1, 15, 5), |
|
|
|
|
|
Spell("Thunder Strike", 1, 18, 6), |
|
|
|
|
|
Spell("Mana Blast", 1, 20, 7), |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
void sleep(int ms) |
|
|
void sleep(int ms) |
|
|
{ |
|
|
{ |
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(ms)); |
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(ms)); |
|
@ -86,24 +97,36 @@ int getNumber(const char *prompt, int min, int max) |
|
|
|
|
|
|
|
|
Character *chooseEnemy() |
|
|
Character *chooseEnemy() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Character Enemies[] = { |
|
|
|
|
|
Character("Red Mage", 1, 1, 10, 5, 1, 1), |
|
|
|
|
|
Character("Green Mage", 2, 3, 20, 10, 1, 1), |
|
|
|
|
|
Character("Blue Mage", 3, 7, 40, 25, 1, 1), |
|
|
|
|
|
Character("White Mage", 4, 11, 80, 40, 1, 1), |
|
|
|
|
|
Character("Black Mage", 5, 16, 160, 80, 1, 1), |
|
|
|
|
|
}; |
|
|
std::cout << "List of challenger:" << std::endl; |
|
|
std::cout << "List of challenger:" << std::endl; |
|
|
for (int i = 0; i < Character::Enemies.size(); i++) |
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) |
|
|
{ |
|
|
{ |
|
|
std::cout << "[" << i << "] " << Character::Enemies[i]->getName() << std::endl; |
|
|
|
|
|
|
|
|
std::cout << "[" << i << "] " << Enemies[i].getName() << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int choice = 0; |
|
|
int choice = 0; |
|
|
do |
|
|
|
|
|
{ |
|
|
|
|
|
choice = getNumber("Choose your enemy: ", 0, Character::Enemies.size()); |
|
|
|
|
|
} while (!(choice >= 0 && choice < Character::Enemies.size())); |
|
|
|
|
|
return Character::Enemies[choice]; |
|
|
|
|
|
|
|
|
choice = getNumber("Choose your enemy: ", 0, 4); |
|
|
|
|
|
return new Character(Enemies[choice]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Character *generatePlayer() |
|
|
Character *generatePlayer() |
|
|
{ |
|
|
{ |
|
|
|
|
|
const char *playerNames[] = { |
|
|
|
|
|
"Abby", |
|
|
|
|
|
"John", |
|
|
|
|
|
"Adam", |
|
|
|
|
|
"Johny", |
|
|
|
|
|
"Christo", |
|
|
|
|
|
"Greg", |
|
|
|
|
|
}; |
|
|
Character *tmp = new Character( |
|
|
Character *tmp = new Character( |
|
|
Character::playerNames[std::rand() % Character::playerNames.size()], |
|
|
|
|
|
|
|
|
playerNames[std::rand() % 6], |
|
|
1, |
|
|
1, |
|
|
1, |
|
|
1, |
|
|
100, |
|
|
100, |
|
@ -156,16 +179,16 @@ Character *startBattle(Character *p1, Character *p2) |
|
|
printCharacterInfo(p2); |
|
|
printCharacterInfo(p2); |
|
|
|
|
|
|
|
|
std::cout << "===== Spell Books =====" << std::endl; |
|
|
std::cout << "===== Spell Books =====" << std::endl; |
|
|
for (int i = 1; i <= p1->getLevel() && i < Spell::Book.size(); i++) |
|
|
|
|
|
|
|
|
for (int i = 1; i <= p1->getLevel() && i < 8; i++) |
|
|
{ |
|
|
{ |
|
|
std::cout << "[" << i << "] " << Spell::Book[i]->getName() << std::endl; |
|
|
|
|
|
|
|
|
std::cout << "[" << i << "] " << spellBook[i].getName() << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int p1Choice = getNumber("Choose your spell: ", 0, getLowest(p1->getLevel(), Spell::Book.size() - 1)); |
|
|
|
|
|
int p2Choice = (std::rand() % getLowest(p2->getLevel(), Spell::Book.size() - 1)) + 1; |
|
|
|
|
|
|
|
|
int p1Choice = getNumber("Choose your spell: ", 0, getLowest(p1->getLevel(), 8 - 1)); |
|
|
|
|
|
int p2Choice = (std::rand() % getLowest(p2->getLevel(), 8 - 1)) + 1; |
|
|
|
|
|
|
|
|
Spell *p1Spell = Spell::Book[p1Choice]; |
|
|
|
|
|
Spell *p2Spell = Spell::Book[p2Choice]; |
|
|
|
|
|
|
|
|
Spell *p1Spell = &spellBook[p1Choice]; |
|
|
|
|
|
Spell *p2Spell = &spellBook[p2Choice]; |
|
|
|
|
|
|
|
|
if (p1->canCastSpell(p1Spell)) |
|
|
if (p1->canCastSpell(p1Spell)) |
|
|
{ |
|
|
{ |
|
|