RCP/Setup.pm

filter: Statementstmt 80.8% 38 / 47 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 100% 4 / 4 totaltotal 81.9% 50 / 61 CC 6 SCAR 15.1
CC
6
Cov
82%
load_custom
12.0
load_defaults
4.0
get_schema
2.0
CRAP 4.5
↑ Summary RCP/Database/Result/HazardSet.pm »
1 package Games::Framework::RCP::Setup;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Sub::Exporter -setup => { exports => [ qw(login get_schema load_defaults load_custom) ] };
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Games::Framework::RCP::Database;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our $VERSION = '0.12';
11  
12 3 my $schema;
13  
14 2 ▶sub login {
Subroutine login: called CC=1 SCAR=0.0
Pod documented
15 2 $schema = Games::Framework::RCP::Database->connect( shift, shift, shift, shift, shift );
16 2 return $schema;
17 }
18  
19 0 ▶sub get_schema {
Subroutine get_schema: not called CC=1 SCAR=6.9
Pod documented
20 0 return $schema;
21 }
22  
23 1 ▶sub load_defaults {
Subroutine load_defaults: called CC=4 SCAR=13.9
Pod documented
24 1 $schema->populate('VarBool', [
25 [qw/name value/],
26 ['colors_on', 1],
27 ['join_time', 0],
28 ['opposite_status_allowed', 1],
29 ['poison_undead_hurts', 1],
30 ['regen_undead_heals', 0],
31 ['ct_decays_past_zero', 0],
32 ['stop_stops_status', 1],
33 ['frozen_stops_status', 0],
34 ['ko_removes_effects', 1],
35 ['seizure_undead_heals', 0],
36 ['poison_every_x_ticks', 1],
37 ['variable_haste', 1],
38 ['variable_slow', 1],
39 ['variable_regen', 1],
40 ['variable_poison', 1],
41 ['in_battle', 0],
42 ['turnorder_shows_status', 0],
43 ]);
44
45 1 $schema->populate('VarInt', [
46 [qw/name value/],
47 ['fight_length', 0],
48 ['poison_tick_checkpoint', 5],
49 ['crit_rule', 1],
50 ['ct_while_dead', 0],
51 ['turn_at_ct', 500],
52 ]);
53
54 1 $schema->populate('VarReal', [
55 [qw/name value/],
56 ['old_crit_threshold', 20],
57 ['haste_boost_percent', 20],
58 ['slow_penalty_percent', 20],
59 ['haste_boost_flex_percent', 5],
60 ['slow_penalty_flex_percent', 5],
61 ['regen_boost_percent', 10],
62 ['poison_penalty_percent', 10],
63 ['regen_boost_flex_percent', 2.5],
64 ['poison_penalty_flex_percent', 2.5],
65 ['crit_save_hp', 0.01],
66 ['safeguard_protection', 80],
67 ['adeath_protection', 80],
68 ]);
69
70
71 1 my %basic = (
72 name => 'Basic',
73 description => 'Nothing fancy, this class represents what just about everyone can do.',
74 kind => {name => 'Unlocked', description => 'Everyone can play this class upon joining the battle.'},
75 hp => 50,
76 mp => 50,
77 pp => 50,
78 spd => 50,
79 patk => 50,
80 matk => 50,
81 pdef => 50,
82 mdef => 50,
83 pacc => 50,
84 macc => 50,
85 pevd => 50,
86 mevd => 50,
87 );
88
89 1 $schema->resultset('Class')->create(\%basic);
90
91 1 my $job_id = $schema->resultset('Class')->single({ name => 'Basic' })->id_class;
92
93 1 $schema->populate('MoveCost', [
94 [qw/name description/],
95 ['mp', 'This move costs a certain amount of mp.'],
96 ['pp', 'This move costs a certain amount of pp.'],
97 ['hp', 'This move costs a certain amount of hp.'],
98 ['exp', 'This move costs a certain amount of exp. Usually from primary job.'],
99 ]);
100
101 1 my $cost_id = $schema->resultset('MoveCost')->single({name => 'mp'})->id_move_cost;
102
103 1 $schema->populate('MoveType', [
104 [qw/name description/],
105 ['Action', 'A normal type of move.'],
106 ['Support', 'A skill that activates automatically at certain points. Can be turned off when required.'],
107 ['Reaction', 'A skill that must be called in reaction to an event.'],
108 ]);
109
110 1 my $type_id = $schema->resultset('MoveType')->single({name => 'Action'})->id_move_type;
111
112 1 my @moves = (
113 {
114 name => 'Fight',
115 fkey_move_type => $type_id,
116 power => 10,
117 description => 'A basic physical attack on the opponent.',
118 },
119 {
120 name => 'Chi Burst',
121 fkey_move_type => $type_id,
122 power => 10,
123 description => 'A basic magical attack on the opponent.',
124 },
125 {
126 name => 'Pick Up',
127 fkey_move_type => $type_id,
128 description => 'Pick up an item off the arena floor.',
129 },
130 {
131 name => 'Wait',
132 fkey_move_type => $type_id,
133 description => 'Do nothing this turn. Advantages? Well, there are a few...',
134 },
135 );
136
137 1 foreach my $type_id (@moves)
138 {
139 4 $schema->resultset('Move')->create($type_id);
140
141 4 my $move_id = $schema->resultset('Move')->single({name => $type_id->{name}})->id_move;
142
143 4 $schema->resultset('ClassMove')->create({
144 fkey_class => $job_id,
145 fkey_move => $move_id,
146 });
147
148 4 ▶ if ($type_id->{name} eq 'Chi Burst')
Branch: 1 branch
BranchTrueFalseTotal
if ($type_id->{"name"} eq "Chi Burst") 1 3 4
149 {
150 1 $schema->resultset('MoveWithCost')->create({
151 fkey_move => $move_id,
152 fkey_move_cost => $cost_id,
153 value => 5,
154 });
155 }
156 }
157
158 1 my @usages = (
159 {
160 name => 'Immediate Use',
161 abbr => '[IU]',
162 description => 'Upon touching/taking this item, it is immediately used on the carrier.',
163 },
164 {
165 name => 'Immediate Use OK',
166 abbr => '[IU OK]',
167 description => 'Upon touching/taking this item, it can be immediately used by the carrier.',
168 },
169 {
170 name => 'Full Turn',
171 description => 'Using this item requires taking the full turn.',
172 },
173 {
174 name => 'Reaction',
175 abbr => '[React]',
176 description => 'This item is only used as a reaction to an event.',
177 },
178 );
179
180 1 foreach my $u_id (@usages)
181 {
182 4 $schema->resultset('ItemUsage')->create($u_id);
183 }
184
185 1 return 'Defaults loaded.';
186 }
187  
188 sub load_custom
189 0 ▶{
Subroutine load_custom: not called CC=3 SCAR=24.8
Pod documented
190 0 my $custom = shift;
191 0 foreach my $tablename (keys %{$custom} )
192 {
193 0 my $table = $custom->{$tablename};
194 0 foreach my $row (@{$table})
195 {
196 0 $schema->resultset($tablename)->update_or_create($row);
197 }
198 }
199
200 0 return 'Customs loaded.';
201 }
202  
203 3 1;
204  
205 __END__
↑ Summary RCP/Database/Result/HazardSet.pm »