On 2009-11-17, Brian Candler <b.candler / pobox.com> wrote:
> ISTM that you are over-complicating. str, dex and con are individual 
> attributes of the character and can be just Fixnums.

Except they can't, because a character doesn't just have a current
str, but also a internal base str, a series of possible modifiers,
some of which have their own internal state, a history of the highest
base str (which may not be the same as the current base str), a current
total value (which could be calculated by examining the others)...

> This is the solution I posted before - what's the problem with it?

Look at the stuff about modifiers.

john.wisdom.modify("drunk", "-3")

For this to work, "wisdom" needs to know both the unmodified value and
its current set of modifiers, in order to figure out its current total.

> class Stats
>   attr_accessor :str, :dex, :con
>   def initialize(str, dex, con)
>     @str, @dex, @con = str, dex, con
>     @max_str, @max_dex, @max_con = str, dex, con
>   end

If I'm going to have a bunch of things (9ish, I think) all of which
have the same semantics (a stored maximum value, etcetera), it seems
to me that they are sort of like a set of objects with similar
characteristics...  Which is to say, a class.

I'm pretty sure I really do want to have these things have non-trivial
internal state.

-s
-- 
Copyright 2009, all wrongs reversed.  Peter Seebach / usenet-nospam / seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!