This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharness.cc
executable file
·102 lines (93 loc) · 2.82 KB
/
harness.cc
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
//#include "character.h"
#include "variable.h"
//#include "treasure.h"
#include "floor.h"
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
using namespace std;
int main(int argc, char *argv[]){
init();
fstream layout;
Floor* myfloor=0;
char command, temp; //
if(argc > 1) {
layout.open(argv[1],std::fstream::in);
}
else {
layout.open("layout.txt",std::fstream::in);
}
cout << "Please select a race (h, d, e, o): ";
cin >> command;
if (command=='q') return 0;
if (command == 'r') cin>>command;
myfloor = new Floor(layout, command);
layout.close();
Character* myChar;
while(true){
cin >> command;
if(!myfloor->returnStatus()){
if (command == 'u') {
cin >> command >> temp;
myChar = myfloor->findAtLocation(command, temp);
if (myChar!=0) myfloor->usePotion(myChar);
else cout<< "There's nothing to use there! Re-enter command: ";
// myfloor->print();
}
else if (command == 'a') {
cin >> command >> temp;
myChar = myfloor->findAtLocation(command, temp);
if (myChar!=0) myfloor->attackEnemy(myChar);
else cout<< "There's nothing to attack there! Re-enter command: ";
// myfloor->print();
}
else if (command == 'r') {
if(argc > 1) {
layout.open(argv[1],std::fstream::in);
}
else {
layout.open("layout.txt",std::fstream::in);
}
delete myfloor;
cin >> command;
myfloor = new Floor(layout, command);
// myfloor->print();
layout.close();
}
else if (command == 'q') {
cout << "Game has ended." << endl;
delete myfloor;
break;
}
else {
cin >> temp;
myfloor->move(command, temp);
// myfloor->print();
}
}
else{
if (command == 'r') {
if(argc > 1) {
layout.open(argv[1],std::fstream::in);
}
else {
layout.open("layout.txt",std::fstream::in);
}
delete myfloor;
cout << "Please select a race (h, d, e, o): ";
cin >> command;
myfloor = new Floor(layout, command);
// myfloor->print();
layout.close();
}
else if (command == 'q') {
cout << "Game has ended." << endl;
delete myfloor;
break;
}
}
cin.clear();
}
}