From: Thorsten Hater
Date: 2010-03-30T02:27:54+09:00
Subject: Re: Question: Dynamic code execution
My problem is, how to formulate the rules in ruby?
Let me give an example:
Lets say in an RPG context, the max skill level is 10,
but if the player chooses to be an elf, he gets 11 as a
max skill level in bow shooting. Additionally there
exists something like a special feature which increases
the max skill level by another point.
At the moment I'm thinking about a mini DSL based on
method_missing, but I'm looking for alternatives.
Aldric Giacomoni wrote:
> Thorsten Hater wrote:
>
>> Hi
>>
>> I'm currently writing a small game application in ruby.
>> The problem is, not all of the rules are static, meaning some
>> of the actions in the game are allowed to change them.
>> My question is, what is the best and safest way to implement this
>> feature?
>> Specifically, I have database of items, which may change parts of
>> the rules upon activation.
>>
>
> Alright.. So store the rules in one or more hashes depending on what
> they are and how they can change, and refer to whatever key you need to
> read the rule (or setting) in the hash.
> That's one way.
>
|