… | |
… | |
162 | |
162 | |
163 | use overload |
163 | use overload |
164 | '=' => sub { bless [@{$_[0]}], ref $_[0] }, |
164 | '=' => sub { bless [@{$_[0]}], ref $_[0] }, |
165 | '""' => \&as_string, |
165 | '""' => \&as_string, |
166 | '>=' => sub { $_[0][0] & $MOVE_TYPE{$_[1]} ? $_[0][1] & $MOVE_TYPE{$_[1]} : undef }, |
166 | '>=' => sub { $_[0][0] & $MOVE_TYPE{$_[1]} ? $_[0][1] & $MOVE_TYPE{$_[1]} : undef }, |
|
|
167 | '<=' => sub { |
|
|
168 | ($_[0][0] & $MOVE_TYPE{$_[1]}) == $MOVE_TYPE{$_[1]} |
|
|
169 | ? $_[0][1] & $MOVE_TYPE{$_[1]} |
|
|
170 | : undef |
|
|
171 | }, |
167 | '+=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] |= $MOVE_TYPE{$_[1]}; &normalise }, |
172 | '+=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] |= $MOVE_TYPE{$_[1]}; &normalise }, |
168 | '-=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
173 | '-=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
169 | '/=' => sub { $_[0][0] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
174 | '/=' => sub { $_[0][0] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
170 | 'x=' => sub { |
175 | 'x=' => sub { # toggle between off, + and - |
171 | my $cur = $_[0] >= $_[1]; |
176 | my $cur = $_[0] >= $_[1]; |
172 | if (!defined $cur) { |
177 | if (!defined $cur) { |
173 | if ($_[0] >= "all") { |
178 | if ($_[0] >= "all") { |
174 | $_[0] -= $_[1]; |
179 | $_[0] -= $_[1]; |
175 | } else { |
180 | } else { |
… | |
… | |
810 | $root = $Deliantra::Data::TYPE{Misc}; |
815 | $root = $Deliantra::Data::TYPE{Misc}; |
811 | } |
816 | } |
812 | } |
817 | } |
813 | |
818 | |
814 | my @import = ($root); |
819 | my @import = ($root); |
815 | |
820 | |
816 | unshift @import, \%Deliantra::Data::DEFAULT_ATTR |
821 | unshift @import, \%Deliantra::Data::DEFAULT_ATTR |
817 | unless $type == 116; |
822 | unless $type == 116; |
818 | |
823 | |
819 | my (%ignore); |
824 | my (%ignore); |
820 | my (@section_order, %section, @attr_order); |
825 | my (@section_order, %section, @attr_order); |
… | |
… | |
841 | $section{$name}{$k} ||= $v; |
846 | $section{$name}{$k} ||= $v; |
842 | } |
847 | } |
843 | } |
848 | } |
844 | } |
849 | } |
845 | |
850 | |
|
|
851 | # remove ignores for "root" type |
|
|
852 | for (map @{$_->[1]}, # section attributes |
|
|
853 | [general => ($root->{attr} || [])], |
|
|
854 | @{$root->{section} || []}) |
|
|
855 | { |
|
|
856 | my ($k, $v) = @$_; |
|
|
857 | # skip fixed attributes, if they are ignored thats fine |
|
|
858 | next if $v->{type} eq 'fixed'; |
|
|
859 | |
|
|
860 | delete $ignore{$k}; # if the attributes are defined explicitly they |
|
|
861 | # should NOT be ignored. ignore should mainly |
|
|
862 | # hit imported/inherited attributes. |
|
|
863 | } |
|
|
864 | |
846 | $attr->{section} = [ |
865 | $attr->{section} = [ |
847 | map !exists $section{$_} ? () : do { |
866 | map !exists $section{$_} ? () : do { |
848 | my $attr = delete $section{$_}; |
867 | my $attr = delete $section{$_}; |
849 | |
868 | |
850 | [ |
869 | [ |
… | |
… | |
852 | map exists $attr->{$_} && !$ignore{$_} |
871 | map exists $attr->{$_} && !$ignore{$_} |
853 | ? [$_ => delete $attr->{$_}] : (), |
872 | ? [$_ => delete $attr->{$_}] : (), |
854 | @attr_order |
873 | @attr_order |
855 | ] |
874 | ] |
856 | }, |
875 | }, |
857 | |
|
|
858 | exists $section{$_} ? [$_ => delete $section{$_}] : (), |
876 | exists $section{$_} ? [$_ => delete $section{$_}] : (), |
859 | @section_order |
877 | @section_order |
860 | ]; |
878 | ]; |
861 | |
879 | |
862 | $attr |
880 | $attr |