Add a 'prefunction' to rules to have special processing.

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@13163 282e977c-c81d-0410-88c4-b93c2d0d6712
master
ryo_saeba 2010-05-10 17:50:57 +00:00
parent b66dcbeb89
commit 0d07667c50
1 changed files with 13 additions and 0 deletions

View File

@ -132,6 +132,7 @@ class DialogRule:
self.__messages = messages
self.__postsems = postsemaphores
self.__suggestions = suggested_response
self.__prefunction = None
# The keyword is a string. Multiple keywords may be defined in the string
# by delimiting them with vertical bar (|) characters. "*" is a special
@ -165,6 +166,14 @@ class DialogRule:
def getSuggests(self):
return self.__suggestions
# Return a possible pre function, that will be called to ensure the rule matches.
def getPreFunction(self):
return self.__prefunction
# Define a prefunction that will be called to match the rule.
def setPreFunction(self, function):
self.__prefunction = function
# This is a subclass of the generic dialog rule that we use for determining whether to
# 'include' additional rules.
class IncludeRule(DialogRule):
@ -270,6 +279,10 @@ class Dialog:
else:
Crossfire.Log(Crossfire.LogError, "CFDialog: Pre Block called with unknown action %s." % action)
return 0
if rule.getPreFunction() != None:
if rule.getPreFunction()(self.__character, rule) != True:
return 0
return 1