Theory and documentation

Version history and plans





SourceForge homepage Logo

Last updated: 2004-02-27

The character framework

    Status: Mature
    Introduced in: 0.0
    Refactorings: 1
    Developed by: Treefinger
    Latest iteration in: 0.1
    Latest iteration by: Treefinger


The character inherits all its graphics functionality from the moveable graphical object. It then adds functionality to contain skills and attributes, to define a body and to have an inventory.


Haphazard makes a simple distinction between skills and attributes, an attribute is a skill with no parent skill. Now, this indicates that there are some form of skill tree in Haphazard which is exactly the case. Each skill is defined to have a parent skill, the parent skill gives a base chance for the skill. For each level of subskill the skills should get more specialized and easier to learn. All skills are in this iteration only defined as a simple <name, description, value> tuple with methods to handle experience gained. They are structured the same way as items with a common name and then a fly weight to represent it.


To be able to represent to hit locations, Haphazard introduces a "body" concept. A body consists of one or more body parts, each of these body parts can have different attributes/implementations. An example of implemented body parts is the torso (or breast as it is named), the torso is quite easy to hit which is represented by how many slots it takes up, it can also take a bit of damage which is represented in it's damage table. Heads on the other hand is quite vulnerable and hard to hit. Arms have the added option of holding an item. To make a monster, it's just to take whatever body parts that take your fancy and put them together in some bizarr way. To hit tables, wounds and so on will be handled automatically.


The inventory is a marvel of invention, it actually takes one step closer to a real world inventory, for good or bad. It tries to take into account weight and dimensions. A normal human with two hands and no clothes what so ever, is only able to carry two things (unless they are very small...). To be able to carry more, the human needs to have someplace to stash things. This is where clothes and items come in, these can be defined as "containers". A container can hold other things, so if you wear a pair of trousers, and these contain pockets. You can stash some things in your pockets. A backpack will allow you to stash more things in there.

The problem with this approach is that it becomes much more time consuming to pack and to find things in your inventory. To help a bit we've implemented algorithms that use heuristics and try to put things in a good place. What we're missing right now is some sort of manual packing utility that allows one to pack where one wants. There are three (five) planned algorithms for packing; Random, BestFit, RelaxedBestFit (Manual, Optimal). The only one currently implemented is the BestFit algorithm, that places the object in the container which free space best matches the objects volume/dimension.

A container can also be specialized, thus allowing only certain types of items to be packed in them. This is to allow for scabbards, money pouches, etc...