Created
April 2, 2011 17:02
-
-
Save 0branch/899653 to your computer and use it in GitHub Desktop.
Player.pm, third draft.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Player; | |
use Moose; | |
has 'inventory' => ( | |
handles => { obtain => 'push' }, | |
isa => 'ArrayRef[Entity]', | |
default => sub { [] }, | |
traits => ['Array'], | |
is => 'ro', | |
); | |
sub list_inventory { | |
my $self = shift; | |
my @inv = @{ $self->inventory }; | |
return "You are carrying nothing." unless @inv; | |
my $output = "You are currently carrying:\n"; | |
$output .= ("* " . $_->name . "\n") foreach(@inv); | |
return $output; | |
} | |
no Moose; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment