Strictify skill enum
This commit is contained in:
@@ -111,7 +111,7 @@ cItemRec::cItemRec(){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 0;
|
||||
ability = eItemAbil::NONE;
|
||||
@@ -153,7 +153,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 1;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::EDGED;
|
||||
type = eSkill::EDGED_WEAPONS;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 55;
|
||||
value = 2;
|
||||
@@ -169,7 +169,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 75;
|
||||
value = 2;
|
||||
@@ -185,7 +185,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 10;
|
||||
value = 15;
|
||||
@@ -201,7 +201,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 12;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 57;
|
||||
value = 1;
|
||||
@@ -217,7 +217,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::POLE;
|
||||
type = eSkill::POLE_WEAPONS;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 4;
|
||||
value = 10;
|
||||
@@ -233,7 +233,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 76;
|
||||
value = 6;
|
||||
@@ -249,7 +249,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 72;
|
||||
value = 0;
|
||||
@@ -265,7 +265,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 0;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 63;
|
||||
value = 0;
|
||||
@@ -281,7 +281,7 @@ cItemRec::cItemRec(long preset){
|
||||
bonus = 0;
|
||||
protection = 0;
|
||||
charges = 1;
|
||||
type = eWeapType::NOT_MELEE;
|
||||
type = eSkill::INVALID;
|
||||
magic_use_type = 0;
|
||||
graphic_num = 60;
|
||||
value = 0;
|
||||
@@ -301,7 +301,9 @@ cItemRec& cItemRec::operator = (legacy::item_record_type& old){
|
||||
bonus = old.bonus;
|
||||
protection = old.protection;
|
||||
charges = old.charges;
|
||||
type = (eWeapType) old.type;
|
||||
if(old.type >= 3 && old.type <= 5)
|
||||
type = eSkill(old.type);
|
||||
else type = eSkill::INVALID;
|
||||
magic_use_type = old.magic_use_type;
|
||||
graphic_num = old.graphic_num;
|
||||
if(graphic_num >= 150) // custom item graphic
|
||||
@@ -408,7 +410,7 @@ void cItemRec::readFrom(std::istream& sin){
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator << (std::ostream& out, eWeapType& e){
|
||||
std::ostream& operator << (std::ostream& out, eSkill& e){
|
||||
return out << (int) e;
|
||||
}
|
||||
|
||||
@@ -421,12 +423,12 @@ std::ostream& operator << (std::ostream& out, eItemAbil& e){
|
||||
}
|
||||
|
||||
// TODO: Perhaps this should understand symbolic names as well?
|
||||
std::istream& operator >> (std::istream& in, eWeapType& e){
|
||||
std::istream& operator >> (std::istream& in, eSkill& e){
|
||||
int i;
|
||||
in >> i;
|
||||
if(i > 0 && i < 4)
|
||||
e = (eWeapType) i;
|
||||
else e = eWeapType::NOT_MELEE;
|
||||
if(i >= 0 && i < 19)
|
||||
e = (eSkill) i;
|
||||
else e = eSkill::INVALID;
|
||||
return in;
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ public:
|
||||
int bonus;
|
||||
int protection;
|
||||
int charges;
|
||||
eWeapType type;
|
||||
eSkill type;
|
||||
int magic_use_type;
|
||||
unsigned short graphic_num;
|
||||
eItemAbil ability;
|
||||
@@ -77,12 +77,12 @@ public:
|
||||
void readFrom(std::istream& sin);
|
||||
};
|
||||
|
||||
std::ostream& operator << (std::ostream& out, eWeapType& e);
|
||||
std::ostream& operator << (std::ostream& out, eItemType& e);
|
||||
std::ostream& operator << (std::ostream& out, eItemAbil& e);
|
||||
std::istream& operator >> (std::istream& in, eWeapType& e);
|
||||
std::istream& operator >> (std::istream& in, eItemType& e);
|
||||
std::istream& operator >> (std::istream& in, eItemAbil& e);
|
||||
std::ostream& operator << (std::ostream& out, eSkill& e);
|
||||
std::istream& operator >> (std::istream& in, eSkill& e);
|
||||
|
||||
class cSpecItem {
|
||||
public:
|
||||
|
@@ -19,8 +19,10 @@ cPlayer& cPlayer::operator = (legacy::pc_record_type old){
|
||||
int i;
|
||||
main_status = (eMainStatus) old.main_status;
|
||||
name = old.name;
|
||||
for(i = 0; i < 20; i++)
|
||||
skills[i] = old.skills[i];
|
||||
for(i = 0; i < 19; i++) {
|
||||
eSkill skill = eSkill(i);
|
||||
skills[skill] = old.skills[i];
|
||||
}
|
||||
max_health = old.max_health;
|
||||
cur_health = old.cur_health;
|
||||
max_sp = old.max_sp;
|
||||
@@ -80,8 +82,9 @@ cPlayer::cPlayer(){
|
||||
main_status = eMainStatus::ABSENT;
|
||||
name = "\n";
|
||||
|
||||
for (i = 0; i < 30; i++)
|
||||
skills[i] = (i < 3) ? 1 : 0;
|
||||
skills[eSkill::STRENGTH] = 1;
|
||||
skills[eSkill::DEXTERITY] = 1;
|
||||
skills[eSkill::INTELLIGENCE] = 1;
|
||||
cur_health = 6;
|
||||
max_health = 6;
|
||||
cur_sp = 0;
|
||||
@@ -130,9 +133,14 @@ cPlayer::cPlayer(long key,short slot){
|
||||
name = "Goo";
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < 30; i++)
|
||||
skills[i] = (i < 3) ? 20 : 8;
|
||||
cur_health = 60;
|
||||
skills[eSkill::STRENGTH] = 20;
|
||||
skills[eSkill::DEXTERITY] = 20;
|
||||
skills[eSkill::INTELLIGENCE] = 20;
|
||||
for (i = 3; i < 19; i++) {
|
||||
eSkill skill = eSkill(i);
|
||||
skills[skill] = 8;
|
||||
}
|
||||
cur_health = 60;
|
||||
max_health = 60;
|
||||
cur_sp = 90;
|
||||
max_sp = 90;
|
||||
@@ -161,13 +169,33 @@ cPlayer::cPlayer(long key,short slot){
|
||||
//exp_adj = 100;
|
||||
direction = 0;
|
||||
}else if(key == 'dflt'){
|
||||
static const short pc_stats[6][19] = {
|
||||
{8,6,2, 6,0,0,0,0,0, 0,0,0,0,1, 0,0,2,0,0},
|
||||
{8,7,2, 0,0,6,3,0,3, 0,0,0,0,0, 0,0,0,2,0},
|
||||
{8,6,2, 3,3,0,0,2,0, 0,0,0,0,0, 4,4,0,2,1},
|
||||
{3,2,6, 2,0,0,2,0,0, 3,0,3,0,1, 0,0,0,0,0},
|
||||
{2,2,6, 3,0,0,2,0,0, 2,1,4,0,0, 0,0,0,0,1},
|
||||
{2,2,6, 0,2,0,2,0,1, 0,3,3,2,0, 0,0,0,0,0}
|
||||
// TODO: The duplication of std::map<eSkill,short> shouldn't be needed here
|
||||
static std::map<eSkill, short> pc_stats[6] = {
|
||||
std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,8}, {eSkill::DEXTERITY,6}, {eSkill::INTELLIGENCE,2},
|
||||
{eSkill::EDGED_WEAPONS,6}, {eSkill::ITEM_LORE,1}, {eSkill::ASSASSINATION,2},
|
||||
}, std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,8}, {eSkill::DEXTERITY,7}, {eSkill::INTELLIGENCE,2},
|
||||
{eSkill::POLE_WEAPONS,6}, {eSkill::THROWN_MISSILES,3}, {eSkill::DEFENSE,3},
|
||||
{eSkill::POISON,2},
|
||||
}, std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,8}, {eSkill::DEXTERITY,6}, {eSkill::INTELLIGENCE,2},
|
||||
{eSkill::EDGED_WEAPONS,3}, {eSkill::BASHING_WEAPONS,3}, {eSkill::ARCHERY,2},
|
||||
{eSkill::DISARM_TRAPS,4}, {eSkill::LOCKPICKING,4}, {eSkill::POISON,2}, {eSkill::LUCK,1},
|
||||
}, std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,3}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6},
|
||||
{eSkill::EDGED_WEAPONS,2}, {eSkill::THROWN_MISSILES,2},
|
||||
{eSkill::MAGE_SPELLS,3}, {eSkill::MAGE_LORE,3}, {eSkill::ITEM_LORE,1},
|
||||
}, std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,2}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6},
|
||||
{eSkill::EDGED_WEAPONS,3}, {eSkill::THROWN_MISSILES,2},
|
||||
{eSkill::MAGE_SPELLS,2}, {eSkill::PRIEST_SPELLS,1}, {eSkill::MAGE_LORE,4},
|
||||
{eSkill::LUCK,1},
|
||||
}, std::map<eSkill,short>{
|
||||
{eSkill::STRENGTH,2}, {eSkill::DEXTERITY,2}, {eSkill::INTELLIGENCE,6},
|
||||
{eSkill::BASHING_WEAPONS,2}, {eSkill::THROWN_MISSILES,2}, {eSkill::DEFENSE,1},
|
||||
{eSkill::PRIEST_SPELLS,3}, {eSkill::MAGE_LORE,3}, {eSkill::ALCHEMY,2},
|
||||
},
|
||||
};
|
||||
static const short pc_health[6] = {22,24,24,16,16,18};
|
||||
static const short pc_sp[6] = {0,0,0,20,20,21};
|
||||
@@ -206,9 +234,11 @@ cPlayer::cPlayer(long key,short slot){
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < 19; i++)
|
||||
skills[i] = pc_stats[slot][i];
|
||||
cur_health = pc_health[slot];
|
||||
for (i = 0; i < 19; i++) {
|
||||
eSkill skill = eSkill(i);
|
||||
skills[skill] = pc_stats[slot][skill];
|
||||
}
|
||||
cur_health = pc_health[slot];
|
||||
max_health = pc_health[slot];
|
||||
experience = 0;
|
||||
skill_pts = 0;
|
||||
@@ -255,11 +285,13 @@ void operator -= (eMainStatus& stat, eMainStatus othr){
|
||||
void cPlayer::writeTo(std::ostream& file){
|
||||
file << "STATUS -1 " << main_status << '\n';
|
||||
file << "NAME " << name << '\n';
|
||||
file << "SKILL -2 " << max_health << '\n';
|
||||
file << "SKILL -1 " << max_sp << '\n';
|
||||
for(int i = 0; i < 30; i++)
|
||||
if(skills[i] > 0)
|
||||
file << "SKILL " << i << ' ' << skills[i] << '\n';
|
||||
file << "SKILL 19 " << max_health << '\n';
|
||||
file << "SKILL 20 " << max_sp << '\n';
|
||||
for(int i = 0; i < 19; i++) {
|
||||
eSkill skill = eSkill(i);
|
||||
if(skills[skill] > 0)
|
||||
file << "SKILL " << i << ' ' << skills[skill] << '\n';
|
||||
}
|
||||
file << "HEALTH " << cur_health << '\n';
|
||||
file << "MANA " << cur_sp << '\n';
|
||||
file << "EXPERIENCE " << experience << '\n';
|
||||
@@ -319,13 +351,17 @@ void cPlayer::readFrom(std::istream& file){
|
||||
sin >> i;
|
||||
switch(i){
|
||||
case -1:
|
||||
case 20:
|
||||
sin >> max_sp;
|
||||
break;
|
||||
case -2:
|
||||
case 19:
|
||||
sin >> max_health;
|
||||
break;
|
||||
default:
|
||||
sin >> skills[i];
|
||||
if(i < 0 || i >= 19) break;
|
||||
eSkill skill = eSkill(i);
|
||||
sin >> skills[skill];
|
||||
}
|
||||
}else if(cur == "HEALTH")
|
||||
sin >> cur_health;
|
||||
|
@@ -24,7 +24,7 @@ class cPlayer {
|
||||
public:
|
||||
eMainStatus main_status;
|
||||
std::string name;
|
||||
short skills[30];
|
||||
std::map<eSkill, short> skills;
|
||||
unsigned short max_health;
|
||||
short cur_health;
|
||||
unsigned short max_sp;
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
//short exp_adj;
|
||||
short direction;
|
||||
short ap;
|
||||
// transient stuff
|
||||
std::map<eSkill,short> last_cast;
|
||||
|
||||
cPlayer& operator = (legacy::pc_record_type old);
|
||||
cPlayer();
|
||||
|
@@ -240,14 +240,6 @@ inline bool blocksMove(eTerObstruct block) {
|
||||
return code > 2;
|
||||
}
|
||||
|
||||
/* items[i].type a.k.a type of weapon */
|
||||
enum class eWeapType {
|
||||
NOT_MELEE = 0,
|
||||
EDGED = 1,
|
||||
BASHING = 2,
|
||||
POLE = 3,
|
||||
};
|
||||
|
||||
/* items[i].variety a.k.a item type (in editor) */
|
||||
enum class eItemType {
|
||||
NO_ITEM = 0,
|
||||
@@ -448,28 +440,35 @@ inline eItemAbilCat getItemAbilCategory(eItemAbil abil) {
|
||||
}
|
||||
|
||||
/* adven[i].skills */ //complete
|
||||
enum eSkill {
|
||||
SKILL_STRENGTH = 0,
|
||||
SKILL_DEXTERITY = 1,
|
||||
SKILL_INTELLIGENCE = 2,
|
||||
SKILL_EDGED_WEAPONS = 3,
|
||||
SKILL_BASHING_WEAPONS = 4,
|
||||
SKILL_POLE_WEAPONS = 5,
|
||||
SKILL_THROWN_MISSILES = 6,
|
||||
SKILL_ARCHERY = 7,
|
||||
SKILL_DEFENSE = 8,
|
||||
SKILL_MAGE_SPELLS = 9,
|
||||
SKILL_PRIEST_SPELLS = 10,
|
||||
SKILL_MAGE_LORE = 11,
|
||||
SKILL_ALCHEMY = 12,
|
||||
SKILL_ITEM_LORE = 13,
|
||||
SKILL_DISARM_TRAPS = 14,
|
||||
SKILL_LOCKPICKING = 15,
|
||||
SKILL_ASSASSINATION = 16,
|
||||
SKILL_POISON = 17,
|
||||
SKILL_LUCK = 18,
|
||||
SKILL_MAX_HP = 19,
|
||||
SKILL_MAX_SP = 20,
|
||||
enum class eSkill {
|
||||
INVALID = -1,
|
||||
STRENGTH = 0,
|
||||
DEXTERITY = 1,
|
||||
INTELLIGENCE = 2,
|
||||
EDGED_WEAPONS = 3,
|
||||
BASHING_WEAPONS = 4,
|
||||
POLE_WEAPONS = 5,
|
||||
THROWN_MISSILES = 6,
|
||||
ARCHERY = 7,
|
||||
DEFENSE = 8,
|
||||
MAGE_SPELLS = 9,
|
||||
PRIEST_SPELLS = 10,
|
||||
MAGE_LORE = 11,
|
||||
ALCHEMY = 12,
|
||||
ITEM_LORE = 13,
|
||||
DISARM_TRAPS = 14,
|
||||
LOCKPICKING = 15,
|
||||
ASSASSINATION = 16,
|
||||
POISON = 17,
|
||||
LUCK = 18,
|
||||
MAX_HP = 19,
|
||||
MAX_SP = 20,
|
||||
// Magic values; only for check_party_stat()
|
||||
CUR_HP = 100,
|
||||
CUR_SP = 101,
|
||||
CUR_XP = 102,
|
||||
CUR_SKILL = 103,
|
||||
CUR_LEVEL = 104,
|
||||
};
|
||||
|
||||
/* adven[i].traits */ //complete
|
||||
|
Reference in New Issue
Block a user