-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCharacter.gd
310 lines (262 loc) · 7.88 KB
/
Character.gd
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# Character Class
extends Node
var AttributesObj = preload("res://Attributes.gd")
var InvObj = preload("res://Inventory.gd")
var Attributes = AttributesObj.new()
var Inventory = InvObj.new()
# Character defining attributes
var CharacterName = ""
var CharacterLevel = 0
var CharacterExperiencePoints = 0
var HitPoints = 0
var MaxHitPoints = 0
var AbilityPoints = 0
var MaxAbilityPoints = 0
var Potential = 0
var RecoveredHitPoints = 0
var RecoveredAbilityPoints = 0
# Constants
const MAX_LEVEL = 25
func _ready():
# Called every time the node is added to the scene.
# Initialization here
pass
func SetGameStartAttributes():
"""
Set up initial attributes for the character (stubbed function). You could
easily also do this in any Inherited or Reference class.
"""
# TODO
pass
func SetPlayerName(name):
"""
Set player name. If a value that is not a string, or an empty string is set,
the method returns false.
Keyword arguments:
name -- The name of the character in a String form. (Required)
"""
if typeof(name) != TYPE_STRING:
return false
if name.empty() == true:
return false
CharacterName = name
return CharacterName
func GetPlayerName():
"""
Returns player name.
"""
return CharacterName
func SetPrimaryStats(Const, Str, Int, Per, Prov):
"""
Set the player primary stats. All primary stats must be defined as
non negative integers, or else the method will return false. They can be
defined as zero.
For Information on the Primary Statistics, please see the documentation
in the `docs` folder.
Keyword arguments:
Const -- Representation of Constitution (Required)
Str -- Representation of Strength (Required)
Int -- Representation of Intelligence (Required)
Per -- Representation of Perception (Required)
Prov -- Representation of Providence (Required)
"""
if typeof(Const) != TYPE_INT \
and typeof(Str) != TYPE_INT \
and typeof(Int) != TYPE_INT \
and typeof(Per) != TYPE_INT \
and typeof(Prov) != TYPE_INT:
return false
if Const >= 0 \
and Str >= 0 \
and Int >= 0 \
and Per >= 0 \
and Prov >= 0:
return false
Attributes.set_constitution(Const)
Attributes.set_strength(Str)
Attributes.set_intelligence(Int)
Attributes.set_perception(Per)
Attributes.set_providence(Prov)
return true
func SetNonStatusDerivedStats():
"""
Sets all the derived statistics not HP or Ability Points
"""
# TODO
func SetHitPoints():
"""
Set the initial Hit Points on creation
"""
self.HitPoints = (Attributes.get_constitution() * 15) + floor((1.5 * Attributes.get_strength()))
self.MaxHitPoints = HitPoints
return self.HitPoints
func AddHitPoints(delta):
"""
Add hit points passed through as a delta. This operation is
intended to be used when Healing or Recovery operations are being used
by the player.
If the delta is not defined, or is a negative integer the
argument returns false.
If the delta leads the new total to exceed the maximum Hit Points
possible, then return the Maximum Hit Points.
Keyword arguments:
delta -- An integer representing Hit Points to be added to the
character (Required)
"""
if typeof(delta) == TYPE_INT and delta > -1:
RecoveredHitPoints = HitPoints + delta
if RecoveredHitPoints >= MaxHitPoints:
HitPoints = MaxHitPoints
return HitPoints
else:
HitPoints = RecoveredHitPoints
return HitPoints
else:
return false
func IncreaseHitPoints(delta):
"""
Add hit points passed through as a delta. This operation is
intended to be used when Leveling Up, or other stat-boosting
operations are being used by the player or the character. Any math that
must be run to calculate what the Delta is obviously needs to be done
before you run this method.
If the delta is not defined, the argument returns false.
Keyword arguments:
delta -- An integer representing Hit Points to be added to the
character. (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
MaxHitPoints = MaxHitPoints + delta;
HitPoints = MaxHitPoints
return HitPoints
else:
return false
func RemoveHitPoints(delta):
"""
Remove hit points passed through as a delta.
If delta is not defined, the argument returns false, changing nothing.
Keyword arguments:
delta -- An integer representing Hit Points to be removed from the
character. (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
HitPoints = HitPoints - delta
else:
return false
func GetCurrentHitPoints():
"""
Returns the current Hit Points for the Character
"""
return HitPoints
func GetMaxHitPoints():
"""
Returns the maximum number of Hit Points
"""
return MaxHitPoints
func SetAbilityPoints():
"""
Set the initial Ability Points on creation
"""
AbilityPoints = (4 * Attributes.get_intelligence()) + floor((1.5 * Attributes.get_perception()))
MaxAbilityPoints = AbilityPoints
return AbilityPoints
func AddAbilityPoints(delta):
"""
Add ability points passed through as a delta. This operations is
intended to be used when Recovery operations are being used by the
player.
If the delta is not defined, the argument returns false.
If the delta leads the new total to exceed the maximum Ability Points
possible, then return the Maximum Ability Points.
Keyword arguments:
delta -- An integer representing Ability Points to be added to the
character (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
RecoveredAbilityPoints = AbilityPoints + delta
if RecoveredAbilityPoints >= MaxAbilityPoints:
AbilityPoints = MaxAbilityPoints
return AbilityPoints
else:
AbilityPoints = RecoveredAbilityPoints
return HitPoints
else:
return false
func IncreaseAbilityPoints(delta):
"""
Add ability points passed through as a delta. This operation is
intended to be used when Leveling Up, or other stat-boosting
operations are being used by the player or the character. Any math that
must be run to calculate what the Delta is obviously needs to be done
before you run this method.
If the delta is not defined, the argument returns false.
Keyword arguments:
delta -- An integer representing Ability Points to be added to the
character. (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
MaxAbilityPoints = MaxAbilityPoints + delta;
AbilityPoints = MaxAbilityPoints
return AbilityPoints
else:
return false
func RemoveAbilityPoints(delta):
"""
Remove ability points passed through as a delta. If delta is not
defined, the argument returns false, changing nothing.
Keyword arguments:
delta -- An integer representing Ability Points to be removed
from the character. (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
AbilityPoints = AbilityPoints - delta;
return AbilityPoints;
else:
return false
func GetCurrentAbilityPoints():
"""
Returns the current total of Ability Points for the Character
"""
return AbilityPoints
func ReturnMaxAbilityPoints():
"""
Returns the Maximum available Ability Points
"""
return MaxAbilityPoints
func SetInitialCharacterLevel():
"""
Sets Character Level to 1
"""
CharacterLevel = 1
return CharacterLevel
func IncreaseCharacterLevel():
"""
Increments the Character Level by 1, unless it hits its potential max, 25.
"""
if CharacterLevel != MAX_LEVEL:
CharacterLevel = CharacterLevel + 1;
return CharacterLevel
func SetCharacterPotential():
"""
Calculates the Character's Potential. This operation is run when new
equipment is attached, a level is gained, and so forth.
"""
#TODO last method once the rest are in place.
func SetExperiencePoints():
"""
Sets Experience Points to 0, to start out with.
"""
CharacterExperiencePoints = 0;
func AddExperiencePoints(delta):
"""
Add experience points passed through as a delta. If delta is
not defined, the argument returns false, changing nothing.
Keyword arguments:
delta -- An integer representing Experience Points to be
added to the character. (Required)
"""
if typeof(delta) == TYPE_INT and delta >= 0:
CharacterExperiencePoints = CharacterExperiencePoints + delta;
return CharacterExperiencePoints;
else:
return false