No Grot is Good Grot

On one of my earlier posts I mentioned a Grot character, in other words a set of ability rolls that can not result in a playable character.

dice_and_men.jpg


After a few dead ends and a little frustration I think I can now use the visitor pattern to check and see if I have a Grot before I go forward.

So All I really need to do is add into each of my 'Ability' classes the rule that applies for it. Using good old strength again the rule is a roll under 6 means you can only be a MU (Magic User) as well if you are going to me a MU you must have intelligence over 8.
So in each 'Ability' class I have an 'is_grot' which tests for its grot condition. So in each of my Abblitiy classes I add something like this


sub is_grot {
my $self = shift;
my ($attr) = @_;
return 1
if ($attr->{strength} < 9 and $attr->{intelligence} < 5);
return 0;
}

Then in the begin of my 'Creator' class I simply 'Visit' each ability with the in coming ability like this


sub BUILD {
    my $self = shift;
    my ($attr) = @_;
    # $attr->{self} = $self;
    foreach my $ability ((qw(Strength Intelligence Wisdom Charisma Constitution Dexterity ))){
		throw_exception( "NeitherRoleNorRoleNameIsGiven", {message=>"There can be no 'Class' for this set of ability rolls?"})
			if ($self->$ability->is_grot($attr));

}


and if there is a 'Grot' combination it will simply fail. So I did that and it works;


my $str = RPG::ADD::Creator->new({strength=>5,
        intelligence=>8,
	dexterity=>12,
	constitution=>9,
	charisma=>8,
	wisdom=>12,
	});


There can be no 'Class' for this set of ability rolls? at C:\Dwimperl\perl\site\lib\Moose\Exception.pm line 37
Moose::Exception::_...

There are a number of other rules that may preclude a 'Class' choice (you should have at least a 9 in one ability) but as 'race' can effect the above rolls they still may be choice for a 'Class' after a 'race' is chosen this rule just weeds out the really bad rolls (and rare as the chance of not getting at least one 9, 10 or 11 are very very slim )

Well onto race next and then only 600 more pages of rules.


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations