Final Little Moose Droppings

Well I am getting close to finishing off my 'Creator' class that I started in this post I really have only three little parts to add on to get to the end. Character Starting Monies, Alignment, and equipping the character.

Well equipping is more a game play than a character creation part as buying something and stuffing it in your sack happens at any point in the game. So all I will have to do is give the character his starting tithe then let them loose in the store, as everyone knows a fool and his money are quickly parted if that 1th level Magic-User want to blow his wad on Chainmail and a Falchion far be it from me from stopping me from buying it.

Encumberance_loRes.jpg

Equipping and using it is another question and again that belongs in game play so I will defer that till later.

That leaves us with Starting Monies and I really solved that one in this post as this is easily handled in the 'Creator' class with the same pattern I used on the '_build_hps' like this


sub _starting_gp {

use RPG::ADD::Dice;
my $self = shift;
return $self->current_gp()
if ($self->current_gp());
my $gp = 0;
foreach my $player_ class (keys($self->class()){
my $throw = RPG::ADD::Dice->new($player_class->start_gp_roll);
$gp+= $throw->roll();
}

$gp = $gp/scalar(keys($self->class());
$self->current_gp($gp );
return $self->current_gp();

}

So that leaves only alignment left. Well with this we know that some "Character Classes" can only be a either a single alignment such as a Druid that must be 'True Neutral' or Paladin that can only be 'Lawful Good' the rest sort of fall in between the two but there can only be 1 alignment per character but is is a role or an attribute.

Well it is an attribute as it is only a guide line for the person playing the character and does not impart some sort of skill (except a language) and the DM (the game in this case) will have to keep a record of how well the player plays the alignment.

So if I create a simple base alignment class like this for now, later I can add in all the other things an alignment class might need.


package RPG::ADD::Alignment;
use Moose;
has 'name' =>(
	is    =>'ro',
	isa  =>'Str",
);

sub 'is_good' =>(
is =>'ro',
isa=>'Bool'
);

sub 'is_lawful' =>(
is =>'ro',
isa=>'Bool'
);

sub 'is_neutral' =>(
is =>'ro',
isa=>'Bool'
);


Then a simple class for each 'Alignment' like this


package RPG::ADD::Alignment::LawfulGood;
use Moose;
extends 'RPG::ADD::Alignment';

has '+name' =>(
default =>'Lawful Good',
);

sub '+is_good' =>(
default =>1
);

sub '+is_lawful' =>(
default =>1
);

sub 'is_neutral' =>(
default =>0
);

alignment-doctorwho.jpg

The when It comes time to 'pick' an alignment the choices open for my character I will have a class so I can reuse the 'Visitor' pattern again as I did in this post and then sprinkle a few 'can_be_alignment' subs for each class.

Well now I all I have to put it all together and build a test suite and presto I am done ;)


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