Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "json"
- # Getting skill names
- file = open("SkillName.json")
- json = file.read
- skillNames = JSON.parse(json)
- tabSkillNames = {}
- skillNames["infos"].each do |info|
- tabSkillNames[info["key"]] = info["value"]
- end
- # Getting skill descriptions
- file = open("SkillExpr.json")
- json = file.read
- skiExpr = JSON.parse(json)
- tabExpr = {}
- skiExpr["infos"].each do |info|
- tabExpr[info["key"]] = info["value"]
- end
- # Getting skills data
- file = open("Skill.json")
- json = file.read
- skills = JSON.parse(json)
- hash_skills = {}
- skills["items"].each do |item|
- hash_skills["#{item["iname"]}"] = item
- end
- # USELESS, no skill buff has a name
- # Getting buff names
- file = open("BuffName.json")
- json = file.read
- buffNames = JSON.parse(json)
- tabBuffNames = {}
- buffNames["infos"].each do |info|
- tabBuffNames[info["key"]] = info["value"]
- end
- # Getting buffs data
- file = open("Buff.json")
- json = file.read
- buffs = JSON.parse(json)
- hash_buffs = {}
- buffs["items"].each do |item|
- hash_buffs["#{item["iname"]}"] = item
- end
- # Getting unit names
- file = open("UnitName.json")
- json = file.read
- unitNames = JSON.parse(json)
- tabUnitNames = {}
- unitNames["infos"].each do |info|
- tabUnitNames[info["key"]] = info["value"]
- end
- # Buffs use a type and not a direct stat, this is annoying
- typebuff = []
- typebuff[1] = "Max HP"
- typebuff[21] = "ATK"
- typebuff[22] = "DEF"
- typebuff[23] = "MAG"
- typebuff[24] = "SPR"
- typebuff[25] = "DEX?"
- typebuff[26] = "AGI"
- typebuff[28] = "Move"
- typebuff[29] = "Jump"
- typebuff[88] = "Paralysis"
- typebuff[89] = "Confusion"
- typebuff[90] = "Charm"
- typebuff[92] = "Toad"
- typebuff[95] = "Haste"
- typebuff[96] = "Slow"
- typebuff[97] = "Stop"
- typebuff[98] = "Stun"
- typebuff[99] = "Immobilize"
- typebuff[100] = "Disable"
- typebuff[101] = "Berserk"
- typebuff[102] = "Doom"
- typebuff[105] = "Protect"
- typebuff[106] = "Shell"
- typebuff[112] = "Quicken"
- typebuff[156] = "Eva"
- typebuff[158] = "CRIT"
- typebuff[180] = "Hate"
- typebuff[181] = "Brave"
- typebuff[182] = "Faith (perma)"
- typebuff[193] = "Faith (temp)"
- descr= {"eff_val"=>" (L1)", "eff_val1" => " (L20)", "val1"=>" (L1)", "val11"=>" (L20)",
- "val2"=>" (L1)", "val21"=>" (L20)", "type1" => " (type)", "type2" => " (type2)", "eff_rate" => "% (L1)",
- "eff_rate1" => "% (L20)", "turn" => " turns", "ct_spd"=>" (CastSpd)", "ct_spd1"=>" (CSpdL20)", "rate"=>"%"}
- # Opening main files
- file = open("UnitAbilityBoard.json")
- json = file.read
- uab_json = JSON.parse(json)
- # Main loop: looping on all items (characters) in the json
- uab_json["items"].each do |item|
- # Name + iname
- puts ""
- puts ""
- puts "#{tabUnitNames[item["iname"]]};;;;#{item["iname"]}"
- # We may want to sort the skills before printing
- sk_char= []
- # Now looping on all the panels in the board
- item["panels"].each do |panel|
- # We're looking only for skill panels
- if panel["panel_effect_type"] == 1
- # I'm linking the panel to the skill, it may have useful info
- hash_skills["#{panel["value"]}"]["panel"] = panel
- # Pushing to array with every skills we want to print:
- sk_char.push(hash_skills["#{panel["value"]}"])
- end
- end
- # Sorting by job
- sk_char.sort_by! { |hash| [hash["panel"]["applicable_job"], hash["panel"]["panel_id"]] }
- # Now the printing part
- sk_char.each do |skill|
- # Skill job
- string = ";#{skill["panel"]["applicable_job"]};"
- # Skill name
- string += "#{tabSkillNames[skill["iname"]]};"
- # Well, I think it's more understandable with the base 100%
- for imp in ["eff_val","eff_val1"]
- val = 100 + skill[imp] if skill[imp] != nil
- string += "#{val}#{descr[imp]}" if skill[imp] != nil
- string += ";"
- end
- # important values, have their own private cell
- for imp in ["eff_rate","eff_rate1", "ct_spd", "ct_spd1"]
- string += "#{skill[imp]}#{descr[imp]}" if skill[imp] != nil
- string += ";"
- end
- # skill description + raw panel data
- string += ";#{tabExpr[skill["iname"]]};;;;#{skill["panel"]};"
- # A cell with all the raw skill data (removed panel for readability)
- skill["panel"] = nil
- string += "#{skill};"
- puts string
- # The skill may have BUFFs
- if skill["s_buffs"] != nil or skill["t_buffs"] != nil
- # concatenate 2 arrays (both can contain buffs), need to be sure not to have nil first
- skill["s_buffs"] = [] if skill["s_buffs"] == nil
- skill["t_buffs"] = [] if skill["t_buffs"] == nil
- buffs = skill["s_buffs"] | skill["t_buffs"]
- # Loop on all the buffs (iterate on both arrays)
- buffs.each do |buff_id|
- bstring = ";;;;"
- # Name of the buff, if available -there is never a buff name for skills-
- bstring += tabBuffNames[buff_id] != "" ? "#{tabBuffNames[buff_id]};" : "Buff;"
- # important values, have their own private cell
- for imp in ["rate", "turn","type1","val1","val11","type2","val2","val21"]
- value = hash_buffs[buff_id][imp]
- # If the buff use this parameter, print value
- if value != nil
- # Must do a special case for those
- if ["type1", "type2"].include?(imp) and typebuff[value] != nil
- value = typebuff[value] if value != nil and typebuff[value] != nil
- bstring += "#{value}"
- else
- # value + description
- bstring += "#{value}#{descr[imp]}"
- end
- end
- bstring += ";"
- end
- # raw data of the buff
- bstring += ";#{hash_buffs[buff_id]};"
- puts bstring
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement