コード例 #1
0
ファイル: artmaking.py プロジェクト: robmessick/curveship
 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
コード例 #2
0
ファイル: artmaking.py プロジェクト: tseaver/curveship
 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
コード例 #3
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #4
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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]))
コード例 #5
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #6
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #7
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #8
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #9
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #10
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #11
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #12
0
ファイル: command_map.py プロジェクト: tseaver/curveship
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)
コード例 #13
0
 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
コード例 #14
0
ファイル: cplus.py プロジェクト: tseaver/curveship
 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