Acme-Hospital-Bed
view release on metacpan or search on metacpan
#!perl
use Acme::Hospital::Bed;
Acme::Hospital::Bed->start;
lib/Acme/Hospital/Bed.pm view on Meta::CPAN
],
[
"Hello, I'm not fine.",
"Where is my mind?",
]
];
}
return $self;
}
sub start {
my $self = shift;
unless (ref $self) {
$self = __PACKAGE__->new;
}
$self->next_patient;
}
sub available_rooms {
return $_[0]->{total_num_of_rooms} - scalar @{$_[0]->{rooms}};
}
lib/Acme/Hospital/Bed.pm view on Meta::CPAN
=cut
=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
use Acme::Hospital::Bed;
Acme::Hospital::Bed->start;
...
Acme::Hospital::Bed->new(
total_num_of_beds => 30,
lifes => 5,
names => [qw/tom richard joy/],
phrases => [
[
"Hello, I am fine.",
lib/Acme/Hospital/Bed.pm view on Meta::CPAN
"Where is my mind?",
],
[
"Hello, This is not fine.",
"Where is my mind?",
],
[
"Are you being dishonest?",
]
]
)->start;
=head1 DESCRIPTION
Acme::Hospital::Bed is a simple command line Q/A game.
The basic gameplay is the following:
A patient is generated with a random 'illness' level of 1 to 10 and a phrase that is associated to this level.
The player then decides y(yes) or n(no) to check the patient into a hospital bed.
lib/Acme/Hospital/Bed.pm view on Meta::CPAN
Configure the total number of lifes the player is allowed. The default is 3.
=head3 names
Configure the list of names used to generate patients. This is expected as an ArrayRef.
=head3 phrases
Configure the list of phrases for each 'health' level. This is expected as an ArrayRefs of ArraysRefs(aoa);
=head2 start
This method can be used to Start the game. You can either call this directly or after new.
Acme::Hospital::Bed->start;
Acme::Hospital::Bed->new(%options)->start;
=head2 next_patient
This method can also be used to start the game. If passed a true param it will return after the first itteration else it will loop untill the game is finished.
Acme::Hospital::Bed->new(%options)->next_patient();
...
Acme::Hospital::Bed->new(%options)->next_patient(1);
=head2 available_rooms
This method will return the number of available rooms left for the current game.
$ahb->available_rooms;
( run in 0.252 second using v1.01-cache-2.11-cpan-0d8aa00de5b )