Module:Farming
From SWGoH Wiki
Jump to navigationJump to searchDocumentation for this module may be created at Module:Farming/doc
local call = {} function split(inputstr, sep) if sep == nil then sep = "," end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, trim(str)) end return t end function trim(s) return s:match( "^%s*(.-)%s*$" ) end function call.charFarm(a) locations = split(a.args[1],",") ignore = split(a.args.ignore,",") slot = a.args.slot rank = { galactic_war_store = 1, cantina_battle = 2, cantina_store = 3, arena_store = 4, guild_store = 5, fleet_store = 6, ls_battle = 7, ds_battle = 8, fleet_battle = 9, shard_shop = 10, event = 11, guild_event_store = 12 } rankFilled = { galactic_war_store = "", cantina_battle = "", cantina_store = "", arena_store = "", guild_store = "", fleet_store = "", ls_battle = "", ds_battle = "", fleet_battle = "", shard_shop = "", event = "", guild_event_store = "" } result = "" locRank = {} if(table.maxn(locations) == 1) then if(slot == "Best") then result = "[["..locations[1].."]]" else result = "na" end else for i,loc in ipairs(locations) do locRank[i] = {} if(string.find(loc, "Galactic War") ~= nil) then if(rankFilled["galactic_war_store"] == "") then locRank[i].rank = 1 locRank[i].pos = i rankFilled["galactic_war_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Cantina Battles Store") ~= nil) then if(rankFilled["cantina_store"] == "") then locRank[i].rank = 3 locRank[i].pos = i rankFilled["cantina_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Cantina Battle") ~= nil) then if(rankFilled["cantina_battle"] == "") then locRank[i].rank = 2 locRank[i].pos = i rankFilled["cantina_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Squad Arena") ~= nil) then if(rankFilled["arena_store"] == "") then locRank[i].rank = 4 locRank[i].pos = i rankFilled["arena_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Guild Store") ~= nil) then if(rankFilled["guild_store"] == "") then locRank[i].rank = 5 locRank[i].pos = i rankFilled["guild_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Fleet Arena") ~= nil) then if(rankFilled["fleet_store"] == "") then locRank[i].rank = 6 locRank[i].pos = i rankFilled["fleet_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Light Side") ~= nil) then if(rankFilled["ls_battle"] == "") then locRank[i].rank = 7 locRank[i].pos = i rankFilled["ls_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Dark Side") ~= nil) then if(rankFilled["ds_battle"] == "") then locRank[i].rank = 8 locRank[i].pos = i rankFilled["ds_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Fleet Battle") ~= nil) then if(rankFilled["fleet_battle"] == "") then locRank[i].rank = 9 locRank[i].pos = i rankFilled["fleet_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Shard Shop") ~= nil) then if(rankFilled["shard_shop"] == "") then locRank[i].rank = 10 locRank[i].pos = i rankFilled["shard_shop"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Guild Event") ~= nil) then if(rankFilled["guild_event_store"] == "" and table.maxn(locations) == 2) then locRank[i].rank = 12 locRank[i].pos = i rankFilled["guild_event_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end else if(string.find(loc, "Shipment") == nil) then if(table.maxn(locations) == 2) then if(rankFilled["event"] == "") then locRank[i].rank = 11 locRank[i].pos = i rankFilled["event"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end else locRank[i].rank = 13 locRank[i].pos = i end else locRank[i].rank = 14 locRank[i].pos = i end end end end table.sort(locRank, function( a,b ) --if (a.rank < b.rank) then -- return true --elseif (a.rank > b.rank) then -- return false --else return a.rank < b.rank --end end) remove = false if(table.maxn(locations) > 1) then if(slot == "Best") then return "[["..locations[locRank[1].pos].."]]" elseif(slot == "Better") then if(locRank[2].rank > 12) then return "na" else for i,content in ipairs(ignore) do if(content == locations[locRank[2].pos]) then remove = true end end if(remove) then return "na" else return "[["..locations[locRank[2].pos].."]]" end end elseif(slot == "Decent") then if(table.maxn(locations) > 2) then if(locRank[3].rank > 12) then return "na" else for i,content in ipairs(ignore) do if(content == locations[locRank[3].pos]) then remove = true end end if(remove) then return "na" else return "[["..locations[locRank[3].pos].."]]" end end else return "na" end end end return result end function call.shipFarm(a) locations = split(a.args[1],",") ignore = split(a.args.ignore,",") slot = a.args.slot rank = { galactic_war_store = 1, cantina_battle = 2, cantina_store = 3, arena_store = 4, guild_store = 5, fleet_store = 6, fleet_battle = 7, ls_battle = 8, ds_battle = 9, shard_shop = 10, event = 11, guild_event_store = 12 } rankFilled = { galactic_war_store = "", cantina_battle = "", cantina_store = "", arena_store = "", guild_store = "", fleet_store = "", ls_battle = "", ds_battle = "", fleet_battle = "", shard_shop = "", event = "", guild_event_store = "" } result = "" locRank = {} if(table.maxn(locations) == 1) then if(slot == "Best") then result = "[["..locations[1].."]]" else result = "na" end else for i,loc in ipairs(locations) do locRank[i] = {} if(string.find(loc, "Galactic War") ~= nil) then if(rankFilled["galactic_war_store"] == "") then locRank[i].rank = 1 locRank[i].pos = i rankFilled["galactic_war_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Cantina Battles Store") ~= nil) then if(rankFilled["cantina_store"] == "") then locRank[i].rank = 3 locRank[i].pos = i rankFilled["cantina_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Cantina Battle") ~= nil) then if(rankFilled["cantina_battle"] == "") then locRank[i].rank = 2 locRank[i].pos = i rankFilled["cantina_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Squad Arena") ~= nil) then if(rankFilled["arena_store"] == "") then locRank[i].rank = 4 locRank[i].pos = i rankFilled["arena_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Guild Store") ~= nil) then if(rankFilled["guild_store"] == "") then locRank[i].rank = 5 locRank[i].pos = i rankFilled["guild_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Fleet Arena") ~= nil) then if(rankFilled["fleet_store"] == "") then locRank[i].rank = 6 locRank[i].pos = i rankFilled["fleet_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Light Side") ~= nil) then if(rankFilled["ls_battle"] == "") then locRank[i].rank = 8 locRank[i].pos = i rankFilled["ls_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Dark Side") ~= nil) then if(rankFilled["ds_battle"] == "") then locRank[i].rank = 9 locRank[i].pos = i rankFilled["ds_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Fleet Battle") ~= nil) then if(rankFilled["fleet_battle"] == "") then locRank[i].rank = 7 locRank[i].pos = i rankFilled["fleet_battle"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Shard Shop") ~= nil) then if(rankFilled["shard_shop"] == "") then locRank[i].rank = 10 locRank[i].pos = i rankFilled["shard_shop"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end elseif(string.find(loc, "Guild Event") ~= nil) then if(rankFilled["guild_event_store"] == "" and table.maxn(locations) == 2) then locRank[i].rank = 12 locRank[i].pos = i rankFilled["guild_event_store"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end else if(string.find(loc, "Shipment") == nil) then if(table.maxn(locations) == 2) then if(rankFilled["event"] == "") then locRank[i].rank = 11 locRank[i].pos = i rankFilled["event"] = "Yes" else locRank[i].rank = 13 locRank[i].pos = i end else locRank[i].rank = 13 locRank[i].pos = i end else locRank[i].rank = 14 locRank[i].pos = i end end end end table.sort(locRank, function( a,b ) --if (a.rank < b.rank) then -- return true --elseif (a.rank > b.rank) then -- return false --else return a.rank < b.rank --end end) remove = false if(table.maxn(locations) > 1) then if(slot == "Best") then return "[["..locations[locRank[1].pos].."]]" elseif(slot == "Better") then if(locRank[2].rank > 12) then return "na" else for i,content in ipairs(ignore) do if(content == locations[locRank[2].pos]) then remove = true end end if(remove) then return "na" else return "[["..locations[locRank[2].pos].."]]" end end elseif(slot == "Decent") then if(table.maxn(locations) > 2) then if(locRank[3].rank > 12) then return "na" else for i,content in ipairs(ignore) do if(content == locations[locRank[3].pos]) then remove = true end end if(remove) then return "na" else return "[["..locations[locRank[3].pos].."]]" end end else return "na" end end end return result end return call