feat: prepare for more complex statuses

This commit is contained in:
Kazhnuz 2021-08-13 19:25:26 +02:00
parent 6e93a11fef
commit a53e367e01
2 changed files with 56 additions and 33 deletions

View file

@ -1,38 +1,55 @@
return { return {
ko = {
temporary = false,
replaceAll = true
},
hidden = { hidden = {
{"evasion", 30}, stats = {{"evasion", 30}},
}, },
focus = { focus = {
{"critical", 30}, stats = {{"critical", 30}},
remove = "distracted"
}, },
shielded = { shielded = {
{"armor", 20} stats = {{"armor", 20}},
remove = "vulnerable"
}, },
hyper = { hyper = {
stats = {
{"damage", 25}, {"damage", 25},
{"critical", 20} {"critical", 20}
}, },
remove = "weakened"
},
lucky = { lucky = {
stats = {
{"evasion", 20}, {"evasion", 20},
{"luck", 20}, {"luck", 20},
}, },
remove = "cursed"
},
regen = { regen = {
{"hpregen", 8} stats = {{"hpregen", 8}}
}, },
poison = { poison = {
{"hpregen", -15} stats = {{"hpregen", -15}}
}, },
weakened = { weakened = {
{"damage", -20} stats = {{"damage", -20}},
remove = "hyper"
}, },
vulnerable = { vulnerable = {
{"armor", -20} stats = {{"armor", -20}}
}, },
cursed = { cursed = {
stats = {
{"evasion", 0}, {"evasion", 0},
{"luck", -30} {"luck", -30}
}, },
remove = "lucky"
},
distracted = { distracted = {
{"accuracy", -30} stats = {{"accuracy", -30}},
remove = "focus"
} }
} }

View file

@ -69,23 +69,12 @@ function AbstractMobParent:getStats()
return self.stats return self.stats
end end
function AbstractMobParent:getStatutsStat(statName)
local stat = 0
for statut, _ in pairs(self.statuts) do
for _, statutStat in ipairs(statutStatList[statut]) do
if (statutStat[1] == statName) then
stat = stat + statutStat[2]
end
end
end
return stat
end
-- STATUT HANDLING -- STATUT HANDLING
function AbstractMobParent:addStatut(name, duration) function AbstractMobParent:addStatut(name, duration, source)
local duration = duration or -1 local duration = duration or -1
self.statuts[name] = duration self.statuts[name] = {}
self.statuts[name].duration = duration
end end
function AbstractMobParent:haveStatuts(statutName) function AbstractMobParent:haveStatuts(statutName)
@ -109,13 +98,30 @@ function AbstractMobParent:isAlive()
end end
function AbstractMobParent:removeOneTurnToStatut() function AbstractMobParent:removeOneTurnToStatut()
for name, duration in pairs(self.statuts) do for name, statut in pairs(self.statuts) do
if (duration == 1) then if (statut ~= nil) then
if (statut.duration == 1) then
self.statuts[name] = nil self.statuts[name] = nil
else else
self.statuts[name] = (duration - 1) self.statuts[name].duration = (statut.duration - 1)
end
end end
end end
end end
function AbstractMobParent:getStatutsStat(statName)
local stat = 0
for statutName, _ in pairs(self.statuts) do
local statut = statutStatList[statutName]
if (statut ~= nil) then
for _, statutStat in ipairs(statut.stats) do
if (statutStat[1] == statName) then
stat = stat + statutStat[2]
end
end
end
end
return stat
end
return AbstractMobParent return AbstractMobParent