|
|
1 | # |
|
|
2 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
|
|
3 | # |
|
|
4 | # Copyright (©) 2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
5 | # |
|
|
6 | # Deliantra is free software: you can redistribute it and/or modify it under |
|
|
7 | # the terms of the Affero GNU General Public License as published by the |
|
|
8 | # Free Software Foundation, either version 3 of the License, or (at your |
|
|
9 | # option) any later version. |
|
|
10 | # |
|
|
11 | # This program is distributed in the hope that it will be useful, |
|
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
14 | # GNU General Public License for more details. |
|
|
15 | # |
|
|
16 | # You should have received a copy of the Affero GNU General Public License |
|
|
17 | # and the GNU General Public License along with this program. If not, see |
|
|
18 | # <http://www.gnu.org/licenses/>. |
|
|
19 | # |
|
|
20 | # The authors can be reached via e-mail to <support@deliantra.net> |
|
|
21 | # |
|
|
22 | |
1 | =head1 NAME |
23 | =head1 NAME |
2 | |
24 | |
3 | cf::match - object matching language |
25 | cf::match - object matching language |
4 | |
26 | |
5 | =head1 DESCRIPTION |
27 | =head1 DESCRIPTION |
… | |
… | |
92 | Not that C<not> only negates a condition and not the whole match |
114 | Not that C<not> only negates a condition and not the whole match |
93 | expressions, thus |
115 | expressions, thus |
94 | |
116 | |
95 | not applied in inv |
117 | not applied in inv |
96 | |
118 | |
97 | is true if there is I<any> non-object in the inventory. To negate a whole |
119 | is true if there is I<any> non-applied object in the inventory. To negate |
98 | match, you have to use a sub-match. To check whether there is I<no> |
120 | a whole match, you have to use a sub-match: To check whether there is |
99 | applied object in someones inventory, write this: |
121 | I<no> applied object in someones inventory, write this: |
100 | |
122 | |
101 | not (applied in inv) |
123 | not (applied in inv) |
102 | |
124 | |
103 | Example: match applied weapons. |
125 | Example: match applied weapons. |
104 | |
126 | |
105 | applied type=WEAPON |
127 | applied type=WEAPON |
106 | |
128 | |
107 | Example: match horns or rods. |
129 | Example: match horns or rods. |
108 | |
130 | |
109 | type=HORN or type=ROD |
131 | type=HORN or type=ROD |
|
|
132 | |
|
|
133 | Example: see if the originator is a player. |
|
|
134 | |
|
|
135 | type=PLAYER of originator |
110 | |
136 | |
111 | =item in ... |
137 | =item in ... |
112 | |
138 | |
113 | The in operator takes the context set and modifies it in various ways. As |
139 | The in operator takes the context set and modifies it in various ways. As |
114 | a less technical description, think of the C<in> as being a I<look into> |
140 | a less technical description, think of the C<in> as being a I<look into> |
… | |
… | |
362 | operator = '=' | '==' | '!=' | '<' | '<=' | '>' | '>=' |
388 | operator = '=' | '==' | '!=' | '<' | '<=' | '>' | '>=' |
363 | |
389 | |
364 | expr = flag |
390 | expr = flag |
365 | | sattr |
391 | | sattr |
366 | | aattr '[' <constant> ']' |
392 | | aattr '[' <constant> ']' |
|
|
393 | | 'stat.' statattr |
367 | | special |
394 | | special |
368 | | func '(' args ')' |
395 | | func '(' args ')' |
369 | | '{' perl code block '}' |
396 | | '{' perl code block '}' |
370 | |
397 | |
371 | func = <any function name> |
398 | func = <any function name> |
372 | sattr = <any scalar object attribute> |
399 | sattr = <any scalar object attribute> |
373 | aattr = <any array object attribute> |
400 | aattr = <any array object attribute> |
374 | flag = <any object flag> |
401 | flag = <any object flag> |
|
|
402 | statattr = <any stat attribute: exp, food, str, dex, hp, maxhp...> |
375 | special = <any ()-less "function"> |
403 | special = <any ()-less "function"> |
376 | |
404 | |
377 | constant = <number> | '"' <string> '"' | <uppercase cf::XXX name> |
405 | constant = <number> | '"' <string> '"' | <uppercase cf::XXX name> |
378 | args = <depends on function> |
406 | args = <depends on function> |
379 | |
407 | |
… | |
… | |
447 | die "number, string or uppercase constant name expected\n"; |
475 | die "number, string or uppercase constant name expected\n"; |
448 | } |
476 | } |
449 | |
477 | |
450 | our $flag = $cf::REFLECT{object}{flags}; |
478 | our $flag = $cf::REFLECT{object}{flags}; |
451 | our $sattr = $cf::REFLECT{object}{scalars}; |
479 | our $sattr = $cf::REFLECT{object}{scalars}; |
|
|
480 | # quick hack to support archname, untested |
|
|
481 | $sattr->{archname} = "W"; |
452 | our $aattr = $cf::REFLECT{object}{arrays}; |
482 | our $aattr = $cf::REFLECT{object}{arrays}; |
|
|
483 | our $lattr = $cf::REFLECT{living}{scalars}; |
453 | |
484 | |
454 | sub expr { |
485 | sub expr { |
455 | # ws done by factor |
486 | # ws done by factor |
456 | my $res; |
487 | my $res; |
457 | |
488 | |
… | |
… | |
459 | # perl |
490 | # perl |
460 | |
491 | |
461 | my $expr = $1; |
492 | my $expr = $1; |
462 | |
493 | |
463 | $res .= $expr =~ /\{([^;]+)\}/ ? $1 : "do $expr"; |
494 | $res .= $expr =~ /\{([^;]+)\}/ ? $1 : "do $expr"; |
|
|
495 | |
|
|
496 | } elsif (/\Gstats\.([A-Za-z0-9_]+)/gc) { |
|
|
497 | |
|
|
498 | if (exists $lattr->{$1}) { |
|
|
499 | $res .= "\$_->stats->$1"; |
|
|
500 | } elsif (exists $lattr->{"\u$1"}) { |
|
|
501 | $res .= "\$_->stats->\u$1"; |
|
|
502 | } else { |
|
|
503 | die "living statistic name expected (str, pow, hp, sp...)\n"; |
|
|
504 | } |
464 | |
505 | |
465 | } elsif (/\G([A-Za-z0-9_]+)/gc) { |
506 | } elsif (/\G([A-Za-z0-9_]+)/gc) { |
466 | |
507 | |
467 | if (my $func = $func{$1}) { |
508 | if (my $func = $func{$1}) { |
468 | /\G\s*\(/gc |
509 | /\G\s*\(/gc |
… | |
… | |
675 | |
716 | |
676 | $res |
717 | $res |
677 | } |
718 | } |
678 | |
719 | |
679 | if (0) {#d# |
720 | if (0) {#d# |
680 | die parse 1, 'applied in inv'; |
721 | die parse 1, 'stats.pow'; |
681 | exit 0; |
722 | exit 0; |
682 | } |
723 | } |
683 | |
724 | |
684 | our %CACHE; |
725 | our %CACHE; |
685 | |
726 | |