def react(self, world, basis): 'Win the game when smashed.' actions = [] if (basis.verb in ['kick', 'strike'] and basis.direct == str(self)): damage = Modify('puncture', basis.agent, direct=str(self), feature='intact', new=False) damage.after = """finally, a worthy contribution to the art world ... victory!""" damage.final = True actions = [damage] return actions
def unlock(agent, tokens, _): 'to unfasten, as what is locked; as, to unlock a door or a chest' return Modify('unlock', agent, direct=tokens[1], feature='locked', old=True, new=False)
def turn_to(agent, tokens, _): 'to rotate; to revolve; to make to face differently' return Modify('rotate', agent, template='[agent/s] [turn/v] [direct/o] to ' + tokens[2], direct=tokens[1], feature='setting', new=int(tokens[2]))
def lock(agent, tokens, _): 'to fasten with a lock, or as with a lock; to make fast; as, to lock a door' return Modify('lock', agent, direct=tokens[1], feature='locked', old=False, new=True)
def burn(agent, tokens, _): 'to consume with fire; to reduce to ashes by means of heat or fire' return Modify('burn', agent, direct=tokens[1], feature='burnt', old=False, new=True)
def turn_on(agent, tokens, _): 'to activate; to switch something from an inactive state to an active one' return Modify('activate', agent, template='[agent/s] [turn/v] [direct/o] on', direct=tokens[1], feature='on', old=False, new=True)
def close(agent, tokens, concept): 'to stop an opening; to shut; as, to close the eyes; to close a door' to_be_closed = check_for_metonymy(tokens[1], concept) return Modify('close', agent, direct=to_be_closed, feature='open', old=True, new=False)
def open_with(agent, tokens, world): 'to attempt to make or set open using a tool; to render free of access' if (hasattr(world.item[tokens[1]], 'locked') and world.item[tokens[1]].locked): return Modify('unlock', agent, direct=tokens[1], feature='locked', old=True, new=False) return Modify('open', agent, template='[agent/s] [open/v] [direct/o] using [' + tokens[2] + '/o]', direct=tokens[1], indirect=tokens[2], feature='open', old=False, new=True)
def open_up(agent, tokens, concept): """to make or set open; to render free of access Since 'open' is a builtin function, this one is called 'open_up.'""" to_be_opened = check_for_metonymy(tokens[1], concept) return Modify('open', agent, direct=to_be_opened, feature='open', old=False, new=True)
def illuminate(agent, tokens, concept): 'to make light; to supply with light; to brighten' if hasattr(concept.item[tokens[1]], 'lit'): feature = 'lit' else: feature = 'on' return Modify('illuminate', agent, direct=tokens[1], feature=feature, old=False, new=True)
def extinguish(agent, tokens, concept): 'to quench; to put out, as a light or fire' if hasattr(concept.item[tokens[1]], 'lit'): feature = 'lit' else: feature = 'on' return Modify('extinguish', agent, direct=tokens[1], feature=feature, old=True, new=False)
def react_to_failed(self, world, basis): actions = [] if (basis.behave and basis.verb == 'leave' and self.intact): actions.append( Modify('trample', basis.agent, direct='@message', feature='intact', new=False, salience=0)) sight = """ the message, now little but a cipher of trampled sawdust, [seem/1/v] to read: [begin-caps] [*/s] [lose/ed/v]""" actions.append( Modify('rewrite', basis.agent, direct=str(self), feature='sight', new=sight, salience=0)) return actions
def react(self, _, basis): 'Increase/decrease the light emitted when turned on/off.' actions = [] if (basis.modify and basis.direct == str(self) and basis.feature == 'on'): # If turned on, make it glow; otherwise, have it stop glowing. if basis.new_value: actions.append( Modify('light', basis.agent, direct=str(self), feature='glow', new=0.6, salience=0.1)) else: actions.append( Modify('extinguish', basis.agent, direct=str(self), feature='glow', new=0.0, salience=0.1)) return actions