-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
120 lines (104 loc) · 3.58 KB
/
main.cpp
File metadata and controls
120 lines (104 loc) · 3.58 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
108
109
110
111
112
113
114
115
116
117
118
119
120
// Tyeon Ford 9/14/25
// CSMC 240
#include "poke.h"
using namespace std;
// Main Menu: Getting user input
int main_menu(){
cout << "\n\n==============================" << endl;
cout << "Welcome to the Pokemon PC!" << endl;
cout << "1. Show PC" << endl;
cout << "2. Show Party" << endl;
cout << "3. Show Pokemon" << endl;
cout << "4. Send Pokemon to PC" << endl;
cout << "5. Send Pokemon to Party" << endl;
cout << "0. Exit" << endl;
cout << "==============================" << endl;
cout << "Please choose an option: \n> ";
int choice;
cin >> choice;
return choice;
}
// Moving pokemon from party to pc
void send_to_pc(vector<int> party, vector<int> PC){
if (party.empty()) {
cout << "Party is empty!" << endl;
} else {
cout << "Enter the index of the Pokemon to send to PC:";
int index;
cin >> index;
// Checking if its a valid index!!
if (index >= PC.size() || index < 0) {
cout << "Invalid index!" << endl;
} else {
array<string, 6> name = get_poke_names();
PC.push_back(party[index]);
cout << "Pokemon [" << index << "] (" << name[party[index]] << ") sent back to PC";
PC.erase(PC.begin() + index);
}
}
}
// Moving pokemon from pc to party
void send_to_party(vector<int> party, vector<int> PC){
if (PC.empty()) {
cout << "PC is empty!" << endl;
} else if (party.size() >= 6){ // Just in case the party may be full
cout << "Party is full!" << endl;
} else {
cout << "Enter the index of the Pokemon to send to party:";
int index;
cin >> index;
// Checking if its a valid index!!
if (index < 0) {
cout << "Invalid index!" << endl;
} else {
array<string, 6> name = get_poke_names();
party.push_back(PC[index]);
cout << "Pokemon [" << index << "] (" << name[index] << ") sent to party";
PC.erase(PC.begin() + index);
}
}
}
int main(){
// vectors to hold pokemon in PC and party
vector<int> pc = {0,1,2,3,4,5}; // pokemon in the PC (start with all pokemon)
vector<int> party = {}; // pokemon in the player's party
while (true){
int choice = main_menu();
// Exit
if (choice == 0){
cout << "Exiting the Pokemon PC. Goodbye!" << endl;
break;
// Show PC
} else if (choice == 1) {
show_PC(pc);
// Show Party
} else if (choice == 2) {
show_party(party);
// Show Pokemon
} else if (choice == 3) {
cout << "Enter the index of the pokemon in the party to show: ";
int poke_index;
cin >> poke_index;
if (party.empty()) {
cout << "Party is empty!" << endl;
// another edge case just if theres an invalid index
} else if (poke_index > party.size() || poke_index < 0) {
cout << "Invalid index!" << endl;
} else {
// getting the actual pokemon
int pokemon_location = party[poke_index];
show_pokemon(pokemon_location);
}
// Send Pokemon to PC
} else if (choice == 4) {
send_to_pc(party, pc);
//Send Pokemon to Party
} else if (choice == 5) {
send_to_party(party, pc);
} else { // Invalid input, Edge case #3
cout << "Invalid menu option, try again!" << endl;
continue;
}
}
return 0;
}