ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf/match.pm
(Generate patch)

Comparing deliantra/server/lib/cf/match.pm (file contents):
Revision 1.3 by root, Sat Oct 10 05:20:24 2009 UTC vs.
Revision 1.4 by root, Sat Oct 10 05:24:54 2009 UTC

16Match the object if it has an object with name C<force> and 16Match the object if it has an object with name C<force> and
17slaying C<poison> in it's inventory: 17slaying C<poison> in it's inventory:
18 18
19 has (name = "force" and slaying = "poison") 19 has (name = "force" and slaying = "poison")
20 20
21Find all inventory objects with value > 10, which are not invisible: 21Find all inventory objects with value >= 10, which are not invisible:
22 22
23 value > 10 and not invisible in inv 23 value >= 10 and not invisible in inv
24 24
25Find all potions with spell objects inside them in someones inventory: 25Find all potions with spell objects inside them in someones inventory:
26 26
27 type=SPELL in type=POTION in inv 27 type=SPELL in type=POTION in inv
28 28
52 factor = 'not' factor 52 factor = 'not' factor
53 | '(' match ')' 53 | '(' match ')'
54 | expr 54 | expr
55 | expr operator constant 55 | expr operator constant
56 56
57 operator = '=' | '!=' | '>' | '<' | '<=' | '>=' 57 operator = '=' | '==' | '!=' | '<' | '<=' | '>' | '>='
58 58
59 expr = flag 59 expr = flag
60 | sattr 60 | sattr
61 | aattr '[' <constant> ']' 61 | aattr '[' <constant> ']'
62 | special 62 | special
70 special = <any ()-less "function"> 70 special = <any ()-less "function">
71 71
72 constant = <number> | '"' <string> '"' | <uppercase cf::XXX name> 72 constant = <number> | '"' <string> '"' | <uppercase cf::XXX name>
73 args = <depends on function> 73 args = <depends on function>
74 74
75 TODO: repeatedly, env 75 TODO: repeatedly, env, contains, possbly matches
76 76
77=head2 STRUCTURE 77=head2 STRUCTURE
78 78
79The two main structures are the C<select>, which selects objects matching 79The two main structures are the C<select>, which selects objects matching
80various criteria, and the C<match>, which determines if an object matches 80various criteria, and the C<match>, which determines if an object matches
86 86
87This set of context objects can be modified in various ways, for example 87This set of context objects can be modified in various ways, for example
88by replacing it with the inventories of all objects, or all objects on the 88by replacing it with the inventories of all objects, or all objects on the
89same mapspace, and so on, by using the C<in> operator. 89same mapspace, and so on, by using the C<in> operator.
90 90
91Once the set of context objects has been established, each objetc is 91Once the set of context objects has been established, each object is
92matched against the C<match> expression. Sometimes the server is only 92matched against the C<match> expression. Sometimes the server is only
93interested in knowing whether I<anything> matches, and sometimes the 93interested in knowing whether I<anything> matches, and sometimes the
94server is interested in I<all> objects that match. 94server is interested in I<all> objects that match.
95 95
96=head2 OPERATORS 96=head2 OPERATORS
198=item array objects attributes 198=item array objects attributes
199 199
200The C<resist> array can be accessed by specifying C<< resist [ ATNR_type ] 200The C<resist> array can be accessed by specifying C<< resist [ ATNR_type ]
201>>. 201>>.
202 202
203Example: match an acid resitance higher than 30. 203Example: match an acid resistance higher than 30.
204 204
205 resist[ATNR_ACID] > 30 205 resist[ATNR_ACID] > 30
206 206
207=item functions 207=item functions
208 208
218 218
219You can compare expressions against constants via any of these 219You can compare expressions against constants via any of these
220operators. If the constant is a string, then a string compare will be 220operators. If the constant is a string, then a string compare will be
221done, otherwise a numerical comparison is used. 221done, otherwise a numerical comparison is used.
222 222
223Example: match an object with name "schnops" that has a value > 10. 223Example: match an object with name "schnops" that has a value >= 10.
224 224
225 name="schnops" and value > 10 225 name="schnops" and value >= 10
226 226
227=item uppercase constant names 227=item uppercase constant names
228 228
229Any uppercase word that exists as constant inide the C<cf::> namespace 229Any uppercase word that exists as constant inside the C<cf::> namespace
230(that is, any deliatra constant) can also be used as-is, but needs to be 230(that is, any deliantra constant) can also be used as-is, but needs to be
231specified in uppercase. 231specified in uppercase.
232 232
233Example: match a type of POTION (using C<cf::POTION>). 233Example: match a type of POTION (using C<cf::POTION>).
234 234
235 type=POTION 235 type=POTION
249 249
250True iff the object has a matching inventory object. 250True iff the object has a matching inventory object.
251 251
252=item count(select) 252=item count(select)
253 253
254Number of matching inventory objects. 254Number of matching objects - the context object for the C<select> are the
255original context objects for the overall C<select>. # TODO bullshit
255 256
256=back 257=back
257 258
258=cut 259=cut
259 260
446 while () { 447 while () {
447 if (/\G\s*(inv|env|map)\b/gc) { 448 if (/\G\s*(inv|env|map)\b/gc) {
448 if ($1 eq "inv") { 449 if ($1 eq "inv") {
449 $res .= " map+(${also}\$_->inv),"; 450 $res .= " map+(${also}\$_->inv),";
450 } elsif ($1 eq "env") { 451 } elsif ($1 eq "env") {
451 $res .= " map+(${also}env_chain), "; 452 $res .= " map+(${also}env_chain), "; # TODO
452 } elsif ($1 eq "map") { 453 } elsif ($1 eq "map") {
453 $res .= " map+(${also}\$_->map->at (\$_->x, \$_->y)),"; 454 $res .= " map+(${also}\$_->map->at (\$_->x, \$_->y)),";
454 } 455 }
455 last unless /\G\s*in\b/gc; 456 last unless /\G\s*in\b/gc;
456 } else { 457 } else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines