Why are weapons so complicated?
Tags:
Right now I’m working on implementing code so that Treasure Trove and Quartermaster can be filtered by types of weapons, like armor.
Of course, there’s way, way more options for filtering weapons than there are armor… Armor is pretty cut and dry, it’s one of 6 different types. Weapons have a relatively complicated hiererarchy, where each weapon can be contained in multiple different groups (e.g. a halberd is a 2-handed melee weapon, an axe, and a polearm), and there are even some strange special cases (specifically the shuriken– the only light blade ranged weapon).
I’ve actually come up with a relatively simple solution, and now it’s a matter of just slogging through and coding everything. It’s also going to be a pain to figure out how the hell I’m supposed to lay this stuff out when I do add it to those programs… The list is going to be very long and difficult to manage. Not sure exactly how I’ll handle that. I’m thinking one list for the weapon groups, and one list for individual weapons might break it up nicely.
For those curious, here’s what I’ve got so far:
http://www.asmor.com/scripts/4eMagicItems/weaponGroupTest.html

I’m not sure whether you’re looking for a code review, but I’d seriously consider creating a CreateWeaponTreeNode function to make adding a new node one line instead of 3-4. Hopefully it’ll make adding new weapons a lot easier for you when new books come out. Something like (this probably won’t be valid javascript, just pseudocode):
function CreateWeaponTreeNode(name, parents) {
newNode=new weaponTreeNode("greataxe")
newNode.parents=parents
if (parents.length > 0)
parents[0].children[parents[0].children.length]=newNode
return newNode;
}
// Example call (not sure about the syntax for passing the array)
greataxe = CreateWeaponTreeNode("greataxe", [axeGrp, twoHmelee]);Gregor LeBlaque’s last blog post..Full-party Initiative
Actually I’d come up with pretty much the exact same solution last night while laying in bed. Gives me an excuse to learn how (or if?) Javascript supports overloaded functions…