From 30c4f4929dbda1c32cf176eaaae811724009084e Mon Sep 17 00:00:00 2001 From: Alex Kerr Date: Thu, 22 Jan 2015 12:40:56 +0000 Subject: [PATCH] Renamed 'Classes' class, use class methods --- lib/OSRIC/Character.pm | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/OSRIC/Character.pm b/lib/OSRIC/Character.pm index 55b2415..b5f8931 100644 --- a/lib/OSRIC/Character.pm +++ b/lib/OSRIC/Character.pm @@ -1,15 +1,15 @@ package OSRIC::Character; -use OSRIC::Classes; -use OSRIC::Classes::Assassin; -use OSRIC::Classes::Cleric; -use OSRIC::Classes::Druid; -use OSRIC::Classes::Fighter; -use OSRIC::Classes::Illusionist; -use OSRIC::Classes::MagicUser; -use OSRIC::Classes::Paladin; -use OSRIC::Classes::Ranger; -use OSRIC::Classes::Thief; +use OSRIC::Class; +use OSRIC::Class::Assassin; +use OSRIC::Class::Cleric; +use OSRIC::Class::Druid; +use OSRIC::Class::Fighter; +use OSRIC::Class::Illusionist; +use OSRIC::Class::MagicUser; +use OSRIC::Class::Paladin; +use OSRIC::Class::Ranger; +use OSRIC::Class::Thief; use OSRIC::Util qw/d/; use JSON qw/encode_json/; @@ -20,9 +20,9 @@ sub new my $class = shift; my $character = { + irc => "", # The player's irc nick, not found on the character sheet. personal => { - irc => "", # The player's irc nick, not found on the character sheet. name => "", classes => [ ], alignment => "", @@ -82,11 +82,12 @@ sub generate_gold my $self = shift; # Get the classes and sort by the highest starting gold (see page 28): - my @sorted = sort { $a->max_starting_gold <=> $b->max_starting_gold } - @{$self->{personal}->{classes}}; + my @sorted = sort { "OSRIC::Class::$a"->max_starting_gold <=> + "OSRIC::Class::$b"->max_starting_gold } + @{$self->{personal}->{classes}}; # Generate the starting gold: - $self->{wealth}->{coins} = $classes[0]->get_gold; + $self->{wealth}->{coins} = "OSRIC::Class::$classes[0]"->get_gold; } # Encodes the character to JSON: