#!/usr/bin/env ruby -w require 'net/http' # WoWhead URL Format http://www.wowhead.com/?object=xxxxx # Data is embeded as arry of arrays within a javascript call # return mp_Embed('Searing Gorge',[[56,76.6],[64.6,49.1],[66.2,37.7],[68,75.1]],this) module LuaRuby def ruby_to_lua(v) if v=~ /\D+/ return "\"#{v}\"" else return v end end end # Add to_lua method to hash and array class Array include LuaRuby def to_lua(depth=1) result = "{" each {|v| if v.instance_of? Array result << v.to_lua(depth+1) elsif v.instance_of? Hash result << v.to_lua(depth+1) else myval = ruby_to_lua(v) result << "\"#{myval}\"," end } result << "}\n" return result end end class Hash include LuaRuby def to_lua(depth=1) # code here to generate lua out result = ("\t" * depth) +"{\n" keys.each {|k| mykey = ruby_to_lua(k) myval = fetch(k) if mykey.to_s.length <= 0 next end if myval.instance_of? Hash result << ("\t" * depth) + "[#{mykey}] = \n" + myval.to_lua(depth+1) elsif myval.instance_of? Array result << ("\t" * depth) + "[#{mykey}] = \n" + myval.to_lua(depth+1) else myval = ruby_to_lua(myval) result << ("\t" * depth)+ "[#{mykey}] = #{myval},\n" end } comma = "" if depth > 1 comma = "," end return result << ("\t" * depth) + "}#{comma}\n" end end def javascript_to_ruby(d) #d.gsub!("Ahn'kahet: The Old Kingdom","Ahn'kahet, The Old Kingdom") #return eval(d.gsub(/\w+:\s/) { |key| key.gsub!(/:/,''); key.gsub!(/\'\"/,'\''); key.lstrip!;key.rstrip!; key = "\"#{key}\"=>"}) return eval(d.gsub(/\w+:\s(?=[\"|\d|\[])/) { |key| key.gsub!(/:/,''); key.lstrip!; key.rstrip!; key = "\"#{key}\"=>"}) end # # $zone_map = { "Arathi Highlands" => 1, "Orgrimmar" => 2, "Eastern Kingdoms" => 3, "Undercity" => 4, "The Barrens" => 5, "Darnassus" => 6, "Azuremyst Isle" => 7, "Un'Goro Crater" => 8, "Burning Steppes" => 9, "Wetlands" => 10, "Winterspring" => 11, "Dustwallow Marsh" => 12, "Darkshore" => 13, "Loch Modan" => 14, "Blade's Edge Mountains" => 15, "Durotar" => 16, "Silithus" => 17, "Shattrath City" => 18, "Ashenvale" => 19, "Azeroth" => 20, "Nagrand" => 21, "Terokkar Forest" =>22, "Eversong Woods" =>23, "Silvermoon City" => 24, "Tanaris" => 25, "Stormwind City" => 26, "Swamp of Sorrows" => 27, "Eastern Plaguelands" => 28, "Blasted Lands" => 29, "Elwynn Forest" => 30, "Deadwind Pass" => 31, "Dun Morogh" => 32, "The Exodar" => 33, "Felwood" => 34, "Silverpine Forest" => 35, "Thunder Bluff" => 36, "The Hinterlands" => 37, "Stonetalon Mountains" => 38, "Mulgore" => 39, "Hellfire Peninsula" => 40, "Ironforge" => 41, "Thousand Needles" => 42, "Stranglethorn Vale" => 43, "Badlands" => 44, "Teldrassil" => 45, "Moonglade" => 46, "Shadowmoon Valley" =>47, "Tirisfal Glades" => 48, "Azshara" => 49, "Redridge Mountains" => 50, "Bloodmyst Isle" => 51, "Western Plaguelands" => 52, "Alterac Mountains" => 53, "Westfall" => 54, "Duskwood" => 55, "Netherstorm" => 56, "Ghostlands" => 57, "Zangarmarsh" => 58, "Desolace" => 59, "Kalimdor" => 60, "Searing Gorge" => 61, "Outland" => 62, "Feralas" => 63, "Hillsbrad Foothills" => 64, "Isle of Quel'Danas" => 65, "Borean Tundra" => 67, "Crystalsong Forest" => 77, "Dragonblight" => 68, "Grizzly Hills" => 69, "Howling Fjord" => 70, "Icecrown" => 71, "Sholazar Basin" => 72, "The Storm Peaks" => 73, "Wintergrasp" => 78, "Zul'Drak" => 74, } $rare_map = { 204 => [202,203], # silver 205 => [203,206], # gold 208 => [206,214,215], # truesilver 209 => [212,213,207], # oozed covered silver 210 => [212,213,207], # ooze covered gold 211 => [212,213,207], # oozed covered true silver 217 => [206,214,215], # dark iron 224 => [222,223,221], # khorium 223 => [222], 441 => [440], #flame cap 229 => [228], # cobalt 232 => [231] # Saronite } $rare_src = { 202 => [204,203], 203 => [204,205], 206 => [208,217,205], 214 => [208,217], 215 => [208,217], 207 => [209,210,211], 212 => [209,210,211], 213 => [209,210,211], 440 => [441], 222 => [224,223], 223 => [224], 221 => [224], 228 => [229], 231 => [232] } # mieral viens mineral_map = { "Copper Vein" => [1731,201], "Incendicite Mineral Vein" => [1610,219], "Tin Vein" => [1732,202], "Lesser Bloodstone Deposit" => [2653,218], "Iron Deposit" => [1735,203], "Mithril Deposit" => [2040,206], "Ooze Covered Mithril Deposit" => [123310,207], "Small Thorium Vein" => [324,214], "Ooze Covered Thorium Vein" => [123848,213], "Rich Thorium Vein" => [175404,215], "Fel Iron Deposit" => [181555,221], "Adamantite Deposit" => [181556,222], "Rich Adamantite Deposit" => [181569,223], "Khorium Vein" => [181557,224], "Nethercite Deposit" => [185877,227], # rare nodes below "Silver Vein" => [1733,204], "Ooze Covered Silver Vein" => [73940,209], "Ooze Covered Rich Thorium Vein" => [177388,212], "Dark Iron Deposit" => [165658,217], "Truesilver Deposit" => [2047,208], "Ooze Covered Truesilver Deposit" => [123309,211], "Gold Vein" => [1734,205], "Ooze Covered Gold Vein" => [73941,210], "Cobalt Deposit" => [189978,228], "Rich Cobalt Deposit" => [189979,229], "Titanium Vein" => [191133,230], "Saronite Deposit" => [189980,231], "Rich Saronite Deposit" => [189981,232] } # Herbs herb_map = { "Silverleaf" => [1617,402], "Peacebloom" => [1618,401], "Bloodthistle" => [181166,436], "Earthroot" => [1619,403], "Mageroyal" => [1620,404], "Briarthorn" => [1621,405], "Stranglekelp" => [2045,407], "Bruiseweed" => [1622,408], "Wild Steelbloom" => [1623,409], "Grave Moss" => [1628,410], "Kingsblood" => [1624,411], "Liferoot" => [2041,412], "Fadeleaf" => [2042,413], "Goldthorn" => [2046,414], "Khadgar's Whisker" => [2043,415], "Wintersbite" => [2044,416], "Firebloom" => [2866,417], "Purple Lotus" => [142140,418], "Arthas' Tears" => [142141,420], "Sungrass" => [142142,421], "Blindweed" => [142143,422], "Ghost Mushroom" => [142144,423], "Gromsblood" => [142145,424], "Golden Sansam" => [176583,425], "Dreamfoil" => [176584,426], "Mountain Silversage" => [176586,427], "Plaguebloom" => [176587,428], "Icecap" => [176588,429], "Black Lotus" => [176589,431], "Felweed" => [181270,432], "Dreaming Glory" => [181271,433], "Terocone" => [181277,434], "Ragveil" => [181275,440], "Flame Cap" => [181276,441], "Netherbloom" => [181279,438], "Nightmare Vine" => [181280,439], "Mana Thistle" => [181281,437], "Netherdust Bush" => [185881,442], "Icethorn" => [190172,447], "Lichbloom" => [190171,448], "Tiger Lily" => [190169,450], "Frozen Herb" => [190173,452], "Adder's Tongue" => [191019,443], "Talandra's Rose" => [190170,449], "Firethorn" => [191303,451], "Goldclover" => [189973,446] } treasure_map = { "Giant Clam" => [2744,501], "Battered Chest" => [2843,502], "Tattered Chest" => [2844,503], "Solid Chest" => [2850,504], "Large Iron Bound Chest" => [74447,505], "Large Solid Chest" => [74448,506], "Large Battered Chest" => [75293,507], "Buccaneer's Strongbox" => [123330,508], "Large Mithril Bound Chest" => [153468,509], "Large Darkwood Chest" => [131979,510], "Un'Goro Dirt Pile" => [157936,511], "Bloodpetal Sprout" => [164958,512], "Blood of Heroes" => [176213,513], "Practice Lockbox" => [178244,514], "Battered Footlocker" => [179488,515], "Waterlogged Footlocker" => [179487,516], "Dented Footlocker" => [179496,517], "Mossy Footlocker" => [179497,518], "Scarlet Footlocker" => [179498,519], "Burial Chest" => [181665,520], "Fel Iron Chest" => [181798,521], "Heavy Fel Iron Chest" => [181800,522], "Adamantite Bound Chest" => [181802,523], "Felsteel Chest" => [181804,524], "Glowcap" => [182053,525], "Wicker Chest" => [184740,526], "Primitive Chest" => [184793,527], "Solid Fel Iron Chest" => [184930,528], "Bound Fel Iron Chest" => [184931,529], "Bound Adamantite Chest" => [184936,530], "Netherwing Egg" => [185915,531], "Everfrost Chip" => [193997,532] } # utility function def gather_coords(x,y) trim_terminator = 7 if y == 100 y = 99.9 end if x == 100 x = 99.9 end id = (x * 10000 + 0.5).floor * 10000 + (y * 10000 + 0.5).floor return id/100 end def get_wowdbdata(id) response = Net::HTTP.get(URI.parse("http://www.wowdb.com/object.aspx?id=#{id}")) unless response raise "Data not available for id #{id}" end lst = response.scan(/