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 {
ko = {
temporary = false,
replaceAll = true
},
hidden = {
{"evasion", 30},
stats = {{"evasion", 30}},
},
focus = {
{"critical", 30},
stats = {{"critical", 30}},
remove = "distracted"
},
shielded = {
{"armor", 20}
stats = {{"armor", 20}},
remove = "vulnerable"
},
hyper = {
stats = {
{"damage", 25},
{"critical", 20}
},
remove = "weakened"
},
lucky = {
stats = {
{"evasion", 20},
{"luck", 20},
},
remove = "cursed"
},
regen = {
{"hpregen", 8}
stats = {{"hpregen", 8}}
},
poison = {
{"hpregen", -15}
stats = {{"hpregen", -15}}
},
weakened = {
{"damage", -20}
stats = {{"damage", -20}},
remove = "hyper"
},
vulnerable = {
{"armor", -20}
stats = {{"armor", -20}}
},
cursed = {
stats = {
{"evasion", 0},
{"luck", -30}
},
remove = "lucky"
},
distracted = {
{"accuracy", -30}
stats = {{"accuracy", -30}},
remove = "focus"
}
}

View file

@ -69,23 +69,12 @@ function AbstractMobParent:getStats()
return self.stats
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
function AbstractMobParent:addStatut(name, duration)
function AbstractMobParent:addStatut(name, duration, source)
local duration = duration or -1
self.statuts[name] = duration
self.statuts[name] = {}
self.statuts[name].duration = duration
end
function AbstractMobParent:haveStatuts(statutName)
@ -109,13 +98,30 @@ function AbstractMobParent:isAlive()
end
function AbstractMobParent:removeOneTurnToStatut()
for name, duration in pairs(self.statuts) do
if (duration == 1) then
for name, statut in pairs(self.statuts) do
if (statut ~= nil) then
if (statut.duration == 1) then
self.statuts[name] = nil
else
self.statuts[name] = (duration - 1)
self.statuts[name].duration = (statut.duration - 1)
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