Parsing Your Character’s Loot
permalink
yesterday at 9:05 am
Here’s a quick teaser for a new project I’m working on, almost ready for public beta.
def loot(character_sheet_file)
@xml ||= Hpricot::XML(character_sheet_file.read)
@loot ||= @xml.search("//LootTally/loot[@count!='0']").map do |item|
res = item.search("//RulesElement")
case res.size
when 0: nil
when 1: coder.decode(res.first.attributes["name"])
when 2: coder.decode(res.last.attributes["name"].sub(res.first.attributes["type"], res.first.attributes["name"]))
else res.map { |re| coder.decode(re.attributes["name"]) }.join(" ")
end
end.compact
end
Character files from D&DI Character Builder store loot as a list, but the names of magic items are concatenated with names of their connected mundane items, so you have to mix them based on the magic item’s @type.
Also, the Character Builder stores every item you’ve ever added, even if you deleted it immediately, so you have to filter out items with a count of zero. You have no way to tell if this was an intentional item purchase, an item accidentally clicked on or a found item from a module, so items with @count=0 are useless.
What could I possibly be building‽‽‽
This entry was posted yesterday at 9:05 am and
is filed under D&D, Web Design/Programming.
You can follow any responses to this entry through
the RSS 2.0 feed. You can leave a response, or
trackback
from your own site.
31 May 2009
Last weekend, at [Gamex][], I spent a grueling three days grinding through [Living Forgotten Realms][lfr] modules in order to level up in time for the convention’s finale: SPEC1-2: Zhent’s Ancient Shadows.
[Gamex]: “One of the three yearly Strategicon Conventions”
[lfr]:
Tagged: D&D | No Comments »
8 March 2009
I took my fiancée to see Watchmen last night. We were unprepared. I give it ★★★★ out of five. Below sums up my thoughts.
It’s violent enough that I cringed. The movie is “patently too adult for … children 17 and under” and the fact that it’s not rated NC-17 is evidence of a moronic and/or [...]
Tagged: Films, Reviews | 1 Comment »
27 January 2009
Six strangers find themselves in the cramped room sitting room of a once-wealthy merchant, who fidgets and stammers through his words. In a nearby city—shrouded in a bizarre permanent darkness—lies his family’s former wealth, and he begs them to return what remains of it. Can these strangers band together to enter the walled Forbidden zones [...]
Tagged: Games | 1 Comment »
17 January 2009
The only person who could summarize the current political situation correctly is John Stewart—reading the future from 2004.
Tagged: Books, Politics | No Comments »