Thou yeasty elf-skinned baggage!
With my last post I managed to apply a role to an instance of a class. What I think this will allow me to do is keep my base 'classes' from sprawling out of control while also encapsulation a good number of Game Rules' (or Biz Rules) in to small parts that I can easily reuse.
So far it has handled things quite well and even taught me a few things and I think has really exposed what Roles can do in Moose. Now as my D&D story moves along I am about to jump into what I think is going to be the to big test for Moose.
Character Races??
The differing races bring a new level of complexity to the game, well except mundane old humans who, unlike the other races, get no extra abilities, bonuses, penalties or alike.
In game play one selects one's 'Race' before a 'Character Class' so I jumped ahead a little by starting with a fighter first but I did learn a few lessons there that I can apply here.
There are a few rules when selecting race, there are a few basic minimums that must be met for example a Dwarf cannot be a player character with a strength score of 7 or lower likewise their Constitution musb be greater than 11. Their maximum score for Dexterity is 17 and 16 for Charisma.
The rules do state that a Dwarf (or any race for that matter) Character can have a higher value than the maximum but to the game they have the max. This is where the initial die roles come back into play as a Dwarf with say 18 initial score for Charisma can only have the 8 human henchmen of 16 ability but she could attractant 7 more henchmen if the rest where dwarfs? So me deciding to keep those scores around will come in handy.
I do not think I am back to this stage as now that I know I can add roles to roles and then add roles to instances I can just keep my 'Character' as it an add in a 'Dwarf' role and not extend my 'Character' class with the Dwarf 'Class'.
Fortunately in game play the 'Racial' Bonus (Constitution +1, Charisma -1 for Dwarfs) is applied once at character creation so one should never see it applied to an instance of a Dwarf class.
So here are extra abilities that Dwarf 'Character' will have.
Maximum of 17 Dexterity and 16 Charisma.
Saving throw bonus against Magic wands, staves, rods and spells
Saving throw bonus against poison
Will speak dwarven, gnome, kobold, orcish and common and can learn 2 more languages if inelegance allows
Infravision
miner (a big one with to many details for this post)
+ 1 to hit half-orcs, goblins, hobgoblins and orcs
So quite allot to look at for our 'Dwarf' role so how about this to start.
Add in a 'race' attribute in my Character class like this
package Character;
use Moose;
has 'race' =>(
is =>'ro',
isa =>'Str',
);
then
I can try this to start with a BUILD
sub BUILD {
my $self = shift;
my ($attr) = @_;
if ($self->race() eq 'Dwarf'){
Dwarf->meta->apply($self);
$self->dexterity(17)
if $self->dexterity() >17;
$self->Charisma(16)
if $self->Charisma() >16;
$self->languages([Language::dwarven->new(), Language::gnome->new(), Language::kobold->new(), Language::orcish->new(), Language::Common->new()])
};
};
Now that give me my Dwarf Role loading which has some of the more generic common bits in it, I am setting my max values and then my language but his to me is looking a little less like Moose and more like trad OO Perl.
If I go on like this I will have a big huge BEGIN with all the race stuff clumping in there. The Dwarf Class almost makes sense again??
Oh well something for the next post to see if it is even possible just to add in the 'Dwarf' role and have it set some of the instance data from inside a role.
Leave a comment