blib/lib/Games/Axmud/Obj/SkillHistory.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 61 CC 2 SCAR 9.6
CC
2
Cov
0%
new
6.0
skill
2.0
advanceMethod
2.0
CRAP 2.6
1 # Copyright (C) 2011-2024 A S Lewis
2 #
3 # This program is free software: you can redistribute it and/or modify it under the terms of the GNU
4 # General Public License as published by the Free Software Foundation, either version 3 of the
5 # License, or (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
8 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License along with this program. If not,
12 # see <http://www.gnu.org/licenses/>.
13 #
14 #
15 # Games::Axmud::Obj::SkillHistory
16 # Object storing details of the character's history of advancing skills
17  
18 { package Games::Axmud::Obj::SkillHistory;
19  
20 use strict;
21 use warnings;
22 # use diagnostics;
23  
24 use Glib qw(TRUE FALSE);
25  
26 our @ISA = qw(Games::Axmud);
27  
28 ##################
29 # Constructors
30  
31 sub new {
32  
33 # Called by GA::Task::Advance->doStage
34 # Creates a new instance of the skill history object
35 #
36 # Expected arguments
37 # $session - The parent GA::Session (not stored as an IV)
38 # $skill - The skill that was being advanced, at the moment this object was created
39 #
40 # Return values
41 # 'undef' on improper arguments
42 # Blessed reference to the newly-created object on success
43  
44 my ($class, $session, $skill, $check) = @_;
45  
46 # Check for improper arguments
47 if (! defined $class || ! defined $session || ! defined $skill || defined $check) {
48  
49 return $axmud::CLIENT->writeImproper($class . '->new', @_);
50 }
51  
52 # Setup
53 my $self = {
54 _objName => $skill,
55 _parentFile => 'otherprof',
56 _parentWorld => $session->currentWorld->name,
57 _objClass => $class,
58 _privFlag => FALSE, # All IVs are public
59  
60 # IVs
61 # ---
62  
63 # The skill advanced
64 skill => $skill,
65 # How the skill was advanced ('order' because of the guild profile's ->advanceOrderList,
66 # 'cycle' because of the guild profile's ->advanceCycleList, or 'manual' because the
67 # user advanced manually, either because the lists are empty or because the user wants
68 # to ignore them
69 advanceMethod => 'manual', # Default value
70  
71 # The skill's level at the time of being advanced
72 skillLevel => 0,
73 # How many times the skill had been advanced, after this advance
74 skillAdvanceCount => 0,
75 # XP spent advancing the skill this time (0 if unknown)
76 skillThisXP => 0,
77 # XP needed to advance the skill, next time (0 if unknown)
78 skillNextXP => 0,
79 # Cash spent advancing the skill this time (0 if unknown)
80 skillThisCash => 0,
81 # Cash needed to adance the skill, next time (0 if unknown)
82 skillNextCash => 0,
83 };
84  
85 # Bless the object into existence
86 bless $self, $class;
87 return $self;
88 }
89  
90 ##################
91 # Methods
92  
93 ##################
94 # Accessors - set
95  
96 ##################
97 # Accessors - get
98  
99 sub skill
100 { $_[0]->{skill} }
101 sub advanceMethod
102 { $_[0]->{advanceMethod} }
103  
104 sub skillLevel
105 { $_[0]->{skillLevel} }
106 sub skillAdvanceCount
107 { $_[0]->{skillAdvanceCount} }
108 sub skillThisXP
109 { $_[0]->{skillThisXP} }
110 sub skillNextXP
111 { $_[0]->{skillNextXP} }
112 sub skillThisCash
113 { $_[0]->{skillThisCash} }
114 sub skillNextCash
115 { $_[0]->{skillNextCash} }
116 }
117  
118 # Package must return a true value
119 1