… | |
… | |
4 | |
4 | |
5 | =cut |
5 | =cut |
6 | |
6 | |
7 | package Deliantra; |
7 | package Deliantra; |
8 | |
8 | |
9 | our $VERSION = '1.23'; |
9 | our $VERSION = '1.25'; |
10 | |
10 | |
11 | use strict; |
11 | use common::sense; |
12 | |
12 | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use File::Spec; |
16 | use File::Spec; |
… | |
… | |
151 | boat => MOVE_BOAT, |
151 | boat => MOVE_BOAT, |
152 | ship => MOVE_SHIP, |
152 | ship => MOVE_SHIP, |
153 | all => MOVE_ALL, |
153 | all => MOVE_ALL, |
154 | ); |
154 | ); |
155 | |
155 | |
156 | our @MOVE_TYPE = keys %MOVE_TYPE; |
156 | our @MOVE_TYPE = qw(all walk flying fly_low fly_high swim boat ship); |
157 | |
157 | |
158 | { |
158 | { |
159 | package Deliantra::MoveType; |
159 | package Deliantra::MoveType; |
160 | |
160 | |
161 | use overload |
161 | use overload |
… | |
… | |
182 | $_[0] |
182 | $_[0] |
183 | }, |
183 | }, |
184 | 'eq' => sub { "$_[0]" eq "$_[1]" }, |
184 | 'eq' => sub { "$_[0]" eq "$_[1]" }, |
185 | 'ne' => sub { "$_[0]" ne "$_[1]" }, |
185 | 'ne' => sub { "$_[0]" ne "$_[1]" }, |
186 | ; |
186 | ; |
|
|
187 | |
|
|
188 | sub TO_JSON { |
|
|
189 | $_[0][0] |
|
|
190 | } |
187 | } |
191 | } |
188 | |
192 | |
189 | sub Deliantra::MoveType::new { |
193 | sub Deliantra::MoveType::new { |
190 | my ($class, $string) = @_; |
194 | my ($class, $string) = @_; |
191 | |
195 | |
… | |
… | |
385 | $ob->{$attr} = new Deliantra::MoveType $ob->{$attr}; |
389 | $ob->{$attr} = new Deliantra::MoveType $ob->{$attr}; |
386 | } |
390 | } |
387 | |
391 | |
388 | # convert outdated movement flags to new movement sets |
392 | # convert outdated movement flags to new movement sets |
389 | if (defined (my $v = delete $ob->{no_pass})) { |
393 | if (defined (my $v = delete $ob->{no_pass})) { |
390 | $ob->{move_block} = new Deliantra::MoveType $v ? "all" : ""; |
394 | $ob->{move_block} = new Deliantra::MoveType $v ? "all" : "0"; |
391 | } |
395 | } |
392 | if (defined (my $v = delete $ob->{slow_move})) { |
396 | if (defined (my $v = delete $ob->{slow_move})) { |
393 | $ob->{move_slow} += "walk"; |
397 | $ob->{move_slow} += "walk"; |
394 | $ob->{move_slow_penalty} = $v; |
398 | $ob->{move_slow_penalty} = $v; |
395 | } |
399 | } |
396 | if (defined (my $v = delete $ob->{walk_on})) { |
400 | if (defined (my $v = delete $ob->{walk_on})) { |
397 | $ob->{move_on} ||= new Deliantra::MoveType; if ($v) { $ob->{move_on} += "walk" } else { $ob->{move_on} -= "walk" } |
401 | $ob->{move_on} ||= new Deliantra::MoveType; if ($v) { $ob->{move_on} += "walk" } else { $ob->{move_on} -= "walk" } |
398 | } |
402 | } |
399 | if (defined (my $v = delete $ob->{walk_off})) { |
403 | if (defined (my $v = delete $ob->{walk_off})) { |
400 | $ob->{move_off} ||= new Deliantra::MoveType; if ($v) { $ob->{move_off} += "walk" } else { $ob->{move_off} -= "walk" } |
404 | $ob->{move_off} ||= new Deliantra::MoveType; if ($v) { $ob->{move_off} += "walk" } else { $ob->{move_off} -= "walk" } |
401 | } |
405 | } |
402 | if (defined (my $v = delete $ob->{fly_on})) { |
406 | if (defined (my $v = delete $ob->{fly_on})) { |