This repository has been archived by the owner on Nov 28, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSkills.cpp
188 lines (154 loc) · 4.59 KB
/
Skills.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
/*******************************
Skill Management Code
each character has access to a variety of skills
practice needed to advance a skill:
ranks exercise (x-class)
1 0 10
2 10 20
3 20 40
4 30 60
5 40 70
6 50 80
etc.
********************************/
#include "Global.h"
#include "Util.h"
#include "Object.h"
#include "Hero.h"
#include "Interface.h"
const char *
shSkill::getName ()
{
switch (mCode) {
case kConcentration: return "Concentration";
case kHide: return "Hide";
case kMoveSilently: return "Move Silently";
case kMeleeWeapon: return "Basic Melee Weapons";
case kSword: return "Swords";
case kUnarmedCombat: return "Unarmed Combat";
case kOpenLock: return "Pick Locks";
case kRepair: return "Repair";
case kGrenade: return "Thrown Weapons";
case kHandgun: return "Handguns";
case kLightGun: return "Light Guns";
case kHeavyGun: return "Heavy Guns";
case kSearch: return "Search";
case kHacking: return "Programming";
case kListen: return "Listen";
case kSpot: return "Spot";
case kMutantPower:
return getMutantPowerName (mPower);
default:
return "Unknown!";
}
}
#if 0
static int
compareSkills (shSkill **a, shSkill **b)
{
shSkill *s1 = * (shSkill **) a;
shSkill *s2 = * (shSkill **) b;
if (s1->mCode < s2->mCode) {
return -1;
} else if (s1->mCode > s2->mCode) {
return 1;
} else if (s1->mPower < s2->mPower) {
return -1;
} else {
return 1;
}
}
#endif
void
shSkill::getDesc (char *buf, int len)
{
const char *abil = NULL;
if (kMutantPower == mCode) {
abil = "Cha";
} else {
switch (kSkillAbilityMask & mCode) {
case kStrSkill: abil = "Str"; break;
case kConSkill: abil = "Con"; break;
case kAgiSkill: abil = "Agi"; break;
case kDexSkill: abil = "Dex"; break;
case kIntSkill: abil = "Int"; break;
case kWisSkill: abil = "Wis"; break;
case kChaSkill: abil = "Cha"; break;
}
}
snprintf (buf, len, "%s (%s) ", getName (), abil);
snprintf (&buf[28], len-28, "%d (%d) ", mRanks,
mAccess*(Hero.mCLevel+1)/4);
}
void
shHero::editSkills ()
{
char prompt[50];
int i;
int flags = 0;
int navail = 0;
char buf[70];
shSkill *skill;
shSkillCode lastcode = kWeaponSkill;
// mSkills.sort (&compareSkills);
do {
if (mSkillPoints > 1) {
snprintf (prompt, 50, "You may make %d skill advancements:",
mSkillPoints);
flags |= shMenu::kMultiPick;
} else if (1 == mSkillPoints) {
snprintf (prompt, 50, "You may advance a skill:");
flags |= shMenu::kMultiPick;
} else {
snprintf (prompt, 50, "Skills");
flags |= shMenu::kNoPick;
}
shMenu menu (prompt, flags);
char letter = 'a';
#if 0
if (mSkillPoints) {
menu.addHeader (" Skill Ranks");
} else {
menu.addHeader ("Skill Ranks");
}
#else
menu.addHeader ("Combat Skills");
#endif
for (i = 0; i < mSkills.count (); i++) {
skill = mSkills.get (i);
skill->getDesc (buf, 70);
if (kMutantPower == skill->mCode && !mMutantPowers[skill->mPower])
continue; /* can't advance skills til you learn the power */
if (kWeaponSkill & lastcode && !(kWeaponSkill & skill->mCode)) {
menu.addHeader ("Adventuring Skills");
} else if (kMutantPower != lastcode &&
kMutantPower == skill->mCode)
{
menu.addHeader ("Mutant Power Skills");
}
lastcode = skill->mCode;
if (mSkillPoints &&
skill->mAccess*(mCLevel+1)/4 > skill->mRanks)
{
menu.addItem (letter++, buf, skill);
navail++;
} else {
menu.addItem (0, buf, skill);
}
}
if (mSkillPoints && !navail) {
return;
}
int advanced = 0;
do {
i = menu.getResult ((const void **) &skill, NULL);
if (skill) {
--mSkillPoints;
skill->mRanks++;
advanced++;
}
} while (i && mSkillPoints);
if (!advanced)
return;
} while (mSkillPoints);
}