From: Aldric Giacomoni Date: 2010-03-30T04:06:45+09:00 Subject: Re: Question: Dynamic code execution Thorsten Hater wrote: > 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. Things which will be crucial to you here are going to be extending modules and classes, as well as inheritance. class Race MAX_SKILL_LEVEL = 10 end class Elf < Race MAX_SKILL_LEVEL += 1 end Race::MAX # => 10 Elf::MAX # => 11 And you can also specify unique skill levels (for instance, your Swordmanship max skill may be 22 because of a unique sword you have, it doesn't raise EVERY skill max...) Does that help a little? -- Posted via http://www.ruby-forum.com/.