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

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 48 CC 2 SCAR 11.0
CC
2
Cov
0%
new
6.0
number
2.0
session
2.0
CRAP 3.0
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::GaugeLevel
16 # Handles a horizontal level in a 'main' window gauge
17  
18 { package Games::Axmud::Obj::GaugeLevel;
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::Strip::GaugeBox->addGaugeLevel
34 # Prepare a new instance of the Axmud gauge level object which handles a single level
35 # (horizontal region) of gauges text or graphical gauges, belonging to a single session,
36 # in the 'main' window
37 #
38 # Expected arguments
39 # $session - The calling GA::Session
40 # $number - Unique number for this gauge level (unique across all sessions)
41 #
42 # Return values
43 # 'undef' on improper arguments
44 # Blessed reference to the newly-created object on success
45  
46 my ($class, $session, $number, $check) = @_;
47  
48 # Check for improper arguments
49 if (! defined $class || ! defined $session || ! defined $number || defined $check) {
50  
51 return $axmud::CLIENT->writeImproper($class . '->new', @_);
52 }
53  
54 # Setup
55 my $self = {
56 _objName => $number,
57 _objClass => $class,
58 _parentFile => undef, # No parent file
59 _parentWorld => undef, # No parent world
60 _privFlag => FALSE, # All IVs are public
61  
62 # Object IVs
63 # ----------
64  
65 # Unique number for this gauge level
66 number => $number,
67 # The number of the GA::Session that's responsible for keeping the gauge up-to-date
68 session => $session,
69  
70 # Hash of GA::Obj::Gauge objects drawn on this gauge level. Hash in the form
71 # $gaugeHash{unique_number} = gauge_object
72 # ...where 'unique_number' is the gauge object's number, unique across all sessions
73 gaugeHash => {},
74 };
75  
76 # Bless the object into existence
77 bless $self, $class;
78 return $self;
79 }
80  
81 ##################
82 # Methods
83  
84 ##################
85 # Accessors - set
86  
87 ##################
88 # Accessors - get
89  
90 sub number
91 { $_[0]->{number} }
92 sub session
93 { $_[0]->{session} }
94  
95 sub gaugeHash
96 { my $self = shift; return %{$self->{gaugeHash}}; }
97 }
98  
99 # Package must return a true value
100 1