-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRunState.lua
More file actions
45 lines (38 loc) · 1.11 KB
/
RunState.lua
File metadata and controls
45 lines (38 loc) · 1.11 KB
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
RunState = {}
RunState.__index = RunState
function RunState:new()
local rs = setmetatable({}, self)
rs.active = false
rs.stageIndex = 0
rs.stages = {}
rs.playerCharacterName = nil
return rs
end
-- Initialize a new run with a simple linear list of encounters
-- opponentNames: array of character names for opponents (e.g., {"wizard", "wizard", ...})
function RunState:startRun(playerCharacterName, opponentNames)
self.active = true
self.playerCharacterName = playerCharacterName
self.stages = opponentNames or { "wizard", "wizard", "wizard", "wizard", "wizard" }
self.stageIndex = 1
end
function RunState:isActive()
return self.active == true
end
function RunState:getCurrentOpponent()
if not self:isActive() then return nil end
return self.stages[self.stageIndex]
end
function RunState:hasNextStage()
return self:isActive() and self.stageIndex < #self.stages
end
function RunState:advanceStage()
if self:hasNextStage() then
self.stageIndex = self.stageIndex + 1
return true
end
return false
end
function RunState:endRun()
self.active = false
end