File Coverage

blib/lib/WWW/MetaForge/ArcRaiders/Result/Arc.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition 7 8 87.5
subroutine 4 4 100.0
pod 1 1 100.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             package WWW::MetaForge::ArcRaiders::Result::Arc;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: Arc (mission/event) result object
4             our $VERSION = '0.002';
5 6     6   350827 use Moo;
  6         6078  
  6         49  
6 6     6   4185 use Types::Standard qw(Str Int ArrayRef HashRef Maybe);
  6         148427  
  6         59  
7 6     6   19129 use namespace::clean;
  6         20153  
  6         60  
8              
9             has id => (
10             is => 'ro',
11             isa => Str,
12             required => 1,
13             );
14              
15             has name => (
16             is => 'ro',
17             isa => Str,
18             required => 1,
19             );
20              
21             has type => (
22             is => 'ro',
23             isa => Maybe[Str],
24             );
25              
26             has description => (
27             is => 'ro',
28             isa => Maybe[Str],
29             );
30              
31             has maps => (
32             is => 'ro',
33             isa => ArrayRef[Str],
34             default => sub { [] },
35             );
36              
37             has duration => (
38             is => 'ro',
39             isa => Maybe[Int],
40             );
41              
42             has cooldown => (
43             is => 'ro',
44             isa => Maybe[Int],
45             );
46              
47             has loot => (
48             is => 'ro',
49             isa => ArrayRef[HashRef],
50             default => sub { [] },
51             );
52              
53             has xp_reward => (
54             is => 'ro',
55             isa => Maybe[Int],
56             );
57              
58             has coin_reward => (
59             is => 'ro',
60             isa => Maybe[Int],
61             );
62              
63             has last_updated => (
64             is => 'ro',
65             isa => Maybe[Str],
66             );
67              
68             has _raw => (
69             is => 'ro',
70             isa => HashRef,
71             );
72              
73             sub from_hashref {
74 19     19 1 41304 my ($class, $data) = @_;
75              
76 19 100 66     85 my $maps = $data->{maps} // ($data->{map} ? [$data->{map}] : []);
77              
78             return $class->new(
79             id => $data->{id},
80             name => $data->{name},
81             type => $data->{type},
82             description => $data->{description},
83             maps => $maps,
84             duration => $data->{duration},
85             cooldown => $data->{cooldown} // $data->{frequency},
86             loot => $data->{loot} // [],
87             xp_reward => $data->{xpReward},
88             coin_reward => $data->{coinReward},
89             last_updated => $data->{lastUpdated},
90 19   100     589 _raw => $data,
      100        
91             );
92             }
93              
94             1;
95              
96             __END__
97              
98             =pod
99              
100             =encoding UTF-8
101              
102             =head1 NAME
103              
104             WWW::MetaForge::ArcRaiders::Result::Arc - Arc (mission/event) result object
105              
106             =head1 VERSION
107              
108             version 0.002
109              
110             =head1 SYNOPSIS
111              
112             my $arcs = $api->arcs(includeLoot => 'true');
113             for my $arc (@$arcs) {
114             say $arc->name . " on " . join(", ", $arc->maps->@*);
115             }
116              
117             =head1 DESCRIPTION
118              
119             Represents an ARC (mission/event) from the ARC Raiders game.
120              
121             =head2 id
122              
123             Arc identifier.
124              
125             =head2 name
126              
127             Arc name.
128              
129             =head2 type
130              
131             Arc type (e.g., "MajorEvent", "MinorEvent").
132              
133             =head2 description
134              
135             Arc description text.
136              
137             =head2 maps
138              
139             ArrayRef of map names where this arc occurs.
140              
141             =head2 duration
142              
143             Duration in seconds.
144              
145             =head2 cooldown
146              
147             Cooldown between occurrences in seconds.
148              
149             =head2 loot
150              
151             ArrayRef of loot drops: C<[{ item => "Name", chance => 0.15 }]>.
152              
153             =head2 xp_reward
154              
155             Experience points reward.
156              
157             =head2 coin_reward
158              
159             Coin reward.
160              
161             =head2 last_updated
162              
163             ISO timestamp of last data update.
164              
165             =head2 from_hashref
166              
167             my $arc = WWW::MetaForge::ArcRaiders::Result::Arc->from_hashref(\%data);
168              
169             Construct from API response. Handles both C<map> and C<maps> fields.
170              
171             =head1 SUPPORT
172              
173             =head2 Issues
174              
175             Please report bugs and feature requests on GitHub at
176             L<https://github.com/Getty/p5-www-metaforge/issues>.
177              
178             =head2 IRC
179              
180             You can reach Getty on C<irc.perl.org> for questions and support.
181              
182             =head1 CONTRIBUTING
183              
184             Contributions are welcome! Please fork the repository and submit a pull request.
185              
186             =head1 AUTHOR
187              
188             Torsten Raudssus <torsten@raudssus.de>
189              
190             =head1 COPYRIGHT AND LICENSE
191              
192             This software is copyright (c) 2026 by Torsten Raudssus.
193              
194             This is free software; you can redistribute it and/or modify it under
195             the same terms as the Perl 5 programming language system itself.
196              
197             =cut