--- deliantra/server/lib/cf/match.pm 2009/10/24 11:45:40 1.22 +++ deliantra/server/lib/cf/match.pm 2010/10/11 17:10:10 1.30 @@ -1,3 +1,25 @@ +# +# This file is part of Deliantra, the Roguelike Realtime MMORPG. +# +# Copyright (©) 2009,2010 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 @@ -94,9 +116,9 @@ not applied in inv -is true if there is I non-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: +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) @@ -108,6 +130,10 @@ 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 @@ -205,6 +231,11 @@ but submatches start at the current object, and in this case C can be used to start at the original object once more. +=item of self + +Starts with the object initiating/asking for the match - this is basically +always the object that the match expression is attached to. + =item of source Starts with the I object - this object is sometimes passed to @@ -221,11 +252,6 @@ This object is often identical to the I (e.g. when a player casts a spell, the player is both source and originator). -=item of self - -Starts with the object initiating/asking for the match - this is basically -always the object that the match expression is attached to. - =back =head2 EXPRESSIONS @@ -244,7 +270,7 @@ Object attributes that consist of a single value (C, C, C<value> and so on) can be specified by simply using their name, in which -acse their corresponding value is used. +case their corresponding value is used. =item array objects attributes @@ -258,7 +284,7 @@ =item functions Some additional functions with or without arguments in parentheses are -available. +available. They are documented in their own section, below. =item { BLOCK } @@ -308,6 +334,11 @@ This simply evaluates to false, and simply makes matching I<never> a bit easier to read. +=item archname + +The same as C<< { $_->arch->archname } >> - the archetype name is commonly +used to match items, so this shortcut is provided. + =item has(condition) True iff the object has a matching inventory object. @@ -435,6 +466,9 @@ none => sub { 0 }, + archname => sub { + '$_->arch->archname' + }, ); sub constant { @@ -699,7 +733,7 @@ sub compile($$) { my ($wantarray, $match) = @_; my $expr = parse $wantarray, $match; - warn "MATCH DEBUG $match,$wantarray => $expr\n";#d# +# warn "MATCH DEBUG $match,$wantarray => $expr\n";#d# $expr = eval " package cf::match::exec; sub {