Skip to content

Commit 9526e01

Browse files
committed
Use class-based action point values
Closes #266.
1 parent ad8b014 commit 9526e01

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

res/data/creatures/classes.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ return {
55
'body_human'
66
},
77
stats = {
8+
ap = 40,
89
hp = 8
910
}
1011
},
@@ -14,6 +15,7 @@ return {
1415
'body_human'
1516
},
1617
stats = {
18+
ap = 30,
1719
hp = 5
1820
}
1921
},
@@ -23,6 +25,7 @@ return {
2325
'body_dog'
2426
},
2527
stats = {
28+
ap = 20,
2629
hp = 4
2730
}
2831
}

src/characters/Character.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ local Character = MapObject:subclass( 'Character' )
2323
-- Constants
2424
-- ------------------------------------------------
2525

26-
local DEFAULT_ACTION_POINTS = 40
27-
2826
local STANCES = require( 'src.constants.STANCES' )
2927
local ITEM_TYPES = require( 'src.constants.ITEM_TYPES' )
3028

@@ -116,12 +114,14 @@ end
116114
-- Public Methods
117115
-- ------------------------------------------------
118116

119-
function Character:initialize( classID )
117+
function Character:initialize( classID, actionPoints )
120118
MapObject.initialize( self )
121119

122120
self.creatureClass = classID
123121

124-
self.actionPoints = DEFAULT_ACTION_POINTS
122+
self.maxActionPoints = actionPoints
123+
self.actionPoints = actionPoints
124+
125125
self.actions = Queue()
126126

127127
self.fov = {}
@@ -240,7 +240,7 @@ end
240240
-- Resets the character's action points to the default value.
241241
--
242242
function Character:resetActionPoints()
243-
self.actionPoints = DEFAULT_ACTION_POINTS
243+
self.actionPoints = self.maxActionPoints
244244
end
245245

246246
---
@@ -451,7 +451,7 @@ end
451451
-- @treturn number The total amount of action points.
452452
--
453453
function Character:getMaxActionPoints()
454-
return DEFAULT_ACTION_POINTS
454+
return self.maxActionPoints
455455
end
456456

457457
---

src/characters/CharacterFactory.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ end
197197
function CharacterFactory.newCharacter( factionType )
198198
local classID = pickCreatureClass( factionType )
199199
local class = findClass( classID )
200-
local character = Character( classID )
200+
local character = Character( classID, class.stats.ap )
201201

202202
local bodyType = Util.pickRandomValue( class.body )
203203
if bodyType == 'body_human' then

0 commit comments

Comments
 (0)