--- deliantra/server/lib/cf/match.pm 2009/10/11 18:18:03 1.11
+++ deliantra/server/lib/cf/match.pm 2009/11/03 23:44:21 1.24
@@ -1,3 +1,25 @@
+#
+# This file is part of Deliantra, the Roguelike Realtime MMORPG.
+#
+# Copyright (©) 2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+#
+# Deliantra is free software: you can redistribute it and/or modify it under
+# the terms of the Affero GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the Affero GNU General Public License
+# and the GNU General Public License along with this program. If not, see
+# .
+#
+# The authors can be reached via e-mail to
+#
+
=head1 NAME
cf::match - object matching language
@@ -27,9 +49,15 @@
type=SPELL in type=POTION in inv
-Find all potions inside someones inventory, or inside applied containers:
+Find all scrolls inside someones inventory, or inside applied scroll
+containers:
+
+ type=SCROLL also in applied type=CONTAINER race="scroll" in inv
- type=POTION also in type=CONTAINER and applied in inv
+Find all unpaid items, anywhere, even deeply nested inside other items, in
+the originator:
+
+ unpaid also deep in inv of originator
=head1 MATCH EXPRESSIONS
@@ -40,23 +68,38 @@
matches some desired properties:
condition
- condition in set
+ condition in set-modifier
+ condition of root-object
-A C receives a set of "context objects" that it is applied to. This
-is initially just one object - for altars, it is the object dropped on it,
-for pedestals, the object on top of it and so on.
+A C receives a set of "context objects" that it is applied
+to. This is initially just one object - by default, for altars, it is the
+object dropped on it, for pedestals, the object on top of it and so on.
This set of context objects can be modified in various ways, for example
-by replacing it with the inventories of all objects, or all objects on the
+by replacing it with the inventories of all objects, or all items on the
same mapspace, and so on, by using the C operator:
condition in inv
- condition in inv in originator
+ condition in map
+
+Also, besides the default root object where all this begins, you can start
+elsewhere, for example in the I (usually the player):
+
+ condition in inv of originator
+
+Once the final set of context objects has been established, each object
+is matched against the C.
+
+It is possible to chain modifiers from right-to-left, so this example
+would start with the originator, take it's inventory, find all inventory
+items which are potions, looks into their inventory, and then finds all
+spells.
+
+ type=SPELL in type=POTION in inv of originator
-Once the set of context objects has been established, each object is
-matched against the C expression. Sometimes the server is only
-interested in knowing whether I matches, and sometimes the
-server is interested in I objects that match.
+Sometimes the server is only interested in knowing whether I
+matches, and sometimes the server is interested in I objects that
+match.
=head2 OPERATORS
@@ -65,17 +108,32 @@
=item and, or, not, ()
Conditions can be combined with C or C to build larger
-expressions. C negates the expression, and parentheses can be used to
-group conditions.
+expressions. C negates the condition, and parentheses can be used to
+override operator precedence and execute submatches.
+
+Not that C only negates a condition and not the whole match
+expressions, thus
+
+ not applied in inv
+
+is true if there is I non-applied object in the inventory. To negate
+a whole match, you have to use a sub-match: To check whether there is
+I applied object in someones inventory, write this:
+
+ not (applied in inv)
Example: match applied weapons.
- type=WEAPON and applied
+ applied type=WEAPON
Example: match horns or rods.
type=HORN or type=ROD
+Example: see if the originator is a player.
+
+ type=PLAYER of originator
+
=item in ...
The in operator takes the context set and modifies it in various ways. As
@@ -86,37 +144,6 @@
=over 4
-=item in object
-
-Replaces all objects by the default object - this is the object passed to
-the match to match against by default. All matches have an explicit C appended.
-
-This must be the last C expression in a match.
-
-=item in source
-
-Replaces all objects by the source object - this object is sometimes
-passed to matches and represents the object is the source of the action,
-such as a rod or a potion when it is applied. Often, the I