Merge pull request #1259 from AtomicChicken/syndrome-util-updates

syndrome-util: added function to remove syndrome wound data
develop
Lethosor 2018-05-18 14:10:14 -04:00 committed by GitHub
commit 9ca79d050d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

@ -22,6 +22,15 @@ ResetPolicy = ResetPolicy or utils.invert({
"NewInstance"
})
function eraseSyndromeData(unit,syndromeId,oldestFirst)
for i = (oldestFirst and 0) or #unit.body.wounds-1,(oldestFirst and #unit.body.wounds-1) or 0,(oldestFirst and 1) or -1 do
if unit.body.wounds[i].syndrome_id == syndromeId then
unit.body.wounds:erase(i)
break
end
end
end
function eraseSyndrome(unit,syndromeId,oldestFirst)
local i1
local iN
@ -38,6 +47,7 @@ function eraseSyndrome(unit,syndromeId,oldestFirst)
local syndromes = unit.syndromes.active
for i=i1,iN,d do
if syndromes[i]['type'] == syndromeId then
eraseSyndromeData(unit,syndromeId,oldestFirst)
syndromes:erase(i)
return true
end
@ -50,6 +60,7 @@ local function eraseSyndromeClassHelper(unit,synclass)
local syndrome = df.syndrome.find(unitSyndrome.type)
for _,class in ipairs(syndrome.syn_class) do
if class.value == synclass then
eraseSyndromeData(unit,syndrome.id)
unit.syndromes.active:erase(i)
return true
end
@ -172,4 +183,3 @@ function infectWithSyndromeIfValidTarget(target,syndrome,resetPolicy)
end
return _ENV