From: Aldric Giacomoni Date: 2009-11-18T04:12:10+09:00 Subject: Re: Newbie question: Defining a numeric type Seebs wrote: > On 2009-11-17, Brian Candler wrote: >> 1. Whilst you want the individual stats to behave as integers, you >> probably don't want the entire Character to behave as an integer - the >> Character is likely to have many other attributes, such as 'name' in the >> above example. So, whenever you deal with individual stats, you are >> always going to do c.str or c.str=val. This is a convenient place to >> masquerade the Stat. > > Actually, yes. Why not take a step back and have "stat" be a hash of all the stats? @stat = { :strength => { :base_value => 15, :mods => { :race => 2 }, :current_value => 17 } This way you "need" Alucard.stat[:strength].current_value, but you can fix that with custom methods / method_missing to become Alucard.strength. This way if you need to compare Alucard.stat[:strength] and Maria.stat[:strength], you can do a custom comparison for whatever sub-stat you want -- and you can write a single comparison method for all your stats. I'm sort of showing up after the war, here, but I really fail to understand WHAT we're arguing about if not a design decision. -- Posted via http://www.ruby-forum.com/.