-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
109 lines (82 loc) · 2.27 KB
/
main.cpp
File metadata and controls
109 lines (82 loc) · 2.27 KB
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
#include <iostream>
#include <fstream>
#include <string>
#include "character.h"
#include "warrior.h"
#include "wizard.h"
#include "game.h"
using namespace std;
int main()
{
string filename;
cin >> filename;
ifstream input(filename);
Game game;
if (!input.is_open()) {
cout << "file not found!" << endl;
exit(0);
}
string inS;
string type, name, race;
int level, health;
string wepName;
int stamina, wepDamage, wepStamCost;
string spName;
int mana, numSpells, spDamage, spMana;
while(!input.eof()){
getline(input,type);
getline(input, name);
getline(input, race);
getline(input, inS);
level = stoi(inS);
getline(input, inS);
health = stoi(inS);
if(type == "Warrior"){//Warrior creation
getline(input,inS);
stamina = stoi(inS);
Warrior *w = new Warrior(name,race,level,health,stamina);
getline(input,wepName); //Gathering weapon info
getline(input,inS);
wepDamage = stoi(inS);
getline(input,inS);
wepStamCost = stoi(inS);
w->EquipWeapon(wepName,wepDamage,wepStamCost);//Adding weapon
game.AddCharacter(w);
}
else if(type == "Wizard"){//Wizard creation
getline(input,inS);
mana = stoi(inS);
Wizard *w = new Wizard(name,race,level,health,mana);
getline(input,inS);
numSpells = stoi(inS);
for(int a = 0; a < numSpells; a++){
getline(input,spName);
getline(input,inS);
spDamage = stoi(inS);
getline(input,inS);
spMana = stoi(inS);
w->AddSpell(spName,spDamage,spMana);
}
game.AddCharacter(w);
}
getline(input, inS);
}
int option = -1;
do {
cout << "Please choose an option: " << endl
<< "1 - Next Turn" << endl
<< "2 - Print All Characters" << endl
<< "3 - Exit" << endl;
cin >> option;
cout << endl;
switch (option) {
case 1: game.NextTurn(); break;
case 2: game.Print(); break;
case 3: exit(0);
default:
cout << "Invalid Option!" << endl;
}
cout << endl;
}while (option != 3);
return 0;
}