User:Bock/Scripts

From The Mana World

itemdbtowiki doc

You can run itemdbtowiki to generate the wiki page. The usage is:

itemdbtowiki <item_db> <items.xml> [<mob_db>] [<translation.po>] > wikipage.txt

item_db may be as a single file or folder with files like item_db_*.txt.

items.xml may include link to other xml files. For example: <include name="items/usable/_include.xml"/>

mob_db optional parameter, may be as a single file or folder. If it is not specified, then in column "Rarity" willn't show chance of drop items from monsters. Default uses the file mob_db.txt, if it does not exist then search in the directory "items" splited files mob_db_*.txt.

translation.po special parameter, which can be transmitted regardless of other parameters. For greater efficiency must change "constants for translation" and "language code"


Note:

Download client data from [git]. Copy item_db _ *.txt and mob_db _ *.txt from [server-data] in the folder "items". Then put the script in the directory "tmwa-client-data-master" and run:

itemdbtowiki > wikipage.txt

If you use translation file, put it in the directory "tmwa-client-data-master" too and run script

itemdbtowiki translation_file.po > wikipage.txt

itemdbtowiki

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#Licensed under GNU General Public License

import sys, os, datetime, subprocess, glob, codecs;
import xml.parsers.expat

health_titles = ["Image","Name (ID)","HP Bonus","SP Bonus",
                 "BUY/Sell","Weight","Description", "Rarity"]
status_titles = ["Image","Name (ID)","BUY/Sell","Weight",
                 "Description", "Effect", "Rarity"]
weapon_titles = ["Image","Name (ID)","Damage","Range",
                 "BUY/Sell","Weight","Description", "Rarity"]
ammo_titles = ["Image","Name (ID)","Damage",
                 "BUY/Sell","Weight","Description", "Rarity"] 
armor_titles = ["Image", "Name (ID)", "Defense", 
              "BUY/Sell", "Weight", "Description", "Rarity"]
other_titles = ["Image","Name (ID)","BUY/Sell",
                "Weight","Description","Rarity"]

debug = 0

# print list of items for dyecmd
printdyed = 0

# language code
TCode = 'En:'

# constants for translation
MAtk = 'M. Attack'
MDef = 'M. Defense'
CDmg = 'Critical Damage'
CDef = 'Critical Defense'
SDmg = 'Damage'
SDef = 'Defense'
SRng = 'Range'
SStr = 'Strength'
SAgi = 'Agility'
SVit = 'Vitality'
SDex = 'Dexterity'
SInt = 'Intelligence'
SLuk = 'Luck'

RBuy = 'Buyable'
RCraft = 'Craftable'
RRDrop = 'Rare drop'
RFDrop = 'Frequent drop'
RColor = 'Colored'
RGMEvent = 'GM Event'

RSQuest = 'Special Quest'
RNlobt = 'No longer obtainable'
RUnobt = 'Unobtainable'
RTail = 'Tailorable'
RSpell = 'Spellable'
RQuest = 'Quest'
RIshi = 'Ishi'
RUnrel = 'Unreleased'

# table styles
tableborder = '{| style="width: 100%; border: 2px solid #99ee99; font-size:90%" cellspacing="2" cellpadding="3" align="center"'
tablehead = '! style="background:#99ee99;"'
tableheadf = '! style="background:#99ee99;width:65px"'
tableheadl = '! style="background:#99ee99;width:300px"'
tableroweven = '| style="background:#eeffee;"'
tablerowodd = '| style="background:#eefaff;"'

#custom group of items
custom_status = [1281] #Shock sweet
custom_helms = []
custom_legs = [731] # Assassin pants
custom_armors = []
custom_boots = [735] # Cotton boots
custom_shield = [585] #Scarab armlet
custom_gloves = []
custom_rings = []
custom_charms = []
custom_dyes = [690, 691, 692, 693, 694, 695, 696, 697, 698, 699]
custom_flowers = [661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674]

custom_easter = [1245, 802, 803, 804, 805, 1208, 1209, 1210, 1211, 1212, 1213, 1246, 1249, 1257, 1254, 4034]
custom_halloween = [1197, 3004, 1280, 1233]
custom_christmas = [635, 1234, 1235, 1236, 1237, 1238, 1239, 841, 842, 843, 844, 845, 846, 847, 849, 850, 851, 852, 853, 1207, 4037, 4038, 4039, 4040, 4041, 1240, 1241]

#not shown items
not_show = ["5000-5109"] #Sorcerer robes


#b - Buy
#c - Craft
#d - Dyed by selim
#g - GM event
#G - GM item only
#j - Developer
#n - No longer obtainable
#o - Unobtainable
#t - Tailorable
#s - Spellable
#q - Quest
#i - Ishi
#r - Unreleased
#e - Extend info
custom_rare = {'CottonShorts' : [["b", ""], ["i", ""]],
'JeansShorts' : [],
'CottonSkirt' : [["b", ""], ["t", "Lora Tay The Legendary Seamstress"]],
'JeansChaps' : [["t", "Pachua the Hermit Indian"]],
'CottonTrousers' : [["t", "Lora Tay The Legendary Seamstress"]],
'AssassinPants' : [["r", ""]],
'TerraniteLegs' : [["q", "The Terranite Armor"]],
'Miniskirt' : [["t", "Lora Tay The Legendary Seamstress"]],
'BromenalLegs' : [["r", ""]],
'LeatherTrousers' : [["q", "Raging Skill"]],
'RaggedShorts' : [["e", "Initial item"]],
'SilkPants' : [["b", ""], ["q", "Hetchel The Silk Weaver"]],
'RedCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenCottonSkirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedCottonShorts' : [["d", "Selim The Dyer"]],
'GreenCottonShorts' : [["d", "Selim The Dyer"]],
'DarkBlueCottonShorts' : [["d", "Selim The Dyer"]],
'YellowCottonShorts' : [["d", "Selim The Dyer"]],
'LightBlueCottonShorts' : [["d", "Selim The Dyer"]],
'PinkCottonShorts' : [["d", "Selim The Dyer"]],
'BlackCottonShorts' : [["d", "Selim The Dyer"]],
'OrangeCottonShorts' : [["d", "Selim The Dyer"]],
'PurpleCottonShorts' : [["d", "Selim The Dyer"]],
'DarkGreenCottonShorts' : [["d", "Selim The Dyer"]],
'RedMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenMiniskirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenCottonTrousers' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"], ["q", "Anwar's_Field"]],
'CactusDrink' : [["b", ""], ["i", ""]],
'CactusPotion' : [["b", ""], ["i", ""]],
'CandyCane' : [],
'XmasCake' : [["b", ""]],
'ChocolateBar' : [["i", ""]],
'Candy' : [["i", ""]],
'GingerBreadMan' : [],
'Cake' : [["b", ""], ["i", ""]],
'XmasCandyCane' : [],
'CherryCake' : [["b", ""], ["i", ""], ["q", "Newbie Quests#Fieri"]],
'EasterEgg' : [["n", ""]],
'Milk' : [["b", ""], ["i", ""]],
'RoastedMaggot' : [["b", ""]],
'OrangeCupcake' : [["b", ""], ["i", ""]],
'RedApple' : [["b", ""], ["i", ""]],
'Beer' : [["b", ""], ["i", ""]],
'BottleOfWater' : [["b", ""]],
'ChickenLeg' : [["b", ""], ["i", ""]],
'PinkPetal' : [["i", ""]],
'SmallMushroom' : [["b", ""], ["i", ""]],
'IronPotion' : [["b", ""], ["c", "Rauk The Alchemist#Potion_Making"]],
'ConcentrationPotion' : [["b", ""], ["c", "Rauk The Alchemist#Potion_Making"]],
'Orange' : [["b", ""], ["i", ""]],
'Steak' : [["b", ""], ["i", ""]],
'TinyHealingPotion' : [["c", "Caul The Alchemist"]],
'SmallHealingPotion' : [["c", "Caul The Alchemist"]],
'MediumHealingPotion' : [["c", "Caul The Alchemist"]],
'LargeHealingPotion' : [["c", "Caul The Alchemist"]],
'ManaPotion' : [["q", "Magic Quests#Wyara.27s_Mana_Potion"]],
'SnakeEgg' : [],
'MountainSnakeEgg' : [],
'GrassSnakeEgg' : [],
'CaveSnakeEgg' : [],
'GreenApple' : [["b", ""], ["i", ""]],
'PurificationPotion' : [["q", "Magic Quests#Cure_The_Pond"]],
'WhiteCake' : [["b", ""], ["i", ""]],
'ChocolateCake' : [["b", ""], ["i", ""]],
'OrangeCake' : [["b", ""], ["i", ""]],
'AppleCake' : [["b", ""], ["i", ""]],
'Acorn' : [],
'DilutedConcentrationPot' : [["o", ""]],
'DarkConcentrationPotion' : [["o", ""]],
'LacedChocolateCake' : [["r", ""]],
'LacedOrangeCupcake' : [["r", ""]],
'SlowPoisonPotion' : [["b", ""]],
'ZombieNachos' : [["b", ""]],
'LadyFingers' : [["b", ""]],
'JellAhh' : [["b", ""]],
'Snapple' : [["b", ""]],
'BeetleJuice' : [["b", ""]],
'GutBuster' : [["b", ""]],
'BloodWine' : [["b", ""]],
'HitchhikersTowel' : [["q", "Candor Quests#Sorfina"]],
'WhiteHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'RedHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'GreenHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'BlueHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'YellowHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'PurpleHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'OrangeHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'PinkHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'TealHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'LimeHitchhikersTowel' : [["d", "The Lost Hitchhiker#Dyeing_the_Towel"]],
'TinyManaElixir' : [],
'SmallManaElixir' : [["b", ""]],
'MediumManaElixir' : [["q", "The Illia Sisters"]],
'LargeManaElixir' : [["r", ""]],
'CranberryLollipop' : [["q", "Trick Or Treat"]],
'GrapeLollipop' : [["q", "Trick Or Treat"]],
'OrangeLollipop' : [["q", "Trick Or Treat"]],
'PollettEgg' : [],
'CaramelApple' : [["q", "The Illia Sisters"]],
'LollipopColor1' : [["n", ""]],
'LollipopColor2' : [["n", ""]],
'LollipopColor3' : [["n", ""]],
'Blueberries' : [],
'Pear' : [],
'Plum' : [],
'Cherry' : [],
'GoldenDeliciousApple' : [["q", "Oscar's Pumpkins"]],
'Honey' : [["r", ""]],
'Scissors' : [["n", ""], ["e", "Halloween 2010"]],
'ShockSweet' : [["b", ""]],
'RubberBat' : [],
'TonoriDelight' : [["b", ""], ["q", "Newbie Quests#Fieri"]],
'Marshmallow' : [["q", "Trick Or Treat"]],
'JellySkull' : [["q", "Trick Or Treat"]],
'CandyPumpkin' : [["q", "Oscar's Pumpkins"]],
'PickledBeets' : [["b", ""]],
'RoastedAcorn' : [["c", "Christmas Event"]],
'MTJarofOwnBlood' : [["r", ""]],
'CasinoCoins' : [["b", ""], ["i", ""]],
'DecorCandy' : [],
'MaggotSlime' : [["i", ""]],
'ScorpionStinger' : [],
'PurplePresentBox' : [],
'BluePresentBox' : [],
'RedScorpionStinger' : [],
'BugLeg' : [["b", ""], ["i", ""]],
'CoinBag' : [],
'TreasureKey' : [],
'GreenPresentBox' : [],
'EmptyBottle' : [],
'BottleOfSand' : [["n", ""]],
'AquaHint' : [["n", ""]],
'MagentaHint' : [["n", ""]],
'YellowHint' : [["n", ""]],
'GreenHint' : [["n", ""]],
'TealHint' : [["n", ""]],
'PurpleHint' : [["n", ""]],
'RedHint' : [["n", ""]],
'BlueHint' : [["n", ""]],
'OrangeHint' : [["n", ""]],
'GrayHint' : [["n", ""]],
'RawLog' : [["i", ""]],
'Toothbrush' : [["g", "Game_Masters/Events#Toothbrush_Event"]],
'WhiteFur' : [["i", ""]],
'CaveSnakeLamp' : [],
'HardSpike' : [["b", ""], ["i", ""]],
'PinkAntenna' : [["i", ""]],
'DarkCrystal' : [["b", ""]],
'SantaCookie' : [["o", ""]],
'IronOre' : [["i", ""]],
'SnakeSkin' : [["i", ""]],
'CottonCloth' : [["i", ""]],
'RedRose' : [["b", ""]],
'WhiteRose' : [["b", ""]],
'DarkRedRose' : [["b", ""]],
'PinkRose' : [["b", ""]],
'YellowRose' : [["b", ""]],
'BlackRose' : [["n", ""], ["e", "Easter 2010"]],
'OrangeRose' : [["b", ""]],
'BlueRose' : [["b", ""]],
'YellowTulip' : [["b", ""]],
'PurpleTulip' : [["b", ""]],
'RedTulip' : [["b", ""]],
'WhiteTulip' : [["b", ""]],
'PinkTulip' : [["b", ""]],
'OrangeTulip' : [["b", ""]],
'HeartNecklace' : [["r", ""]],
'MauveHerb' : [],
'CobaltHerb' : [],
'GambogeHerb' : [],
'AlizarinHerb' : [],
'RedDye' : [["c", "Rauk The Alchemist#Dye_Making"], ["i", ""]],
'GreenDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'DarkBlueDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'YellowDye' : [["c", "Rauk The Alchemist#Dye_Making"], ["i", ""]],
'LightBlueDye' : [["c", "Rauk The Alchemist#Dye_Making"], ["i", ""]],
'PinkDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'BlackDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'OrangeDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'PurpleDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'DarkGreenDye' : [["c", "Rauk The Alchemist#Dye_Making"]],
'Pearl' : [],
'PileOfAsh' : [["i", ""]],
'SulphurPowder' : [["c", "Rauk The Alchemist#Powder_Making"], ["s", "#gole"]],
'IronPowder' : [["c", "Rauk The Alchemist#Powder_Making"], ["s", "#zukminbirf"]],
'GoldenScorpionStinger' : [["q", "Setzer Quest#Kfahr"]],
'MonsterOilPotion' : [["q", "Setzer Quest#Make_the_Monster_Oil"]],
'LeatherPatch' : [["c", "Pachua the Hermit Indian"]],
'BlackScorpionStinger' : [],
'SnakeTongue' : [],
'MountainSnakeTongue' : [],
'GrassSnakeTongue' : [],
'CaveSnakeTongue' : [],
'SilkCocoon' : [],
'Iten' : [["q", "Newbie Quests#Miners_Quest"], ["s", ""]],
'MoubooFigurine' : [["s", "#parum boo"]],
'WarpedLog' : [["s", ""]],
'Lifestone' : [["s", "#manpahil"], ["q", "Life Magic Skill#Life_Stones"], ["i", ""]],
'DruidTreeBranch' : [["q", "Magic Quests#Old_Druid_Tree_2"]],
'Root' : [["b", ""]],
'MopoxCurePotion' : [["r", ""]],
'BatWing' : [],
'BatTeeth' : [],
'TerraniteOre' : [],
'WispPowder' : [["b", ""], ["i", ""]],
'SpectrePowder' : [["b", ""], ["i", ""]],
'PoltergeistPowder' : [["b", ""], ["i", ""]],
'Bone' : [],
'Skull' : [],
'RottenRags' : [],
'DiseasedHeart' : [],
'UndeadEar' : [],
'UndeadEye' : [],
'MylarinDust' : [["q", "Love Triangle Quest"]],
'EasterBasket' : [["n" , ""], ["e" , "Easter 2011"]],
'GrassLiner' : [["n", ""], ["e", "Easter 2011"]],
'JellyBeans' : [["n", ""], ["e", "Easter 2011"]],
'ChocolateMouboo' : [["n", ""], ["e", "Easter 2011"]],
'ReedBundle' : [],
'GrassSeed' : [],
'DiamondPowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'RubyPowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'EmeraldPowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'SapphirePowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'TopazPowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'AmethystPowder' : [["c", "The Lost Hitchhiker#The_Gem_Powders"]],
'BrokenFourLeafAmulet' : [["r", ""]],
'BrokenDoll' : [["q", "Rossy Quest"]],
'HyvernStinger' : [],
'GrubSlime' : [],
'RedDottedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'YellowDottedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'BlueDottedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'PurpleStripedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'RedGoldenStripedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'GreenRedStripedWrap' : [["n", ""], ["e", "Christmas 2011"]],
'PlushMouboo' : [["n", ""], ["e", "Christmas 2011"]],
'OpenPresentBox' : [["q", "Christmas_Event"]],
'ClosedChristmasBox' : [["n", ""], ["e", "Christmas 2011"]],
'StickReinboo' : [["n", ""], ["e", "Christmas 2011"]],
'LeatherBall' : [["n", ""], ["e", "Christmas 2011"]],
'Doll' : [["n", ""], ["e", "Christmas 2011"]],
'WolvernTooth' : [],
'WolvernPelt' : [],
'SquirrelPelt' : [],
'WhiteBellTuber' : [],
'IcedWater' : [],
'SilverMirror' : [],
'BookPage' : [],
'LeatherSuitcase' : [["q", "Kylian the Businessman"]],
'Antlers' : [],
'SealedSoul' : [["q", "The Illia Sisters"]],
'LockPicks' : [["q", "The Illia Sisters"]],
'LazuriteShard' : [["q", "The Illia Sisters"]],
'LazuriteCrystal' : [["q", "The Illia Sisters"]],
'HeartOfLazurite' : [["q", "The Illia Sisters"]],
'SilkSheet' : [["c", "Hetchel The Silk Weaver"]],
'OrangeSummonFlower' : [["q", "Orum and Waric follow-up quest"]],
'PurpleSummonFlower' : [["q", "Orum and Waric follow-up quest"]],
'WhiteSummonFlower' : [["q", "Orum and Waric follow-up quest"]],
'YellowSummonFlower' : [["q", "Orum and Waric follow-up quest"]],
'RedSummonFlower' : [["q", "Orum and Waric follow-up quest"]],
'WhiteWrap' : [["q", "Christmas Event"]],
'YellowWrap' : [["q", "Christmas Event"]],
'BlueWrap' : [["q", "Christmas Event"]],
'PurpleWrap' : [["q", "Christmas Event"]],
'GreenWrap' : [["q", "Christmas Event"]],
'Soul' : [],
'RedChristmasStocking' : [["n", ""], ["e", "Christmas 2010"]],
'RedEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'GreenEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'BlueEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'YellowEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'PinkEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'TealEasterEgg' : [["q", "Easter Eggs Hunt"], ["e", "Rare"]],
'LightCrystal' : [["r", ""]],
'FakeFangs' : [["n", ""]],
'RedOrnament' : [["n", ""]],
'YellowOrnament' : [["n", ""]],
'GreenOrnament' : [["n", ""]],
'AquaOrnament' : [["n", ""]],
'BlueOrnament' : [["n", ""]],
'MagentaOrnament' : [["n", ""]],
'SantaSnowGlobe' : [["n", ""]],
'SnowmanSnowGlobe' : [["n", ""]],
'BentNeedle' : [["n", ""], ["e", "Easter 2010"]],
'DarkEasterEgg' : [["n", ""], ["e", "Easter 2010"]],
'StrangeCoin' : [["n", ""], ["e", "Easter 2010"]],
'DarkPetal' : [["n", ""], ["e", "Easter 2010"]],
'FlawedLens' : [["n", ""], ["e", "Easter 2010"]],
'RedCottonCloth' : [["d", "Selim The Dyer"]],
'GreenCottonCloth' : [["d", "Selim The Dyer"]],
'DarkBlueCottonCloth' : [["d", "Selim The Dyer"]],
'YellowCottonCloth' : [["d", "Selim The Dyer"]],
'LightBlueCottonCloth' : [["d", "Selim The Dyer"]],
'PinkCottonCloth' : [["d", "Selim The Dyer"]],
'BlackCottonCloth' : [["d", "Selim The Dyer"]],
'OrangeCottonCloth' : [["d", "Selim The Dyer"]],
'PurpleCottonCloth' : [["d", "Selim The Dyer"]],
'DarkGreenCottonCloth' : [["d", "Selim The Dyer"]],
'JackOLantern' : [],
'RealisticBrain' : [],
'JarofBlood' : [],
'Tongue' : [["n", ""]],
'PumpkinSeeds' : [],
'AngryScorpionStinger' : [],
'Coal' : [],
'Diamond' : [],
'Ruby' : [],
'Emerald' : [],
'Sapphire' : [],
'Topaz' : [],
'Amethyst' : [],
'IronIngot' : [["c", "Iron Ingot"]],
'BanditHood' : [],
'RedPowder' : [["q", "Orum Quest"]],
'YellowPowder' : [["q", "Orum Quest"]],
'BluePowder' : [["q", "Orum Quest"]],
'YellowPresentBox' : [],
'WhitePresentBox' : [],
'AnimalBones' : [],
'FrozenYetiTear' : [],
'YetiClaw' : [],
'IceCube' : [],
'GrimaceOfDementia' : [["q", "Grimace of Dementia"]],
'BlackPearl' : [["n", ""], ["e", "Easter 2012"]],
'WhiteBlanket' : [["n", ""], ["e", "Christmas 2012"]],
'WhiteSaddleRug' : [["n", ""], ["e", "Christmas 2012"]],
'RedSaddleRug' : [["n", ""], ["e", "Christmas 2012"]],
'RawTalisman' : [["n", ""], ["e", "Christmas 2012"]],
'FlightTalisman' : [["n", ""], ["e", "Christmas 2012"]],
'Bloodstone' : [["o", ""]],
'BrainStem' : [["o", ""]],
'CryptKey' : [["r", ""]],
'Ectoplasm' : [["r", ""]],
'Urn' : [["r", ""]],
'VampireBatWing' : [],
'WraithHorn' : [["r", ""]],
'AstralCube' : [["r", ""]],
'RunestoneA' : [["r", ""]],
'RunestoneL' : [["r", ""]],
'RunestoneN' : [["r", ""]],
'RunestoneT' : [["r", ""]],
'RunestoneW' : [["r", ""]],
'QuillOfBinding' : [["r", ""]],
'BloodInk' : [["r", ""]],
'UnderworldKey' : [["r", ""]],
'JarofOwnBlood' : [["r", ""]],
'SantaHat' : [["q", "Quest Of Snowman"]],
'FancyHat' : [["b", ""], ["i", ""]],
'MinersHat' : [["q", "Newbie Quests#Miners_Quest"]],
'StandardHeadband' : [["b", ""]],
'SilkHeadband' : [["b", ""]],
'PumpkinHelmet' : [],
'AxeHat' : [],
'PirateHat' : [],
'Goggles' : [["n", ""]],
'LeatherGoggles' : [["n", ""]],
'Circlet' : [],
'Eyepatch' : [["n", ""]],
'Bandana' : [],
'TopHat' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'FunkyHat' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'MushHat' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'ShroomHat' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'ChristmasElfHat' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'FaceMask' : [["n", ""]],
'WarlordHelmet' : [["c", "Nicholas the Blacksmith"]],
'KnightsHelmet' : [["c", "Nicholas the Blacksmith"]],
'InfantryHelmet' : [],
'CrusadeHelmet' : [["c", "Nicholas the Blacksmith"]],
'WhiteCowboyHat' : [["c", "Pachua the Hermit Indian"]],
'BlackCowboyHat' : [["c", "Pachua the Hermit Indian"]],
'Crown' : [["o", ""]],
'DevelopersCap' : [["j", ""]],
'Cap' : [["b", ""]],
'SerfHat' : [["b", ""], ["q", "Newbie Quests#Sarah"], ["i", ""]],
'GraduationCap' : [["q", "Newbie Graduation"]],
'NohMask' : [["q", "Robberies In Hurnscald"]],
'DemonMask' : [["q", "Demon Mask"]],
'HighPriestCrown' : [["b", ""]],
'MonsterSkullHelmet' : [["b", ""]],
'DesertHat' : [["b", ""], ["t", "Lora Tay The Legendary Seamstress"]],
'CottonHeadband' : [["b", ""]],
'GMCap' : [["G", ""]],
'PinkieHat' : [],
'FluffyHat' : [],
'PaladinsHelmet' : [["r", ""]],
'OverlordsHelmet' : [["r", ""]],
'DesertHelmet' : [["r", ""]],
'SailorHat' : [["r", ""]],
'CaptainsHat' : [["r", ""]],
'TerraniteHelmet' : [["q", "The Terranite Armor"]],
'GuyFawkesMask' : [["n", ""], ["e", "Halloween 2010"]],
'FairyHat' : [["q", "Bandit Quest"]],
'BromenalHelmet' : [["r", ""]],
'BowlerHatBrown' : [["q", "Love Triangle Quest"]],
'PinkieHelmet' : [["q", "Headless Man's Helmet"]],
'Earmuffs' : [["r", ""]],
'ElfNightcap' : [["n", ""], ["e", "Christmas 2011"]],
'Sunglasses' : [["n", ""], ["e", "Christmas 2011"]],
'KnitCap' : [["q", "Santa's Stolen Presents"]],
'BullHelmet' : [["q", "The Illia Sisters"]],
'RedEggshellHat' : [["q", "Easter Eggs Hunt"]],
'BlueEggshellHat' : [["q", "Easter Eggs Hunt"]],
'YellowEggshellHat' : [["q", "Easter Eggs Hunt"]],
'GreenEggshellHat' : [["q", "Easter Eggs Hunt"]],
'OrangeEggshellHat' : [["q", "Easter Eggs Hunt"]],
'DarkEggshellHat' : [["q", "Easter Eggs Hunt"]],
'MagicGMTopHat' : [["g", "Game Masters/Events#Kill_the_GM"], ["e", "GM Usage only"]],
'MurdererCrown' : [["g", "Game Masters/Events#Kill_the_GM"]],
'BeanieCopter' : [["q", "Milly's Hero"]],
'RedRoseHat' : [["q", "Orum and Waric follow-up quest"]],
'WhiteRoseHat' : [["d", "Blossom"]],
'PinkRoseHat' : [["d", "Blossom"]],
'YellowRoseHat' : [["d", "Blossom"]],
'OrangeRoseHat' : [["d", "Blossom"]],
'BlueRoseHat' : [["d", "Blossom"]],
'BucketHat' : [["q", "Trick Or Treat"]],
'TamOShanter' : [["r", ""]],
'CashiersShade' : [["r", ""]],
'AutumnMask' : [["q", "Trick Or Treat"]],
'NutcrackerHat' : [["q", "Christmas Event"]],
'Beret' : [["n", ""]],
'RangerHat' : [],
'AntlerHat' : [["n", ""]],
'ChristmasTreeHat' : [["n", ""]],
'SantaBeardHat' : [["n", ""]],
'BunnyEars' : [["n", ""], ["e", "Christmas 2010, Easter 2011"]],
'MoubooHead' : [["n", ""]],
'CatEars' : [["q", "Cat Ears Quest"]],
'PaperBag' : [["n", ""]],
'MoubootaurHead' : [["o", ""]],
'BunchOfParsley' : [["n", ""], ["e", "Halloween 2011"]],
'SkullMask' : [],
'SnowGoggles' : [["n", ""]],
'HeartGlasses' : [["n", ""], ["e", "Easter 2010"]],
'RabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'EggshellHat' : [["n", ""], ["e", "Easter 2010"]],
'OperaMask' : [["n", ""], ["e", "Halloween 2010"]],
'JesterMask' : [["n", ""], ["e", "Halloween 2010"]],
'WitchHat' : [["n", ""], ["e", "Halloween 2010"]],
'GoblinMask' : [["n", ""], ["e", "Halloween 2010"]],
'RedDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenDesertHat' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedCottonHeadband' : [["d", "Selim The Dyer"]],
'GreenCottonHeadband' : [["d", "Selim The Dyer"]],
'DarkBlueCottonHeadband' : [["d", "Selim The Dyer"]],
'YellowCottonHeadband' : [["d", "Selim The Dyer"]],
'LightBlueCottonHeadband' : [["d", "Selim The Dyer"]],
'PinkCottonHeadband' : [["d", "Selim The Dyer"]],
'BlackCottonHeadband' : [["d", "Selim The Dyer"]],
'OrangeCottonHeadband' : [["d", "Selim The Dyer"]],
'PurpleCottonHeadband' : [["d", "Selim The Dyer"]],
'DarkGreenCottonHeadband' : [["d", "Selim The Dyer"]],
'RedRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'GreenRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'DarkBlueRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'YellowRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'LightBlueRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'PinkRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'BlackRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'OrangeRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'PurpleRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'DarkGreenRabbitEars' : [["n", ""], ["e", "Easter 2010"]],
'RedWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'GreenWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'DarkBlueWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'YellowWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'LightBlueWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'PinkWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'BlackWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'OrangeWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'PurpleWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'DarkGreenWizardHat' : [["d", "Selim The Dyer"], ["q", "Angela's Daughter"]],
'RedBowlerHat' : [["d", "Selim The Dyer"]],
'GreenBowlerHat' : [["d", "Selim The Dyer"]],
'DarkBlueBowlerHat' : [["d", "Selim The Dyer"]],
'YellowBowlerHat' : [["d", "Selim The Dyer"]],
'LightBlueBowlerHat' : [["d", "Selim The Dyer"]],
'PinkBowlerHat' : [["d", "Selim The Dyer"]],
'BlackBowlerHat' : [["d", "Selim The Dyer"]],
'OrangeBowlerHat' : [["d", "Selim The Dyer"]],
'PurpleBowlerHat' : [["d", "Selim The Dyer"]],
'DarkGreenBowlerHat' : [["d", "Selim The Dyer"]],
'RedBowlerHatBrown' : [["d", "Selim The Dyer"]],
'GreenBowlerHatBrown' : [["d", "Selim The Dyer"]],
'DarkBlueBowlerHatBrown' : [["d", "Selim The Dyer"]],
'YellowBowlerHatBrown' : [["d", "Selim The Dyer"]],
'LightBlueBowlerHatBrown' : [["d", "Selim The Dyer"]],
'PinkBowlerHatBrown' : [["d", "Selim The Dyer"]],
'BlackBowlerHatBrown' : [["d", "Selim The Dyer"]],
'OrangeBowlerHatBrown' : [["d", "Selim The Dyer"]],
'PurpleBowlerHatBrown' : [["d", "Selim The Dyer"]],
'DarkGreenBowlerHatBrown' : [["d", "Selim The Dyer"]],
'RedBeret' : [["n", ""]],
'GreenBeret' : [["n", ""]],
'DarkBlueBeret' : [["n", ""]],
'YellowBeret' : [["n", ""]],
'LightBlueBeret' : [["n", ""]],
'PinkBeret' : [["n", ""]],
'BlackBeret' : [["n", ""]],
'OrangeBeret' : [["n", ""]],
'PurpleBeret' : [["n", ""]],
'DarkGreenBeret' : [["n", ""]],
'CandleHelmet' : [["q", "Orum Quest"]],
'YetiMask' : [],
'WizardHat' : [["q", "Angela's Daughter"]],
'BowlerHat' : [["q", "Shannon's Bowler Hat"]],
'Monocle' : [["r", ""]],
'PanHat' : [["n", ""], ["e", "Easter 2012"]],
'ChefHat' : [["n", ""], ["e", "Easter 2012"]],
'RedNose' : [],
'DarkHelm' : [],
'UnderworldMask' : [["r", ""]],
'Phylactery' : [["r", ""]],
'Dagger' : [["b", ""]],
'SharpKnife' : [["b", ""], ["q", "Candor Quests#Hasan"]],
'IronArrow' : [["b", ""]],
'ShortBow' : [["b", ""], ["q", "Newbie Quests#Miners_Quest"]],
'ShortSword' : [["q", "Short Sword Quest"]],
'ForestBow' : [["b", ""], ["q", "Forest Bow Quest"]],
'Bardiche' : [["r", ""]],
'Halberd' : [["r", ""]],
'Axe' : [["r", ""]],
'BlacksmithsAxe' : [["r", ""]],
'Sabre' : [["r", ""]],
'BoneKnife' : [["q", "Bone Knife Quest"]],
'Setzer' : [["q", "Setzer Quest"]],
'Scimitar' : [["r", ""]],
'Falchion' : [["r", ""]],
'Scorpion' : [["r", ""]],
'DesertBow' : [["r", ""]],
'Beheader' : [["r", ""]],
'BoneDarts' : [["r", ""]],
'SandCutter' : [["r", ""]],
'RockKnife' : [["q", "Angela's Daughter"]],
'StaffOfLife' : [["r", ""]],
'CrescentRod' : [["r", ""]],
'StaffOfFire' : [["r", ""]],
'StaffOfIce' : [["r", ""]],
'Jackal' : [["r", ""]],
'Sword' : [["r", ""]],
'BastardSword' : [["r", ""]],
'LongSword' : [["r", ""]],
'Spear' : [["r", ""]],
'Scythe' : [["q", "Farmer's Scythe"]],
'WoodenStaff' : [["q", "Angela's Daughter"]],
'Wand' : [["q", "Candor Quests#Morgan"]],
'TerraniteArrow' : [["q", "Heathin's Terranite Arrows"]],
'IceGladius' : [["q", "Blue Sage Quest"]],
'BansheeBow' : [["q", "The Illia Sisters"]],
'SlingShot' : [["b", ""], ["q", "Candor Quests#Tanisha"]],
'SlingBullet' : [["b", ""], ["q", "Candor Quests#Tanisha"]],
'KidBook' : [],
'Arrow' : [["b", ""], ["s", "#kularzufrill"], ["q", "Newbie Quests#Sandra"], ["i", ""]],
'Bow' : [["b", ""], ["q", "Newbie Quests#Sandra"]],
'Knife' : [["b", ""], ["q", "Candor Quests#Sorfina"]],
'ToySabre' : [["b", ""]],
'BoneArrows' : [["b", ""]],
'MinerGloves' : [["b", ""], ["q", "Newbie Quests#Miners_Quest"]],
'LeatherGloves' : [],
'WinterGloves' : [["q", "Agostine The Tailor"]],
'CottonGloves' : [["b", ""]],
'AssassinGloves' : [["r", ""]],
'BromenalGloves' : [["r", ""]],
'SilkGloves' : [["q", "Blue Sage Quest"]],
'RedCottonGloves' : [["d", "Selim The Dyer"]],
'GreenCottonGloves' : [["d", "Selim The Dyer"]],
'DarkBlueCottonGloves' : [["d", "Selim The Dyer"]],
'YellowCottonGloves' : [["d", "Selim The Dyer"]],
'LightBlueCottonGloves' : [["d", "Selim The Dyer"]],
'PinkCottonGloves' : [["d", "Selim The Dyer"]],
'BlackCottonGloves' : [["d", "Selim The Dyer"]],
'OrangeCottonGloves' : [["d", "Selim The Dyer"]],
'PurpleCottonGloves' : [["d", "Selim The Dyer"]],
'DarkGreenCottonGloves' : [["d", "Selim The Dyer"]],
'ScarabArmlet' : [["n", ""]],
'SteelShield' : [["c", "Nicholas the Blacksmith"]],
'WoodenShield' : [["q", "Wooden Shield Quest"]],
'LeatherShield' : [["b", ""], ["q", "Newbie Quests#Miners_Quest"]],
'BromenalShield' : [["r", ""]],
'LeatherShirt' : [["b", ""]],
'DesertShirt' : [["b", ""], ["q", "Newbie Quests#Miners_Quest"]],
'Turtleneck' : [["q", "Santa's Stolen Presents"]],
'VNeckSweater' : [["q", "Santa's Stolen Presents"]],
'ChainmailShirt' : [["c", "Nicholas the Blacksmith"]],
'LightPlatemail' : [["c", "Nicholas the Blacksmith"]],
'GoldenPlatemail' : [["r", ""]],
'WhiteEvokersRobeBlue' : [["r", ""]],
'BlackEvokersRobeBlue' : [["r", ""]],
'WhiteWizardRobe' : [["r", ""]],
'BlackWizardRobe' : [["r", ""]],
'ApprenticeRobe' : [["r", ""]],
'WarlordPlate' : [["c", "Nicholas the Blacksmith"]],
'GoldenWarlordPlate' : [["r", ""]],
'TankTop' : [["s", "#patloree"], ["t", "Lora Tay The Legendary Seamstress"]],
'ShortTankTop' : [["s", "#patviloree"], ["t", "Lora Tay The Legendary Seamstress"]],
'SilkRobe' : [["b", ""], ["t", "Lora Tay The Legendary Seamstress"]],
'GMRobe' : [["G", ""]],
'AssassinShirt' : [["r", ""]],
'TerraniteChestArmor' : [["q", "The Terranite Armor"]],
'ForestArmor' : [["q", "Bandit Quest"]],
'PlatynaRedDress' : [["o", ""]],
'YetiSkinShirt' : [["q", "Raging_Skill"]],
'BromenalChest' : [["r", ""]],
'SorcererRed' : [["q", "Love Triangle Quest"]],
'FineDress' : [["q", "Agostine's Dream Dress"]],
'LazuriteRobe' : [["q", "The Illia Sisters"]],
'Contributor' : [],
'AmberChristmasSweater' : [["q", "Christmas Event"]],
'FunkyChristmasSweater' : [["q", "Christmas Event"]],
'PinkChristmasSweater' : [["q", "Christmas Event"]],
'DarkChristmasSweater' : [["q", "Christmas Event"]],
'BlueChristmasSweater' : [["q", "Christmas Event"]],
'CottonShirt' : [["b", ""], ["s", "#patmuploo"], ["i", ""], ["t", "Lora Tay The Legendary Seamstress"], ["q", "Tutorial"]],
'RedCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenCottonShirt' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedVNeckSweater' : [["d", "Selim The Dyer"]],
'GreenVNeckSweater' : [["d", "Selim The Dyer"]],
'DarkBlueVNeckSweater' : [["d", "Selim The Dyer"]],
'YellowVNeckSweater' : [["d", "Selim The Dyer"]],
'LightBlueVNeckSweater' : [["d", "Selim The Dyer"]],
'PinkVNeckSweater' : [["d", "Selim The Dyer"]],
'BlackVNeckSweater' : [["d", "Selim The Dyer"]],
'OrangeVNeckSweater' : [["d", "Selim The Dyer"]],
'PurpleVNeckSweater' : [["d", "Selim The Dyer"]],
'DarkGreenVNeckSweater' : [["d", "Selim The Dyer"]],
'RedTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'GreenTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'DarkBlueTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'YellowTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'LightBlueTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'PinkTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'BlackTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'OrangeTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'PurpleTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'DarkGreenTurtleneck' : [["d", "Selim The Dyer"], ["q", "Santa's Stolen Presents"]],
'RedSilkRobe' : [["d", "Selim The Dyer"]],
'GreenSilkRobe' : [["d", "Selim The Dyer"]],
'DarkBlueSilkRobe' : [["d", "Selim The Dyer"]],
'YellowSilkRobe' : [["d", "Selim The Dyer"]],
'LightBlueSilkRobe' : [["d", "Selim The Dyer"]],
'PinkSilkRobe' : [["d", "Selim The Dyer"]],
'BlackSilkRobe' : [["d", "Selim The Dyer"]],
'OrangeSilkRobe' : [["d", "Selim The Dyer"]],
'PurpleSilkRobe' : [["d", "Selim The Dyer"]],
'DarkGreenSilkRobe' : [["d", "Selim The Dyer"]],
'RedTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenShortTankTop' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererRed' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenFineDress' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererDBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererYellow' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererLBlue' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererPink' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererBlack' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererOrange' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererPurple' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererDGreen' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'GreenSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkBlueSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'YellowSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'LightBlueSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PinkSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'BlackSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'OrangeSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'PurpleSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'DarkGreenSorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'SorcererWhite' : [["d", "Selim The Dyer"], ["t", "Lora Tay The Legendary Seamstress"]],
'RedContributor' : [["d", "Selim The Dyer"]],
'GreenContributor' : [["d", "Selim The Dyer"]],
'DarkBlueContributor' : [["d", "Selim The Dyer"]],
'YellowContributor' : [["d", "Selim The Dyer"]],
'LightBlueContributor' : [["d", "Selim The Dyer"]],
'PinkContributor' : [["d", "Selim The Dyer"]],
'BlackContributor' : [["d", "Selim The Dyer"]],
'OrangeContributor' : [["d", "Selim The Dyer"]],
'PurpleContributor' : [["d", "Selim The Dyer"]],
'DarkGreenContributor' : [["d", "Selim The Dyer"]],
'Boots' : [["b", ""], ["i", ""], ["q", "Newbie Quests#Lieutenant_Dausen"]],
'FurBoots' : [["q", "Agostine The Tailor"]],
'BlackBoots' : [["q", "Rossy Quest"]],
'CottonBoots' : [["b", ""], ["i", ""]],
'AssassinBoots' : [["r", ""]],
'BromenalBoots' : [["r", ""]],
'WarlordBoots' : [["c", "Nicholas the Blacksmith"]],
'RedCottonBoots' : [["d", "Selim The Dyer"]],
'GreenCottonBoots' : [["d", "Selim The Dyer"]],
'DarkBlueCottonBoots' : [["d", "Selim The Dyer"]],
'YellowCottonBoots' : [["d", "Selim The Dyer"]],
'LightBlueCottonBoots' : [["d", "Selim The Dyer"]],
'PinkCottonBoots' : [["d", "Selim The Dyer"]],
'BlackCottonBoots' : [["d", "Selim The Dyer"]],
'OrangeCottonBoots' : [["d", "Selim The Dyer"]],
'PurpleCottonBoots' : [["d", "Selim The Dyer"]],
'DarkGreenCottonBoots' : [["d", "Selim The Dyer"]],
'RedStockings' : [["q", "Christmas Event"]],
'WeddingRing' : [["q", "Wedding Woodland"]],
'FourLeafClover' : [],
'Towel' : [["n", ""]],
'CrozeniteFourLeafAmulet' : [["r", ""]],
'BromenalFourLeafAmulet' : [["r", ""]],
'SilverFourLeafAmulet' : [["r", ""]],
'GoldenFourLeafAmulet' : [["r", ""]],
'Grimoire' : [["q", "Blue Sage Quest"]],
'HeartOfIsis' : [["q", "The Illia Sisters"]],
'SkeletonCharm' : [["q", "Parua's Brother"]],
'DarkTalisman' : [["r", ""]],
'DiamondRing' : [["c", "Inya"]],
'RubyRing' : [["c", "Inya"]],
'EmeraldRing' : [["c", "Inya"]],
'SapphireRing' : [["c", "Inya"]],
'TopazRing' : [["c", "Inya"]],
'AmethystRing' : [["c", "Inya"]],
'SimpleRing' : [["b", ""], ["q" , "Love Triangle Quest"]]
}

imagesused = set()

class whatever: pass

log = []


# parseitems(file)
## Returns list with items from eathena item_db file.

def saveint(string, altval = 0):
    a = 0
    try:
        a = int(string)
    except:
        a = altval
    return a

def parseshowitems(items):
    none = []
    for num in items:
        pos = str(num).find("-")
        if pos != -1:
            start = int(num[0:pos])
            end = int(num[pos+1:])+1
            for i in range(start,end):
                none.append(i)
        else:
            none.append(num)
    return none
			
def parsescript(s):
    # Assumes that there's only one call of each method, otherwise it would need to know
    # how to combine those function calls. In practice, the latter call would prevail.
    script = {}
    scriptentry = ""
    parentry = ""
    mode = 0
    for a in s:

        if mode == 0: # looking for method
            if a.isalpha(): 
                mode = 1
                scriptentry += a
            elif a == '}': mode = 9
        elif mode == 1: # reading method name
            if a in " ;}":
                if a == " ": mode = 2
                elif a == ";": mode = 1
                elif a == "}": mode = 9
                parentry = ""
                script[scriptentry] = []
            else: scriptentry += a
        elif mode == 2: #looking for param
            if a == " ": pass
            elif a == ";": 
                mode = 0
                scriptentry = ""
            else:
                mode = 3
                parentry = a
        elif mode == 3: #reading param
            if a in (" ", ",", ";"):
                script[scriptentry].append(parentry)
                parentry = ""
                if a == ';': 
                    mode = 0
                    scriptentry = ""
                else: mode = 2
            else: 
                parentry += a
        elif mode == 9: #finished
            pass

    # Convert all possible parameters to integers
    for i in script.keys():
        for j in range(len(script[i])):
            try:
                script[i][j] = int(script[i][j])
            except:
                pass
    return script

def parsemonsters(file):
    objects = []
    sfile = file.split(chr(10))
    for line in sfile:
        s = line[:line.find('//')].strip().replace('\t','')
        if s:
            values = s.split(',')            
            numberofvalues = 57
            if len(values) != numberofvalues:
                log.append("mob_db: Warning, monster-line with ID %s has %d values instead of %d" % (values[0], len(values), numberofvalues))
                while len(values) < numberofvalues - 1:
                    values.append('')
                while len(values) > numberofvalues - 1:
                    values.pop()
            if saveint(values[29])!=0:
                o = whatever()
                o.dropid     = saveint(values[29])
                o.dropper    = saveint(values[30])
                objects.append(o)
            if saveint(values[31])!=0:
                o = whatever()
                o.dropid     = saveint(values[31])
                o.dropper    = saveint(values[32])
                objects.append(o)
            if saveint(values[33])!=0:
                o = whatever()
                o.dropid     = saveint(values[33])
                o.dropper    = saveint(values[34])
                objects.append(o)
            if saveint(values[35])!=0:
                o = whatever()
                o.dropid     = saveint(values[35])
                o.dropper    = saveint(values[36])
                objects.append(o)
            if saveint(values[37])!=0:
                o = whatever()
                o.dropid     = saveint(values[37])
                o.dropper    = saveint(values[38])
                objects.append(o)
            if saveint(values[39])!=0:
                o = whatever()
                o.dropid     = saveint(values[39])
                o.dropper    = saveint(values[40])
                objects.append(o)
            if saveint(values[41])!=0:
                o = whatever()
                o.dropid     = saveint(values[41])
                o.dropper    = saveint(values[42])
                objects.append(o)
            if saveint(values[43])!=0:
                o = whatever()
                o.dropid     = saveint(values[43])
                o.dropper    = saveint(values[44])
                objects.append(o)
    objects.sort(key=lambda x: (x.dropid, x.dropper),reverse=True)
    out = []
    param1 = []
    param2 = []
    prev = -1
    for m in objects:
        if prev != m.dropid:
            prev = m.dropid
            param1.append(m.dropid)
            param2.append(m.dropper)
    out.append(param1)
    out.append(param2)
    return out

def parseitems(file):
    objects = []
    sfile = file.split(chr(10))
    for line in sfile:
        s = line[:line.find('//')].strip().replace('\t','')
        if s:
            if s[len(s)-1]!="}":
                s += "}"
            mode = 0
            sout = ""
            for a in s:
                if mode == 0: #Out of {}
                    if a == '{': mode = 1
                    sout += a
                elif mode == 1: #Inside {}
                    if a == ',': sout += '|'
                    else:
                        sout += a
                        if a == '}': mode = 0
            values = sout.split(',')
            if line[0] == '#':
                continue
            if len(values) != 18:
                log.append("item_db: Warning, item-line with ID %s has %d values instead of 18" % (values[0], len(values)))
                while len(values) < 18:
                    values.append('')
                while len(values) > 18:
                    values.pop()
            o = whatever()
            o.id        = int(values[0])
            o.name      = values[1]
            o.type      = saveint(values[2])
            o.price     = saveint(values[3])
            o.sell      = saveint(values[4])
            o.weight    = saveint(values[5])
            o.atk       = saveint(values[6])
            o.defense   = saveint(values[7])
            o.range     = saveint(values[8])
            o.mbonus    = saveint(values[9])
            o.slot      = saveint(values[10],-1)
            o.gender    = saveint(values[11],-1)
            o.loc       = saveint(values[12],-1)
            o.wlv       = saveint(values[13])
            o.elv       = saveint(values[14])
            o.view      = saveint(values[15],-1)
            o.usescript = parsescript(values[16].replace('|',','))
            o.equipscript = parsescript(values[17].replace('|',','))
            objects.append(o)
    return objects

# parsexmlitems(file) parseincludes(file)
## Creates a dictionary containing the values of a client items.xml
## Yeah, there are XML parsers in the standard python libraries, but they're too object
## oriented and thus don't fit the style of this program.
def parseincludes(file):
    s = file.read()
    xmldata = ""
    pre = "<include "
    term = "/>"
    attrs = ["name"]
    index = 0
    if pre not in s[index:] and s.find("type=\"hairsprite")==-1 and s.find("type=\"race")==-1:
        xmldata += s
    while pre in s[index:]:
        index += s[index:].find(pre) + len(pre)
        curitem = {}
        termstart = index + s[index:].find(term) + len(term)
        for attr in attrs:
            found = s[index:].find(attr+'="')
            if found >= 0:
                start = index + found + len(attr+'="')
                end= start + s[start:].find('"')
            else:
                start = termstart
            if start < termstart:
                curitem[attr] = s[start:end]
        finclude = open('./'+curitem["name"])
        xmldata += parseincludes(finclude)
    return xmldata

def parsexmlitems(file):
    s = parseincludes(file)
    items = {}
    pre = "<item "
    term = ">"+chr(10)
    attrs = ["id", "image", "art", "name", "description", "type", "hp", "mp", "str", "agi", "vit", "int", "dex", "luck", "weight", "slot", "effect"]
    intattrs = ["id", "art", "hp", "str", "agi", "vit", "int", "dex", "luck", "mp"," weight", "slot"]
    index = 0
    while pre in s[index:]:
        index += s[index:].find(pre) + len(pre)
        curitem = {}
        termstart = index + s[index:].find(term) + len(term)
        curitem["effect"] = ""
        curitem["hp"] = 0
        curitem["mp"] = 0
        curitem["str"] = 0
        curitem["agi"] = 0
        curitem["vit"] = 0
        curitem["int"] = 0
        curitem["dex"] = 0
        curitem["luck"] = 0
        for attr in attrs:
            found = s[index:].find(attr+'="')
            if found >= 0:
                start = index + found + len(attr+'="')
                end= start + s[start:].find('"')
            else:
                start = termstart

            if start < termstart:
                curitem[attr] = s[start:end]

        for a in intattrs:
            try:
                if a in curitem:
                    curitem[a] = int(curitem[a])
            except:
                log.append("Item-ID %s: Cannot convert integer attribute %s to an integer. Value: '%s'" % (curitem["id"], a, curitem[a]))
        try:
            items[curitem['id']] = curitem
        except:
            if debug:
                log.append("Error, may be empty string: %s" % curitem)
    return items


# addclientinformation(items, citems, mobs, po)
## Entends the item data with the data collected from the client items.xml.

def addclientinformation(items,citems,mobs,po):
    for i in items:
        if i.id in citems:
            i.imagename=citems[i.id]["image"]
            i.itype=citems[i.id]["type"]
            i.imgurl = i.imagename[0].upper() + i.imagename[1:]
            filen = i.imgurl.split('/')
            filen = filen[len(filen)-1]
            url = i.imgurl.replace(filen, i.name.replace(" ","").lower())+".png"
            if printdyed:
                if i.imgurl.find("|")!=-1:
                    log.append ("dyecmd \""+i.imgurl+"\" colored/"+url)
            url=url.replace('/','-')
            i.wikiimg = "[[Image:%s]]" % url
            imagesused.add(citems[i.id]["image"])
            if po and citems[i.id]["description"]!="" and citems[i.id]["description"] in po:
                i.description = po[citems[i.id]["description"]]
            else:
                i.description = citems[i.id]["description"]
            if po and citems[i.id]["name"] in po:
                i.translatename = po[citems[i.id]["name"]]
            else:
                i.translatename = ""
            i.clientname = citems[i.id]["name"]
            if po and citems[i.id]["effect"]!="" and citems[i.id]["effect"] in po:
                i.effect = po[citems[i.id]["effect"]]
            else:
                i.effect = citems[i.id]["effect"]
            i.hp = citems[i.id]["hp"]
            i.mp = citems[i.id]["mp"]
            i.str = citems[i.id]["str"]
            i.agi = citems[i.id]["agi"]
            i.vit = citems[i.id]["vit"]
            i.dex = citems[i.id]["dex"]
            i.int = citems[i.id]["int"]
            i.luck = citems[i.id]["luck"]
            if i.id in mobs[0]:
                i.rare = mobs[1][mobs[0].index(i.id)]
            else:
                i.rare = -1
        else:
            i.itype= ''
            i.imgurl = ''
            i.description = ''
            i.clientname = ''



# gettypedir (items)
## Returns sorted lists of items by itemtype
def gettypedir(items):
    items.sort(key=lambda x: x.price+x.sell)

    typedir = whatever()
    typedir.healthy = []
    typedir.status = []
    typedir.h1weapons = []
    typedir.h2weapons = []
    typedir.ammo = []
    typedir.helms = []
    typedir.legs = []
    typedir.boots = []
    typedir.shield = []
    typedir.gloves = []
    typedir.rings = []
    typedir.charms = []
    typedir.armor = []
    typedir.dye = []
    typedir.flower = []
    typedir.easter = []
    typedir.halloween = []
    typedir.christmas = []
    typedir.other = []
    for item in items:
        if item.imgurl.strip() or item.clientname.strip():
            if item.id in not_show:
                continue
            elif item.id in custom_armors:
                typedir.armor.append(item)
            elif item.id in custom_boots:
                typedir.boots.append(item)
            elif item.id in custom_charms:
                typedir.charms.append(item)
            elif item.id in custom_christmas:
                typedir.christmas.append(item)
            elif item.id in custom_dyes:
                typedir.dye.append(item)
            elif item.id in custom_easter:
                typedir.easter.append(item)
            elif item.id in custom_flowers:
                typedir.flower.append(item)
            elif item.id in custom_gloves:
                typedir.gloves.append(item)
            elif item.id in custom_halloween:
                typedir.halloween.append(item)
            elif item.id in custom_helms:
                typedir.helms.append(item)
            elif item.id in custom_legs:
                typedir.legs.append(item)
            elif item.id in custom_rings:
                typedir.rings.append(item)
            elif item.id in custom_shield:
                typedir.shield.append(item)
            elif item.id in custom_status:
                typedir.status.append(item)
            elif item.atk > 0:
                if item.defense == 0:
                    if item.range == 0:
                        typedir.ammo.append(item)
                    else:
                        if item.itype == "equip-2hand":
                            typedir.h2weapons.append(item)
                        elif item.itype == "equip-1hand":
                            typedir.h1weapons.append(item)
            elif item.defense > 0: 
                if item.itype == "equip-arms": 
                    typedir.gloves.append(item)
                elif item.itype == "equip-feet": 
                    typedir.boots.append(item)
                elif item.itype == "equip-head": 
                    typedir.helms.append(item)
                elif item.itype == "equip-legs": 
                    typedir.legs.append(item)
                elif item.itype == "equip-torso": 
                    typedir.armor.append(item)
                elif item.itype == "equip-shield": 
                    typedir.shield.append(item)
            elif "sc_start" not in item.usescript and (item.hp != 0 or item.mp != 0):
                typedir.healthy.append(item)
            elif "sc_start" in item.usescript:
                typedir.status.append(item)
            elif item.itype == "equip-ring":
                typedir.rings.append(item)
            elif item.itype == "equip-charm":
                typedir.charms.append(item)
            else: typedir.other.append(item)

    typedir.h1weapons.sort(key=lambda x: (x.atk, int(x.price), x.id))
    typedir.h2weapons.sort(key=lambda x: (x.atk, int(x.price), x.id))
    typedir.ammo.sort(key=lambda x: (int(x.price), x.id))
    typedir.armor.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.gloves.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.boots.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.helms.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.legs.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.shield.sort(key=lambda x: (x.defense, int(x.mbonus), int(x.price), x.id))
    typedir.dye.sort(key=lambda x: (int(x.price), x.id))
    typedir.flower.sort(key=lambda x: (x.id))
    typedir.easter.sort(key=lambda x: (int(x.price), x.id))
    typedir.halloween.sort(key=lambda x: (int(x.price), x.id))
    typedir.christmas.sort(key=lambda x: (int(x.price), x.id))
    typedir.healthy.sort(key=lambda x: (int(x.hp), int(x.mp), int(x.price), x.id))
    typedir.rings.sort(key=lambda x: (int(x.price), x.id))
    typedir.charms.sort(key=lambda x: (int(x.price), x.id))
    typedir.status.sort(key=lambda x: x.id)
    typedir.other.sort(key=lambda x: (int(x.price), x.id))

    return typedir
    
# printlog()
## Prints the global variable log to stdout
def printlog():
    global log
    if len(log) > 0:
        print ("\n---------------------------------------")
    for line in log:
        print (line)


# print<>items(items, title)
## Creates the table in wikicode, depending on what kind of item is being printed

def getmoneystring(buy, sell):
    return ""
def getidstring(id):
    return '<span style="color:#969696;">(%d)</span>' % id

def getmstats(eff, stat):
    out = ""
    ff = eff.find(stat)
    if ff!=-1:
        fs = eff.find(' ', ff+len(stat)+1)
        if fs!=-1:
            out = eff[ff:fs]
        else:
            out = eff[ff:]
    return out
def geteffect(item):
    status = "" 
    mstat = ""
    effc = item.effect
    if effc != "":
        mstat = getmstats(effc, MAtk)
        effc = effc.replace(mstat, '')
        s = getmstats(effc, MDef)
        effc = effc.replace(s, '')
        if len(s)>0:
            if len(mstat)>0:
                mstat += " / "+s
            else:
                mstat = s
    if effc != "":
        effc = effc.replace(CDmg, 'CrDa3')
        effc = effc.replace(CDef, 'CrDf3')
        effc = effc.replace(SDmg+' +'+str(item.atk), '')
        effc = effc.replace(SDmg+' +?', '')
        effc = effc.replace(SDef+' +'+str(item.defense), '')
        effc = effc.replace(SRng+' '+str(item.range), '')
        effc = effc.replace('CrDa3', CDmg)
        effc = effc.replace('CrDf3', CDef)
        while effc.find(' /  / ')!=-1:
            effc = effc.replace(' /  / ', ' / ')
        if len(effc)>0:
            while effc[0]==" " or effc[0]=="/" or effc[0]==",":
                effc = effc[1:]
                if len(effc)==0:
                    break
        if len(effc)>0:
            while effc[len(effc)-1]==" " or effc[len(effc)-1]=="/" or effc[len(effc)-1]==",":
                effc = effc[:-1]
                if len(effc)==0:
                    break
    if item.str != 0:
        if item.str < 0:
            stats = SStr+" %d" % item.str
        else:
            stats = SStr+" +%d" % item.str
    else:
        stats = ""
    if item.agi != 0:
        if stats != "":
            stats += " / "
        if item.agi < 0:
            stats += SAgi+" %d" % item.agi
        else:
            stats += SAgi+" +%d" % item.agi
    if item.vit != 0:
        if stats != "":
            stats += " / "
        if item.vit < 0:
            stats += SVit+" %d" % item.vit
        else:
            stats += SVit+" +%d" % item.vit
    if item.dex != 0:
        if stats != "":
            stats += " / "
        if item.dex < 0:
            stats += SDex+" %d" % item.dex
        else:
            stats += SDex+" +%d" % item.dex
    if item.int != 0:
        if stats != "":
            stats += " / "
        if item.int < 0:
            stats += SInt+" %d" % item.int
        else:
            stats += SInt+" +%d" % item.int
    if item.luck != 0:
        if stats != "":
            stats += " / "
        if item.luck < 0:
            stats += SLuk+" %d" % item.luck
        else:
            stats += SLuk+" +%d" % item.luck
    if effc != "" and stats != "":
        effc = stats+' / '+effc
    elif stats != "":
        effc = stats
    if len(mstat) != 0:
        status = '<br /><span style="font-size: smaller; color:#007700;">%s</span>' % mstat
    if len(effc) != 0:
        status += '<br /><span style="font-size:smaller; color:#ad1818;">%s</span>' % effc
    return status

def getrare(item):
    out = ""
    if item.rare!=-1:
        if item.rare>100:
            out = RFDrop
        else:
            out = RRDrop
    id = item.name.replace(" ","")
    if id in custom_rare:
        ar = custom_rare.get(id)
        for i in ar:
            if len(i)>1:
                if out != "":
                    if i[0]=="b" or i[0]=="c" or i[0]=="d":
                        out = ", "+out
                    elif i[0]!="e":
                        out +=", "
                if i[0]=="b":
                    out = RBuy+out
                elif i[0]=="c":
                    out = ("[[%s|%s]]" % (i[1], RCraft))+out
                elif i[0]=="d":
                    out = ("[[%s|%s]]" % (i[1], RColor))+out
                elif i[0]=="g":
                    out += "[[%s|%s]]" % (i[1], RGMEvent)
                elif i[0]=="G":
                    out += "[[Game Masters|Game Master]] only"
                elif i[0]=="j":
                    out += "[[Dev:Joining the project|%s]]" % RSQuest
                elif i[0]=="n":
                    out += RNlobt
                elif i[0]=="o":
                    out += RUnobt
                elif i[0]=="t":
                    out += "[[%s|%s]]" % (i[1], RTail)
                elif i[0]=="s":
                    if i[1]!="":
                        out += "{{H:title|%s|%s}}" % (i[1], RSpell)
                    else:
                        out += RSpell
                elif i[0]=="q":
                    out += "[[%s|%s]]" % (i[1], RQuest)
                elif i[0]=="i":
                    out += "[[Aidan And Ishi's Monster Points|%s]]" % RIshi
                elif i[0]=="r":
                    out += RUnrel
                elif i[0]=="e":
                    out += "<br /><span style=\"font-size: smaller; color:#ad1818;\">%s</span>" % i[1]
    return out

def dategenerate():
    print ("<!-- Page last generated on %s -->\n" % datetime.date.today())

def printhealitems(items,title):
    print ('==%s==' % title)
    print (tableborder)
    # Print labels
    for title in health_titles:
        if health_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif health_titles.index(title)==len(health_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead,title))
    cnt = 0    
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id),geteffect(i)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s %s' % (cellstyle,i.clientname,getidstring(i.id),geteffect(i)))
        print ('%s | %d' % (cellstyle,i.hp))
        print ('%s | %d' % (cellstyle,i.mp))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle, i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()

def printstatusitems(items,title):
    print ('==%s==\n' % title)
    print (tableborder)
    for title in status_titles:
        if status_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif status_titles.index(title)==len(status_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead, title))
    cnt = 0
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s' % (cellstyle,i.clientname,getidstring(i.id)))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle, i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,i.effect))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()

def printweaponitems(items, title):
    print ('==%s==\n' % title)
    print (tableborder)
    for title in weapon_titles:
        if weapon_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif weapon_titles.index(title)==len(weapon_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead, title))
    cnt = 0
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))    
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id),geteffect(i)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s %s' % (cellstyle,i.clientname,getidstring(i.id),geteffect(i)))
        print ('%s | %d ' % (cellstyle,i.atk))
        print ('%s | %d ' % (cellstyle,i.range))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle,i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()

def printammoitems(items, title):
    print ('==%s==\n' % title)
    print (tableborder)
    for title in ammo_titles:
        if ammo_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif ammo_titles.index(title)==len(ammo_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead, title))
    cnt = 0
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id),geteffect(i)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s %s' % (cellstyle,i.clientname,getidstring(i.id),geteffect(i)))
        print ('%s | %d ' % (cellstyle,i.atk))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle,i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()
    
def printarmoritems(items, title):
    print ('==%s==\n' % title)
    print (tableborder)
    for title in armor_titles:
        if armor_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif armor_titles.index(title)==len(armor_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead, title))
    cnt = 0
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))    
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id),geteffect(i)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s %s' % (cellstyle,i.clientname,getidstring(i.id),geteffect(i)))
        print ('%s | %d ' % (cellstyle,i.defense))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle,i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()

def printotheritems(items, title):
    print ('==%s==' % title)
    print (tableborder)
    for title in other_titles:
        if other_titles.index(title)==0:
            print ('%s | %s' % (tableheadf,title))
        elif other_titles.index(title)==len(other_titles)-1:
            print ('%s | %s' % (tableheadl,title))
        else:
            print ('%s | %s' % (tablehead,title))
    cnt = 0
    for i in items:
        if cnt % 2 != 0:
            cellstyle = tablerowodd
        else:
            cellstyle = tableroweven
        print ('|-')
        print ('%s | %s' % (cellstyle,i.wikiimg))
        if i.translatename:
            print ('%s | \'\'\'[[%s%s|{{H:title|%s|%s}}]]\'\'\' %s %s' % (cellstyle,TCode,i.clientname,i.clientname,i.translatename,getidstring(i.id),geteffect(i)))
        else:
            print ('%s | \'\'\'[[%s]]\'\'\' %s %s' % (cellstyle,i.clientname,getidstring(i.id),geteffect(i)))
        print ('%s | %d GP<br>%d gp' % (cellstyle, i.price,i.sell))
        print ('%s | %d' % (cellstyle, i.weight))
        print ('%s | %s' % (cellstyle,i.description))
        print ('%s | %s' % (cellstyle,getrare(i)))
        cnt += 1
    print ('|}\n')
    dategenerate()

def parsepo (po):
    ar = {}
    mode = 0
    for line in po:
        if "msgid" in line:
            id = line[line.find("\"")+1:-2]
            mode = 1
        elif "msgstr" in line:
            data = line[line.find("\"")+1:-2]
            mode = 2
        elif mode == 1 and "\"" in line:
            id += line[line.find("\"")+1:-2]
        elif mode == 2 and "\"" in line:
            data+= line[line.find("\"")+1:-2]
        elif mode == 2:
            ar[id] = data
            mode = 0
    return ar

def getfileext(file):
    ext = file.split(".")
    ext = ext[len(ext)-1]
    return ext

#####################################################################
#  MAIN
#####################################################################

try:
    po = ""
    if len(sys.argv) == 1:
        item_db = "item_db.txt"
        item_xml = "items.xml"
        mob_db = "mob_db.txt"
    elif  len(sys.argv) == 2 and getfileext(sys.argv[1])=="po":
        item_db = "item_db.txt"
        item_xml = "items.xml"
        mob_db = "mob_db.txt"
        po = sys.argv[1]
    elif len(sys.argv) == 3:
        item_db = sys.argv[1]
        item_xml = sys.argv[2]
        mob_db = "mob_db.txt"
    elif len(sys.argv) == 4:
        item_db = sys.argv[1]
        item_xml = sys.argv[2]
        if getfileext(sys.argv[3])=="po":
            po = sys.argv[3]
            mob_db = "mob_db.txt"
        else:
            mob_db = sys.argv[3]
    elif len(sys.argv) == 5:
        item_db = sys.argv[1]
        item_xml = sys.argv[2]
        mob_db = sys.argv[3]
        po = sys.argv[4]
    else: 
        item_db = ''
        item_xml = ''
        mod_db = ''
        print ("Wrong number of arguments")

    splitidb = 0
    splitmdb = 0
    if item_db and not os.path.isfile(item_db):
        print ("File does not exist: %s" % item_db)
    if item_xml and not os.path.isfile(item_xml):
        print ("File does not exist: %s" % item_xml)
    if mob_db and not os.path.isfile(mob_db):
        print ("File does not exist: %s" % mob_db)
    wdir = os.getcwd()
    if item_db and os.path.isdir(item_db):
        splitidb = 1
    elif not os.path.isfile(item_db):
        item_db = wdir+"/items"
        splitidb = 1
    if splitidb:
        print ("Search split item_db files in: %s" % item_db)
        os.chdir(item_db)
        item_db = ""
        for fname in glob.glob("item_db_*.txt"):
            item_db += (open(fname).read())
            print ("Found file: %s" % fname)
        os.chdir(wdir)
    elif item_db and item_xml and os.path.isfile(item_db) and os.path.isfile(item_xml):
        item_db = open(item_db).read()
    if mob_db and os.path.isdir(mob_db):
        splitmdb = 1
    elif not os.path.isfile(mob_db):
        mob_db = wdir+"/items"
        splitmdb = 1
    if splitmdb:
        print ("Search split mob_db files in: %s" % mob_db)
        os.chdir(mob_db)
        mob_db = ""
        for fname in glob.glob("mob_db_*.txt"):
            mob_db += (open(fname).read())
            print ("Found file: %s" % fname)
        os.chdir(wdir)
    elif mob_db and os.path.isfile(mob_db):
        mob_db = open(mob_db).read()
    if splitmdb and not mob_db:
        print ("Not found mob_db")
    if os.path.isfile(po):
        po = codecs.open(po, encoding='utf-8')
    else:
        po = ""
    if not (item_db and item_xml):
        print ("\nUSAGE:")
        print ("dbtowiki without any arguments will use item_db.txt or search files \"item_db_*.txt\" in \"items\" directory and items.xml in the current directory.")
        print ("to specify custom files, call: dbtowiki <item_db> <item_xml> [<mob_db>]")
        exit(-1)
    else:
#        log.append("Item-list [item_db] = %s" % item_db)
#        log.append("Item-list [item_xml] = %s" % item_xml)
        not_show = parseshowitems(not_show)
        if po:
            po = parsepo(po)
        mobs = parsemonsters(mob_db)
        items = parseitems(item_db)
        f = open(item_xml)
        citems = parsexmlitems(f)
        addclientinformation(items, citems, mobs, po)
        typedir = gettypedir(items)
        if len(typedir.healthy) > 0: printhealitems(typedir.healthy, "Health")
        if len(typedir.status) > 0: printstatusitems(typedir.status, "Status")
        if len(typedir.h1weapons) > 0: printweaponitems(typedir.h1weapons, "1-Handed Weapons")
        if len(typedir.h2weapons) > 0: printweaponitems(typedir.h2weapons, "2-Handed Weapons")
        if len(typedir.ammo) > 0: printammoitems(typedir.ammo, "Ammo")
        if len(typedir.helms) > 0: printarmoritems(typedir.helms, "Helmets")
        if len(typedir.legs) > 0: printarmoritems(typedir.legs, "Legs")
        if len(typedir.armor) > 0: printarmoritems(typedir.armor, "Armors")
        if len(typedir.boots) > 0: printarmoritems(typedir.boots, "Boots")
        if len(typedir.shield) > 0: printarmoritems(typedir.shield, "Shields")
        if len(typedir.gloves) > 0: printarmoritems(typedir.gloves, "Gloves")
        if len(typedir.rings) > 0: printotheritems(typedir.rings, "Rings")
        if len(typedir.charms) > 0: printotheritems(typedir.charms, "Charms")
        if len(typedir.dye) > 0: printotheritems(typedir.dye, "Dyes")
        if len(typedir.flower) > 0: printotheritems(typedir.flower, "Flowers")
        if len(typedir.easter) > 0: printotheritems(typedir.easter, "Easter")
        if len(typedir.halloween) > 0: printotheritems(typedir.halloween, "Halloween")
        if len(typedir.christmas) > 0: printotheritems(typedir.christmas, "Christmas")
        if len(typedir.other) > 0: printotheritems(typedir.other, "Other")
        print ("\n")
finally:
    printlog()