Acme-Llama
view release on metacpan or search on metacpan
lib/Acme/Llama.pm view on Meta::CPAN
Too much food makes a sad llama though. :(
No one likes a sad llama.
[Technical details: returns 1 for a happy hungry llama, and returns
for a big full llama. ]
=cut
sub feed {
$llama{'foodage'}++;
if ( $llama{'foodage'} < 10 ) { $llama{'happiness'}++ and return 1; }
else { $llama{'happiness'}-- and return; }
}
=item B<play>
A good llama trainer should play often with their llama,
as this makes them happy.
Llamas get tired though, and then they don't like to play,
they need rest instead then.
[Technical details: returns 1 for a llama that wants to play more,
and returns for a llama that needs a nap. ]
=cut
sub play {
if ( $llama{'tired'} == 1 ) {
$llama{'happiness'} - 5;
return;
}
my $int = int( rand(20) );
$llama{'happiness'} + 2;
if ( $int > 10 ) {
$llama{'tired'} = 1;
return;
}
else {
$llama{'tired'} = 0;
return 1;
}
}
=item B<nap>
Sometimes, even the big llamas get tired.
When llamas are tired, they need a nap to make them
feel better! But, if the llama isn't tired, making it
try to take a nap will make it a sad llama. :(
=cut
sub nap {
if ( $llama{'tired'} == 0 ) { $llama{'happiness'}--; return; }
else { $llama{'tired'} = 0 and $llama{'happiness'}++; return 1; }
}
=item B<sacrifice>
Ah, we finally have reached the last goal of all good llamas. Sacrificing to the Perl gods.
You'd best hope your llama was happy enough, or death to your Perl script will come! :(
=back
=cut
sub sacrifice {
my ( $self, %args ) = @_;
$args{'TO'} ||= '';
if ( lc( $args{'TO'} ) ne 'perl gods' ) {
die('Who are you sacrificing this llama to?');
}
if ( $llama{'happiness'} > 10 ) {
print(
"Congratulations. Your sacrifical llama has appeased the Perl gods!\n"
);
exit;
}
else {
die(
"Sorry, your llama was not happy enough. Try to raise it better next time! :("
);
}
}
1;
=head1 AUTHOR
Alexandria Marie Wolcott <alyx@cpan.org>
=head1 LICENSE
Copyright (c) Alexandria Marie Wolcott
This module may be used, modified, and distributed under BSD license. See the beginning of this file for said license.
=head1 SEE ALSO
L<http://enwp.org/llama>
=cut
( run in 3.978 seconds using v1.01-cache-2.11-cpan-364913b4093 )