Line 237: |
Line 237: |
| end | | end |
| end | | end |
− | | + | else |
| + | break |
| end | | end |
| end | | end |
Line 254: |
Line 255: |
| ["Air Supremacy"] = false, | | ["Air Supremacy"] = false, |
| ["Air Superiority"] =false} | | ["Air Superiority"] =false} |
− | local validNodeLetters = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} | + | local validNodeLetters = {["A"]=true, |
| + | ["B"]=true, |
| + | ["C"]=true, |
| + | ["D"]=true, |
| + | ["E"]=true, |
| + | ["F"]=true, |
| + | ["G"]=true, |
| + | ["H"]=true, |
| + | ["I"]=true, |
| + | ["J"]=true, |
| + | ["K"]=true, |
| + | ["L"]=true, |
| + | ["M"]=true, |
| + | ["N"]=true, |
| + | ["O"]=true, |
| + | ["P"]=true, |
| + | ["Q"]=true, |
| + | ["R"]=true, |
| + | ["S"]=true, |
| + | ["T"]=true, |
| + | ["U"]=true, |
| + | ["V"]=true, |
| + | ["W"]=true, |
| + | ["X"]=true, |
| + | ["Y"]=true, |
| + | ["Z"]=true} |
| -- map all the nodes we'll be using into mapEncounterTable -> {"A":true,"B"=true} etc | | -- map all the nodes we'll be using into mapEncounterTable -> {"A":true,"B"=true} etc |
| for k,v in pairs(frame.args) do | | for k,v in pairs(frame.args) do |
| if string.lower(k) ~= "boss_node" and string.lower(k) ~= "final_form" then | | if string.lower(k) ~= "boss_node" and string.lower(k) ~= "final_form" then |
− | for i,letter in pairs(validNodeLetters) do | + | local letter = mw.text.split(k,"")[1] |
− | local split = mw.text.split(k,"_")
| + | local num = mw.text.split(k,"")[2] |
− | if valid(letter,mw.text.split(string.upper(split[1]),"")) then
| + | if validNodeLetters[letter] and tonumber(num) ~= nil then |
− | mapEncounterTable[letter] = {}
| + | mapEncounterTable[letter] = {} |
− | if letter>bossNode then
| + | if letter>bossNode then |
− | bossNode = letter
| + | bossNode = letter |
− | end
| |
| end | | end |
| end | | end |
Line 286: |
Line 311: |
| -- nodePattern should be like A1_xp, B3_lv, C1_form or something | | -- nodePattern should be like A1_xp, B3_lv, C1_form or something |
| for nodePattern,patternInfo in pairs(frame.args) do | | for nodePattern,patternInfo in pairs(frame.args) do |
− | -- letter is the letter of a valid node we have | + | local letter = mw.text.split(nodePattern,"")[1] |
− | for letter,_ in pairs(mapEncounterTable) do
| + | if mapEncounterTable[letter] ~= nil and nodePattern ~= "final_form" then |
− | -- if letter is equal to the first letter in nodePattern,
| + | if mw.text.split(nodePattern,"")[2] ~= "_" then |
− | if letter == mw.text.split(string.upper(nodePattern),"")[1] and nodePattern ~= "final_form" and nodePattern ~= nil then
| + | local patternNum = mw.text.split(mw.text.split(nodePattern,"_")[1],"")[2] |
− | if mw.text.split(nodePattern,"")[2] ~= "_" then
| |
− | local patternNum = mw.text.split(mw.text.split(nodePattern,"_")[1],"")[2]
| |
| | | |
− | -- If the second char is not a number, invalid.
| + | -- If the second char is not a number, invalid. |
− | if tonumber(patternNum) == nil and nodePattern ~= "final_form" then
| + | if tonumber(patternNum) == nil and nodePattern ~= "final_form" then |
− | --return patternNum
| + | --return patternNum |
− | return "<span style='color:red'>Please check your module invocation arguments. Something is invalid</span>"
| + | return "<span style='color:red'>Please check your module invocation arguments. Something is invalid</span>" |
− | end
| + | end |
− | patternNum = tonumber(patternNum)
| + | patternNum = tonumber(patternNum) |
− | local nodePatternSplit = mw.text.split(nodePattern,"_")
| + | local nodePatternSplit = mw.text.split(nodePattern,"_") |
− | local paramName = ""
| + | local paramName = "" |
| | | |
− | -- get the parameter name, eg A1_xp's param name is just "Xp"
| + | -- get the parameter name, eg A1_xp's param name is just "Xp" |
− | -- B3_form's param name is just "Form"
| + | -- B3_form's param name is just "Form" |
− | -- notice the conversion of capitalization
| + | -- notice the conversion of capitalization |
− | if nodePatternSplit ~= nil then
| + | if nodePatternSplit ~= nil then |
− | for i = 2, #nodePatternSplit do
| + | for i = 2, #nodePatternSplit do |
− | paramName = paramName .. capitalize(nodePatternSplit[i])
| + | paramName = paramName .. capitalize(nodePatternSplit[i]) |
− | if i ~= #nodePatternSplit then
| + | if i ~= #nodePatternSplit then |
− | paramName = paramName .. " "
| + | paramName = paramName .. " " |
− | end
| |
| end | | end |
| end | | end |
− | if mapEncounterTable[letter][patternNum] == nil then
| |
− | -- skeleton table for info for each pattern at a node.
| |
− | -- eg, pattern 1 at node A, pattern 3 at node C, etc all need
| |
− | -- the xp, lv, form, etc info
| |
− | local nodePatternInfo = {["Xp"] = "",
| |
− | ["Lv"] = "",
| |
− | ["Node Info"] = "",
| |
− | ["Form"] = "",
| |
− | ["Air Supremacy"] = "",
| |
− | ["Air Superiority"] = ""}
| |
− | mapEncounterTable[letter][patternNum] = nodePatternInfo
| |
− | end
| |
− | mapEncounterTable[letter][patternNum][paramName] = patternInfo
| |
− | usedParams[paramName] = true
| |
| end | | end |
− | local split = mw.text.split(nodePattern,"_") | + | if mapEncounterTable[letter][patternNum] == nil then |
− | if split[2] == "label" then
| + | -- skeleton table for info for each pattern at a node. |
− | local letter = string.upper(mw.text.split(split[1],"")[1])
| + | -- eg, pattern 1 at node A, pattern 3 at node C, etc all need |
− | mapEncounterTable[letter]["label"] = patternInfo | + | -- the xp, lv, form, etc info |
| + | local nodePatternInfo = {["Xp"] = "", |
| + | ["Lv"] = "", |
| + | ["Node Info"] = "", |
| + | ["Form"] = "", |
| + | ["Air Supremacy"] = "", |
| + | ["Air Superiority"] = ""} |
| + | mapEncounterTable[letter][patternNum] = nodePatternInfo |
| end | | end |
| + | mapEncounterTable[letter][patternNum][paramName] = patternInfo |
| + | usedParams[paramName] = true |
| + | end |
| + | local split = mw.text.split(nodePattern,"_") |
| + | if split[2] == "label" then |
| + | local letter = string.upper(mw.text.split(split[1],"")[1]) |
| + | mapEncounterTable[letter]["label"] = patternInfo |
| end | | end |
| end | | end |
Line 339: |
Line 361: |
| if frame.args["final_form"] ~= nil then | | if frame.args["final_form"] ~= nil then |
| local nodeAndPatterns = mw.text.split(frame.args["final_form"]," ") | | local nodeAndPatterns = mw.text.split(frame.args["final_form"]," ") |
− | for _,nodePattern in pairs(nodeAndPatterns) do | + | for _,nodePattern in pairs(nodeAndPatterns) do |
− | for _,validLetter in pairs(validNodeLetters) do | + | local nodeLetter = mw.text.split(nodePattern,"")[1] |
− | if validLetter == mw.text.split(nodePattern,"")[1] then
| + | if validNodeLetters[nodeLetter] then |
− | local patternNum = mw.text.split(nodePattern,"")[2]
| + | local patternNum = mw.text.split(nodePattern,"")[2] |
− | if tonumber(patternNum) ~= nil then
| + | if tonumber(patternNum) ~= nil then |
− | patternNum = tonumber(patternNum)
| + | patternNum = tonumber(patternNum) |
− | | + | if mapEncounterTable[validLetter][patternNum] ~= nil then |
− | if mapEncounterTable[validLetter][patternNum] ~= nil then
| + | mapEncounterTable[validLetter][patternNum]["isFinalForm"] = true |
− | mapEncounterTable[validLetter][patternNum]["isFinalForm"] = true
| |
− | end
| |
| end | | end |
| end | | end |