-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathutilities.cpp
214 lines (173 loc) · 5.55 KB
/
utilities.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//
// Created by itke on 4/20/2022.
//
#include "utilities.h"
using std::cout;
using std::string;
using std::ostream;
using std::endl;
/* ---------------------------------------------------------------------------------------------- */
// ---------------- Print functions for Player class -----------------------
void printPlayerDetails(ostream &os, string name, string job, int level, int force, int HP, int coins)
{
const int nameDistance = 16;
const int distance = 6;
os << name;
for(unsigned int i = 0; i < nameDistance - name.size(); i++){
os << " ";
}
os << level;
if(level < 10){
os << " ";
}
os << " " << force;
for(unsigned int i = 0; i < distance - std::to_string(force).size(); i++){
os << " ";
}
os << HP;
for(unsigned int i = 0; i < distance - std::to_string(HP).size(); i++){
os << " ";
}
os << coins;
for(unsigned int i = 0; i < distance - std::to_string(coins).size(); i++){
os << " ";
}
os << job << " ";
}
/* ---------------------------------------------------------------------------------------------- */
// ---------------------------- Print functions for Card class --------------------------
void printCardDetails(ostream &os, string name)
{
os << "Card Details:" << endl;
os << "Name: " << name << endl;
}
void printEndOfCardDetails(ostream &os)
{
os << "-------------------------------" << std::endl;
}
void printMerchantInitialMessageForInteractiveEncounter(ostream &os, string playerName, int coins)
{
os << "You've ran into a Merchant!" << endl;
os << "Browse his wares:"<< endl;
os << "Health Potion (heals 1 health point) : 5 coins per potion." << endl;
os << "Force boost (adds 1 force): 10 coins per boost." << endl;
os << "Enter 1 for Health Potion, 2 for force boost or 0 to leave." << endl;
os << playerName << " has " << coins << " coins" << endl;
}
void printMerchantInsufficientCoins(std::ostream &os){
cout << "You dont have enough coins for this purchase. Please try again." << endl;
}
void printMonsterDetails(ostream &os, int force, int damage, int coins, bool isDragon)
{
os << "Force: " << force << endl;
if (isDragon)
os << "Damage upon loss: " << "Infinite" << endl;
else
os << "Damage upon loss: " << damage << endl;
os << "Coins: " << coins << endl;
}
void printBarfightMessage(bool isFighter)
{
if(isFighter){
cout << "You've won the scuffle without losing any health points." << endl;
}
else{
cout << "This is but a flesh wound. You've lost 10 health points" << endl ;
}
}
void printFairyMessage(bool isWizard)
{
if(isWizard){
cout << "Fairies like wizards, you've gained 10 health points." << endl;
}
else{
cout << "Nothing happened." << endl ;
}
}
void printPitfallMessage(bool isRogue)
{
if(isRogue){
cout << "You saw the trap coming from miles away, you dodged it gracefully." << endl;
}
else{
cout << "You fell into the trap, lose 10 health points." << endl ;
}
}
void printTreasureMessage()
{
cout << "You've stumbled into a pile of coins! you've gained 10 gold." << endl;
}
void printMerchantSummary(ostream &os, string playerName, int type, int cost)
{
os << playerName << " has paid " << cost << " coins ";
if(type != 0){
os << "for ";;
}
if(type == 1){
os << "1 health potion!";
}
if(type == 2){
os << "1 force boost!";
}
os << endl <<"Safe travels!" << endl;
}
/* ---------------------------------------------------------------------------------------------- */
// Prints for Game
void printInsertPlayerMessage()
{
cout << "Please insert the player name and class: " << endl;
}
void printInvalidTeamSize()
{
cout << "Invalid team size! Please enter a different size." << endl;
}
void printInvalidClass()
{
cout << "You have entered an invalid class. Please try again." << endl;
}
void printInvalidName()
{
cout << "You have entered an invalid name. Please try again." << endl;
}
void printInvalidInput()
{
cout << "You have entered an invalid input. Please try again." << endl;
}
void printStartGameMessage()
{
cout << "Welcome to the world of MtmChkin!!!" << endl;
}
void printEnterTeamSizeMessage()
{
cout << "Please enter team size: (2-6)" << endl;
}
void printTurnStartMessage(string name)
{
cout << "Start of " << name << "'s turn: " << endl;
}
void printRoundStartMessage(int roundCount)
{
cout << endl << "-------------------------------------------" << endl;
cout << "Start of round " << roundCount << ":" << endl << endl;
}
void printWinBattle(string playerName, string monsterName)
{
cout << "Player " << playerName << " has defeated " << monsterName << " and rose 1 Level!" << endl;
}
void printLossBattle(string playerName, string monsterName)
{
cout << "Player " << playerName << " has been defeated by a " << monsterName << "." << endl;
}
void printLeaderBoardStartMessage()
{
cout << endl << "The current ranking of the Team:" << endl;
cout << "Ranking Player Name Level Force HP Coins Job" << endl;
}
void printPlayerLeaderBoard(int ranking, Player& player)
{
cout << ranking << " " << player << endl;
}
void printGameEndMessage()
{
cout << "The Game has ended!!!" << endl;
}