Merge pull request #194 from argonui/weakness-finder

Remove area check when drawing a random weakness
This commit is contained in:
Chr1Z 2023-01-16 12:11:05 +01:00 committed by GitHub
commit 99cf04761e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,3 @@
-- Position to check for weaknesses. Everything with X and Z less
-- than these values (down and right on the table) will be checked
local WEAKNESS_CHECK_X = 15
local WEAKNESS_CHECK_Z = 37
local cardIdIndex = { } local cardIdIndex = { }
local classAndLevelIndex = { } local classAndLevelIndex = { }
local basicWeaknessList = { } local basicWeaknessList = { }
@ -311,12 +305,12 @@ function buildAvailableWeaknesses()
local weaknessesInPlay = { } local weaknessesInPlay = { }
local allObjects = getAllObjects() local allObjects = getAllObjects()
for _, object in ipairs(allObjects) do for _, object in ipairs(allObjects) do
if (object.name == "Deck" and isInPlayArea(object)) then if (object.name == "Deck") then
for _, cardData in ipairs(object.getData().ContainedObjects) do for _, cardData in ipairs(object.getData().ContainedObjects) do
local cardMetadata = JSON.decode(cardData.GMNotes) local cardMetadata = JSON.decode(cardData.GMNotes)
incrementWeaknessCount(weaknessesInPlay, cardMetadata) incrementWeaknessCount(weaknessesInPlay, cardMetadata)
end end
elseif (object.name == "Card" and isInPlayArea(object)) then elseif (object.name == "Card") then
local cardMetadata = JSON.decode(object.getGMNotes()) local cardMetadata = JSON.decode(object.getGMNotes())
incrementWeaknessCount(weaknessesInPlay, cardMetadata) incrementWeaknessCount(weaknessesInPlay, cardMetadata)
end end
@ -352,15 +346,6 @@ function incrementWeaknessCount(table, cardMetadata)
end end
end end
function isInPlayArea(object)
if (object == nil) then
return false
end
local position = object.getPosition()
return position.x < WEAKNESS_CHECK_X
and position.z < WEAKNESS_CHECK_Z
end
function isBasicWeakness(cardMetadata) function isBasicWeakness(cardMetadata)
return cardMetadata ~= nil return cardMetadata ~= nil
and cardMetadata.weakness and cardMetadata.weakness