-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem.cpp
39 lines (31 loc) · 1.19 KB
/
item.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
#include "item.h"
Item::Item() {
//srand(time(0)); I think this is once-per-application not once-per-class
generateItem();
}
Item::~Item() {};
// renamed for consistency and brevity
void Item::display() {
wprintw(Display::gear_win, "%s -- %d\n", this->name.c_str(), this->value);
}
void Item::generateItem() {
int randVal = rand() % 100;
std::string junkArray[] = {"Rock", "Broken Tooth", "Ripped Pelt", "Unidentifiable Ooze", "Shiny Rock"};
int junkValArray[] = {1, 5, 10, 3, 20};
std::string equipArray[] = {"Knife", "Shortsword", "Greatsword", "Breastplate", "Gauntlets"};
int equipValArray[] = {10, 25, 75, 40, 35};
std::string preArray[] = {"Rusted", "Worn", "Gaudy", "Common", "Masterwork"};
// std::string suffArray[] = {" of More Health"}; NYI
if (randVal < 15) { //You got equipment, generate it
randVal = rand() % 5; //Always get a base equipment
int randPreVal = rand() % 5; //Always get a prefix
name = preArray[randPreVal] + equipArray[randVal] + "";
value = equipValArray[randVal];
}
else { //You got junk, sell it!
randVal = rand() % 5;
value = junkValArray[randVal];
name = junkArray[randVal];
}
// name = nameArray[randName];
}