adonthell-devel
[Top][All Lists]
Advanced

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

Re: [Adonthell-devel] A little Skill system check...


From: Kai Sterker
Subject: Re: [Adonthell-devel] A little Skill system check...
Date: Tue, 4 Mar 2003 17:03:35 +0100

On Tue, 04 Mar 2003 11:52:56 +0100 Nils Fohrbeck wrote:

> Hi folks!
> 
> Yesterday I started doing some Python. In order to make it more
> interesting I decided to make a little skill checker out of itl. What
> do you guys think? Any comments are welcome...

Pretty cool :). Next practice is doing the same in OO style ;). 

But seriously, did you have some thoughts about characters? Because once
you know the character interface, things could be implemented in a more
abstract fashion.

I imagine that most of the character implementation would be done on
python side, much like it is done with items. Actually, I wanted to
write something about that to the list later on. 

 
> (Ps: It is a Python Script. I would suggest you try it first before
> looking at the source code...)

Why? I've seen much worse. (Like my own first few programs :P)

Just for comparison, here's the skill check method I wrote some time
ago. (Note that it only works for variable skill checks. The other sort
can be easily made on the fly.)

    # -- tests whether a character's skill is high 
    #    enough for the task at hand
    #
    #    rank:      character's rank in the skill to test
    #    required:  number the character must beat to succeed
    #    dice:      number of rolls the character has
    #    faces:     number of sides the dice has
    #
    #    returns    1 if the character succeeds, 0 on failure
    def probe (rank, required, dice = 1, faces = 6):
        if faces < 2: faces = 2
        
        while dice > 0:
            required = required - rank * random.randrange (1, faces, 1)
            dice = dice - 1
        
        return (required <= 0)

Kai




reply via email to

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