-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
145 lines (134 loc) · 4.16 KB
/
main.cpp
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* @file main.cpp
* @author Diego Antonio Garcia Padilla (github.com/DiegoGarciaPadilla)
* @brief This program is a character creator for the D&D game.
* @version 0.1
* @date 2022-12-21
*
* @copyright Copyright (c) 2022
*
*/
#ifndef MAIN_H // If the preprocessor MAIN_H is not defined
#define MAIN_H // Define the preprocessor MAIN_H
#include <iostream> // Library for input and output
#include <string> // Library for strings
#include <sstream> // Library for string streams
#include <fstream> // Library for file streams
#include <cstdlib> // Library for system functions
#include <vector> // Library for vectors
#include "drivers/Menu.cc" // Library for menus
#include "drivers/Functions.cc" // Library for functions
#include "drivers/Character.cc" // Library for the character class
#include "drivers/Merchant.cc" // Library for the merchant class
// Main function
int main()
{
// Variables
int mainOption;
Character character;
Merchant merchant;
// Initialize merchant
merchant.initialize();
// Main menu loop
do
{
// Show the main menu
mainMenu();
// Get the option
std::cout << "Enter an option:" << std::endl;
std::cin >> mainOption;
cleanScreen();
// Switch for the main menu
switch (mainOption)
{
case 1:
if (character.getName() != "None")
{
// Variables
int characterOption;
// Ask the user if they want to overwrite the character
std::cout << "There is already a character created" << std::endl;
std::cout << "Do you want to overwrite it?" << std::endl;
std::cout << "1. Yes" << std::endl;
std::cout << "2. No" << std::endl;
std::cin >> characterOption;
// Switch for the character menu
switch (characterOption)
{
case 1:
character.createCharacter();
break;
case 2:
std::cout << "The character was not overwritten" << std::endl;
break;
default:
std::cout << "Invalid option" << std::endl;
break;
}
}
else
{
character.createCharacter();
}
pause();
break;
case 2:
if (character.getName() == "None")
{
std::cout << "There is no character to show" << std::endl;
}
else
{
std::cout << character.toString() << std::endl;
}
pause();
break;
case 3:
if (character.getName() == "None")
{
std::cout << "There is no character to show" << std::endl;
}
else
{
character.showEquippedItems();
}
pause();
break;
case 4:
if (character.getName() == "None")
{
std::cout << "There is no character to show" << std::endl;
}
else
{
character.showInventory();
}
pause();
break;
case 5:
if (character.getName() == "None")
{
std::cout << "You need to create a character first" << std::endl;
}
else
{
merchant.interact(character);
}
pause();
break;
case 6:
encyclopediaMenu();
break;
case 0:
std::cout << "Goodbye adventurer. See you soon..." << std::endl;
pause();
break;
default:
std::cout << "Invalid option" << std::endl;
pause();
break;
}
cleanScreen();
} while (mainOption != 0);
}
#endif // End of the preprocessor MAIN_H