adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Adonthell-devel] New character test


From: Kai Sterker
Subject: Re: [Adonthell-devel] New character test
Date: Tue, 11 Mar 2003 17:24:38 +0100

On Mon, 10 Mar 2003 19:22:01 +0100 Alexandre Courbot wrote:

> > Next thing is the advancement data, which is now read from a file
> > and kept in a global (that is, static) storage class
> > (character.table). Because of that, you'll need Python 2.2 to run
> > the code. I guess the change to v0.4 is a good point to switch to
> > Python 2.2 and drop support for older versions.
> 
> Right. That way we could take advantage of all the improvments
> (including speed) of Python 2.2.

Glad you agree, 'cause with the new version of the character test, this
is what I did :).

The biggest change was to the character base class. The background is
the following:

There are two kinds of attributes: those that have a fixed maximum
value, and those whose maximum is calculated from the current value of
other attributes.

Obviously, those maxima have to be read from two different sources. What
I wanted to achieve is to hide this detail, so that all maxima can be
accessed in the same fashion. At the same time, maxima should be
readonly, so that people couldn't (easily) change them. And finally,
the returned maxima should also include the character specific modifier.

The simple solution would have been to write a lot of methods along the
line of "get_max_strength ()", etc. But I found that not very elegant.
So used the Property feature of Python 2.2, meaning the maxima can be
accessed as attributes (like "MaxStrength"). As the builtin property
class requires a set/get method for each attribute, I extended it, so
you can also pass the name of the attribute to get/set. That way, one
pair of get/set methods is all we need.

The actual attributes are stored in a private dictionary, called
__Attributes. That solves some issues I had with storing them directly
as private variables in __dict__. 

With the above in mind, the character base class should be pretty easy
to understand. I personally find the solution quite elegant. Took me
some time to get it sorted out.


The char_generator test is mostly unchanged. To test the new code, a +1
modifier is randomly added to one of the attributes, and some derived
attributes are displayed.


One more rules related thing. As you might have noticed, if you pass
very low levels to the generator, the creature would often have a health
of 0, meaning it is dead. The solution to this would be a third,
predifined value for each attribute of each type of creature: the
initial rank of the attribute.

When looking at the Character Creation chapter of the rules doc, this is
exactly what Ben described:

    All attributes are set to the following values: 

    Attribute   dwarves   humans   half-elves   elves 
    -------------------------------------------------
    strength       2         3          1         1 
    hardness       3         2          2         2 
    agility        1         2          3         2 
    willpower      2         1          2         3

The same would be done for any other character type as well. I did it
for our test race (Wolf: 1, 1, 2, 0), so in the new version of the test,
it will always have a health of 10 at least.


Something I have to figure out yet is adding of additional attributes in
derived classes. Shouldn't be hard to accomplish, though.

Anyway, have fun with the new test. Hope I can have a go at items and
combat stuff soon.  Methods for equipping/unequipping items are already
in place (in the humanoid class), but not tested yet.

Kai

Attachment: character-test.tar.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]