… | |
… | |
16 | Match the object if it has an object with name C<force> and |
16 | Match the object if it has an object with name C<force> and |
17 | slaying C<poison> in it's inventory: |
17 | slaying C<poison> in it's inventory: |
18 | |
18 | |
19 | has (name = "force" and slaying = "poison") |
19 | has (name = "force" and slaying = "poison") |
20 | |
20 | |
21 | Find all inventory objects with value > 10, which are not invisible: |
21 | Find 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 | |
25 | Find all potions with spell objects inside them in someones inventory: |
25 | Find 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 | |
79 | The two main structures are the C<select>, which selects objects matching |
79 | The two main structures are the C<select>, which selects objects matching |
80 | various criteria, and the C<match>, which determines if an object matches |
80 | various criteria, and the C<match>, which determines if an object matches |
… | |
… | |
86 | |
86 | |
87 | This set of context objects can be modified in various ways, for example |
87 | This set of context objects can be modified in various ways, for example |
88 | by replacing it with the inventories of all objects, or all objects on the |
88 | by replacing it with the inventories of all objects, or all objects on the |
89 | same mapspace, and so on, by using the C<in> operator. |
89 | same mapspace, and so on, by using the C<in> operator. |
90 | |
90 | |
91 | Once the set of context objects has been established, each objetc is |
91 | Once the set of context objects has been established, each object is |
92 | matched against the C<match> expression. Sometimes the server is only |
92 | matched against the C<match> expression. Sometimes the server is only |
93 | interested in knowing whether I<anything> matches, and sometimes the |
93 | interested in knowing whether I<anything> matches, and sometimes the |
94 | server is interested in I<all> objects that match. |
94 | server 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 | |
200 | The C<resist> array can be accessed by specifying C<< resist [ ATNR_type ] |
200 | The C<resist> array can be accessed by specifying C<< resist [ ATNR_type ] |
201 | >>. |
201 | >>. |
202 | |
202 | |
203 | Example: match an acid resitance higher than 30. |
203 | Example: 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 | |
219 | You can compare expressions against constants via any of these |
219 | You can compare expressions against constants via any of these |
220 | operators. If the constant is a string, then a string compare will be |
220 | operators. If the constant is a string, then a string compare will be |
221 | done, otherwise a numerical comparison is used. |
221 | done, otherwise a numerical comparison is used. |
222 | |
222 | |
223 | Example: match an object with name "schnops" that has a value > 10. |
223 | Example: 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 | |
229 | Any uppercase word that exists as constant inide the C<cf::> namespace |
229 | Any 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 |
231 | specified in uppercase. |
231 | specified in uppercase. |
232 | |
232 | |
233 | Example: match a type of POTION (using C<cf::POTION>). |
233 | Example: match a type of POTION (using C<cf::POTION>). |
234 | |
234 | |
235 | type=POTION |
235 | type=POTION |
… | |
… | |
249 | |
249 | |
250 | True iff the object has a matching inventory object. |
250 | True iff the object has a matching inventory object. |
251 | |
251 | |
252 | =item count(select) |
252 | =item count(select) |
253 | |
253 | |
254 | Number of matching inventory objects. |
254 | Number of matching objects - the context object for the C<select> are the |
|
|
255 | original 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 { |