--- deliantra/server/lib/cf/match.pm 2009/10/11 23:51:47 1.13 +++ deliantra/server/lib/cf/match.pm 2009/10/12 17:37:43 1.15 @@ -112,16 +112,20 @@ Replaces all objects by their containing object, if they have one. +=item in arch + +Replaces all objects by their archetypes. + =item in map Replaces all objects by the objects that are on the same mapspace as them. -=item in +=item in Finds all context objects matching the condition, and then puts their inventories into the context set. -Note that C is simply a special case of an C<< in >> that +Note that C is simply a special case of an C<< in >> that matches any object. Example: find all spells inside potions inside the inventory of the context @@ -289,14 +293,14 @@ An independent match - semantics like C, except it only matters whether the match finds any object (which is faster). -=item dump +=item dump() Dumps the object to the server log when executed, and evaluates to true. Note that logical operations are short-circuiting, so this only dumps potions: - type=POTION and dump + type=POTION and dump() =back @@ -315,18 +319,18 @@ | chain also deep 'in' set also = nothing | 'also' deep = nothing | 'deep' - set = 'inv' | 'env' | 'map' + set = 'inv' | 'env' | 'arch' | 'map' empty = # boolean matching condition condition = factor - | factor 'and'? cond - | factor 'or' cond + | factor 'and'? condition + | factor 'or' condition factor = 'not' factor - | '(' cond ')' + | '(' condition ')' | expr | expr operator constant @@ -393,12 +397,6 @@ local $all = 0; '(scalar ' . &match ('$_') . ')' }, - ); - - our %special = ( - any => sub { - 1 - }, dump => sub { 'do { warn "cf::match::match dump:\n" @@ -409,6 +407,12 @@ }, ); + our %special = ( + any => sub { + 1 + }, + ); + sub constant { ws; @@ -529,7 +533,8 @@ ws; # first check some stop-symbols, so we don't have to backtrack - if (/\G(?=also\b|deep\b|in\b|of\b\)|$)/gc) { + if (/\G(?=also\b|deep\b|in\b|of\b\)|\z)/gc) { + pos = pos; # argh. the misop hits again. again. again. again. you die. last; } elsif (/\Gor\b/gc) { @@ -559,11 +564,13 @@ if (/\Gin\s+/gc) { my $expand; - if (/\G(inv|env|map)\b/gc) { + if (/\G(inv|env|map|arch)\b/gc) { if ($1 eq "inv") { $expand = "map \$_->inv,"; } elsif ($1 eq "env") { $expand = "map \$_->env // (),"; + } elsif ($1 eq "arch") { + $expand = "map \$_->arch,"; } elsif ($1 eq "map") { $expand = "map \$_->map->at (\$_->x, \$_->y),"; } @@ -612,7 +619,7 @@ eval { $res = cf::match::parser::match "\$object"; - /\G\s*$/gc + /\G$/gc or die "unexpected trailing characters after match\n"; }; @@ -629,7 +636,7 @@ } if (0) {#d# - die parse 'applied', 1; + die parse 'type=SPELL_EFFECT and match(name="bullet" in arch)', 1; exit 0; }