| 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::Protect | ||
| 16 | # Handles protected objects | ||
| 17 | |||
| 18 | { package Games::Axmud::Obj::Protect; | ||
| 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 | # Prepare a new instance of the protected model object (which enjoys semi-protection against | ||
| 34 | # being sold by Axmud tasks) | ||
| 35 | # | ||
| 36 | # Expected arguments | ||
| 37 | # $session - The parent GA::Session (not stored as an IV) | ||
| 38 | # | ||
| 39 | # Return values | ||
| 40 | # 'undef' on improper arguments | ||
| 41 | # Blessed reference to the newly-created object on success | ||
| 42 | |||
| 43 | my ($class, $session, $check) = @_; | ||
| 44 | |||
| 45 | # Check for improper arguments | ||
| 46 | if (! defined $class || ! defined $session || defined $check) { | ||
| 47 | |||
| 48 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 49 | } | ||
| 50 | |||
| 51 | # Setup | ||
| 52 | my $self = { | ||
| 53 | _objName => 'protect_obj', | ||
| 54 | _objClass => $class, | ||
| 55 | _parentFile => 'otherprof', | ||
| 56 | _parentWorld => $session->currentWorld->name, | ||
| 57 | _privFlag => FALSE, # All IVs are public | ||
| 58 | |||
| 59 | # Object IVs (match IVs used by GA::Generic::ModelObj) | ||
| 60 | # ---------------------------------------------------- | ||
| 61 | |||
| 62 | noun => undef, | ||
| 63 | categoryList => [], # Equivalent of GA::Generic::ModelObj->category | ||
| 64 | otherNounList => [], | ||
| 65 | adjList => [], | ||
| 66 | pseudoAdjList => [], | ||
| 67 | unknownWordList => [], | ||
| 68 | }; | ||
| 69 | |||
| 70 | # Bless the object into existence | ||
| 71 | bless $self, $class; | ||
| 72 | return $self; | ||
| 73 | } | ||
| 74 | |||
| 75 | ################## | ||
| 76 | # Methods | ||
| 77 | |||
| 78 | ################## | ||
| 79 | # Accessors - set | ||
| 80 | |||
| 81 | ################## | ||
| 82 | # Accessors - get | ||
| 83 | |||
| 84 | sub noun | ||
| 85 | { $_[0]->{noun} } | ||
| 86 | sub categoryList | ||
| 87 | { my $self = shift; return @{$self->{categoryList}}; } | ||
| 88 | sub otherNounList | ||
| 89 | { my $self = shift; return @{$self->{otherNounList}}; } | ||
| 90 | sub adjList | ||
| 91 | { my $self = shift; return @{$self->{adjList}}; } | ||
| 92 | sub pseudoAdjList | ||
| 93 | { my $self = shift; return @{$self->{pseudoAdjList}}; } | ||
| 94 | sub unknownWordList | ||
| 95 | { my $self = shift; return @{$self->{unknownWordList}}; } | ||
| 96 | } | ||
| 97 | |||
| 98 | # Package must return a true value | ||
| 99 | 1 |