Fate-Grand-Order_Lua
Fate-Grand-Order_Lua copied to clipboard
Type Chains
Was just messing around with settings and I know that you guys are doing a major overhaul, I made a simple system for Type-Chains just thrown on top of your pre-existing code. Just thought I'd leave it here for you guys.
function doBattleLogic()
local cardStorage =
{
WB = {}, B = {}, RB = {},
WA = {}, A = {}, RA = {},
WQ = {}, Q = {}, RQ = {}
}
local WeakCards = {}
local BusterCards = {}
local ArtCards = {}
local QuickCards = {}
for cardSlot = 1, 5 do
local cardAffinity = checkCardAffin(CardAffinRegionArray[cardSlot])
local cardType = checkCardType(CardTypeRegionArray[cardSlot])
local cardScore = cardAffinity * cardType
if cardScore == WeakBuster then
table.insert(cardStorage.WB, cardSlot)
table.insert(WeakCards, cardSlot)
table.insert(BusterCards, cardSlot)
elseif cardScore == BCard then
table.insert(cardStorage.B, cardSlot)
table.insert(BusterCards, cardSlot)
elseif cardScore == ResistBuster then
table.insert(cardStorage.RB, cardSlot)
elseif cardScore == WeakArt then
table.insert(cardStorage.WA, cardSlot)
table.insert(WeakCards, cardSlot)
table.insert(ArtCards, cardSlot)
elseif cardScore == ACard then
table.insert(cardStorage.A, cardSlot)
table.insert(ArtCards, cardSlot)
elseif cardScore == ResistArt then
table.insert(cardStorage.RA, cardSlot)
elseif cardScore == WeakQuick then
table.insert(cardStorage.WQ, cardSlot)
table.insert(WeakCards, cardSlot)
table.insert(QuickCards, cardSlot)
elseif cardScore == QCard then
table.insert(cardStorage.Q, cardSlot)
table.insert(QuickCards, cardSlot)
else
table.insert(cardStorage.RQ, cardSlot)
end
end
local clickCount = 0
-- Battle Logic Start
if WeakCards[3] ~= nil then
for s, cardSlot in ipairs(WeakCards) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
elseif BusterCards[3] ~= nil then
for s, cardSlot in ipairs(BusterCards) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
elseif ArtCards[3] ~= nil then
for s, cardSlot in ipairs(ArtCards) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
elseif QuickCards[3] ~= nil then
for s, cardSlot in ipairs(QuickCards) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
else
for p, cardPriority in ipairs(CardPriorityArray) do
local currentStorage = cardStorage[cardPriority]
for s, cardSlot in pairs(currentStorage) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
if clickCount == 3 then
break
end
end
end
end
Just a light cleanup
local clickCount = 0
if WeakCards[3] ~= nil then
chainSelect(WeakCards)
elseif BusterCards[3] ~= nil then
chainSelect(BusterCards)
elseif ArtCards[3] ~= nil then
chainSelect(ArtCards)
elseif QuickCards[3] ~= nil then
chainSelect(QuickCards)
else
for p, cardPriority in ipairs(CardPriorityArray) do
local currentStorage = cardStorage[cardPriority]
for s, cardSlot in pairs(currentStorage) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
if clickCount == 3 then
break
end
end
end
function chainSelect(cardType)
local clickCount = 0
for s, cardSlot in ipairs(cardType) do
click(CardClickArray[cardSlot])
clickCount = clickCount + 1
if clickCount == 3 then
break
end
end
end