def copy(self) : """Returns a copy which behaves like the original, but for which modifications do not change the original.""" newat = ActionSystem() newat.action_verify = self.action_verify.copy() newat.action_trybefore = self.action_trybefore.copy() newat.action_before = self.action_before.copy() newat.action_when = self.action_when.copy() newat.action_report = self.action_report.copy() newat.verify = make_rule_decorator(newat.action_verify) newat.trybefore = make_rule_decorator(newat.action_trybefore) newat.before = make_rule_decorator(newat.action_before) newat.when = make_rule_decorator(newat.action_when) newat.report = make_rule_decorator(newat.action_report) return newat
def copy(self): """Returns a copy which behaves like the original, but for which modifications do not change the original.""" newat = ActionSystem() newat.action_verify = self.action_verify.copy() newat.action_trybefore = self.action_trybefore.copy() newat.action_before = self.action_before.copy() newat.action_when = self.action_when.copy() newat.action_report = self.action_report.copy() newat.verify = make_rule_decorator(newat.action_verify) newat.trybefore = make_rule_decorator(newat.action_trybefore) newat.before = make_rule_decorator(newat.action_before) newat.when = make_rule_decorator(newat.action_when) newat.report = make_rule_decorator(newat.action_report) return newat
def __init__(self) : self.action_verify = RuleTable(doc="""Handles verifying actions for being at least somewhat logical. Should not change world state.""") self.action_trybefore = RuleTable(doc="""Handles a last attempt to make the action work (one shouldn't work with this table directly).""") self.action_before = RuleTable(doc="""Checks an action to see if it is even possible (opening a door is logical, but it's not immediately possible to open a locked door)""") self.action_when = RuleTable(doc="""Carries out the action. Must not fail.""") self.action_report = RuleTable(doc="""Explains what happened with this action. Should not change world state.""") self.verify = make_rule_decorator(self.action_verify) self.trybefore = make_rule_decorator(self.action_trybefore) self.before = make_rule_decorator(self.action_before) self.when = make_rule_decorator(self.action_when) self.report = make_rule_decorator(self.action_report)
def __init__(self): self.action_verify = RuleTable( doc="""Handles verifying actions for being at least somewhat logical. Should not change world state.""") self.action_trybefore = RuleTable(doc="""Handles a last attempt to make the action work (one shouldn't work with this table directly).""") self.action_before = RuleTable(doc="""Checks an action to see if it is even possible (opening a door is logical, but it's not immediately possible to open a locked door)""") self.action_when = RuleTable( doc="""Carries out the action. Must not fail.""") self.action_report = RuleTable(doc="""Explains what happened with this action. Should not change world state.""") self.verify = make_rule_decorator(self.action_verify) self.trybefore = make_rule_decorator(self.action_trybefore) self.before = make_rule_decorator(self.action_before) self.when = make_rule_decorator(self.action_when) self.report = make_rule_decorator(self.action_report)
from textadv.gamesystem.gamecontexts import ActorActivities from textadv.gamesystem.basicpatterns import * from textadv.gamesystem.utilities import * #import textadv.gamesystem.parser as parser from textadv.gamesystem.parser import default_parser, Ambiguous from textadv.gamesystem.actionsystem import BasicAction, DoInstead, verify_instead, ActionSystem from textadv.gamesystem.actionsystem import VeryLogicalOperation, LogicalOperation, BarelyLogicalOperation, IllogicalOperation, IllogicalInaccessible, NonObviousOperation, IllogicalNotVisible ### ### The main game world! ### world = World() actionsystem = ActionSystem() verify = make_rule_decorator(actionsystem.action_verify) trybefore = make_rule_decorator(actionsystem.action_trybefore) before = make_rule_decorator(actionsystem.action_before) when = make_rule_decorator(actionsystem.action_when) report = make_rule_decorator(actionsystem.action_report) parser = default_parser.copy() actoractivities = ActorActivities() ### ### Global properties ### @world.define_property