Beispiel #1
0
 def __init__(self,
              game,
              name,
              description,
              aliases=None,
              traits=None,
              size=0,
              value=0,
              capacity=0):
     self.traits = Traits.merge(self, traits, Container.DEFAULT_TRAITS)
     super(Container, self).__init__(game,
                                     name,
                                     description,
                                     aliases,
                                     size=size,
                                     value=value)
     self.vocab = game.vocabulary
     self.put_preposition = 'in'
     self.capacity = capacity
     self.items = []
     self.add_patient_role('put')
     self.add_patient_role('get')
     if not self.traits.surface:
         self.add_patient_role('open')
         self.add_patient_role('close')
         self.add_patient_role('lock')
         self.add_patient_role('unlock')
Beispiel #2
0
 def __init__(self, game, name, description, aliases=None, traits=None, size=0, value=0):
     traits = Traits.merge(self, traits, Location.DEFAULT_TRAITS)
     super(Location, self).__init__(game, name, description, aliases=aliases, traits=traits,
                                    size=size, value=value, capacity=Container.MAX_CAPACITY)
     self.vocab = game.vocabulary
     self.exits = dict()
     self.visited = False
Beispiel #3
0
 def __init__(self, game, name, description, aliases=None, traits=None):
     self.traits = Traits.merge(self, traits, Door.DEFAULT_TRAITS)
     super(Door, self).__init__(game, name, description, aliases)
     self.add_patient_role('open')
     self.add_patient_role('close')
     self.add_patient_role('lock')
     self.add_patient_role('unlock')
Beispiel #4
0
 def __init__(self, game, location=None):
     self.traits = Traits.merge(self, None, Player.DEFAULT_TRAITS)
     super(Player,
           self).__init__(game=game,
                          name='me',
                          description='A travel-weary but brave adventurer',
                          aliases=None,
                          health=100,
                          strength=75,
                          dexterity=80,
                          location=location)
     self.game = game
     self.vocab = game.vocabulary
Beispiel #5
0
 def __init__(self, game, name, location, direction, destination, description,
              condition, fail_result, after=None, traits=None):
     self.traits = Traits.merge(self, traits, Passage.DEFAULT_TRAITS)
     super(Passage, self).__init__(game, name, aliases=None)
     self.vocab = game.vocabulary
     self.location = location.id
     self.direction = direction.id
     self.destination = destination.id
     self.description = description
     self.condition = condition
     self.after = after
     if fail_result:
         self.fail_result = fail_result
     else:
         self.fail_result = Passage.DEFAULT_FAIL_RESULT
Beispiel #6
0
 def __init__(self,
              game,
              name,
              description,
              aliases=None,
              traits=None,
              health=0,
              strength=0,
              dexterity=0,
              speed=50,
              activity=33,
              location=None,
              entry_action=None,
              present_action=None,
              exit_action=None):
     self.traits = Traits.merge(self, traits, Creature.DEFAULT_TRAITS)
     super(Creature, self).__init__(game, name, description, aliases)
     self.health = health
     self.location = location
     self.strength = strength
     self.dexterity = dexterity
     self.last_movement = 0
     self.movement_frequency = int(100 / speed)
     self.movement_strategy = self.random_walk
     self.last_activity = 0
     self.activity_frequency = int(100 / activity)
     self.wanted_items = []
     if not entry_action:
         self.entry_action = self.default_entry
     if not exit_action:
         self.exit_action = self.default_exit
     if not present_action:
         self.present_action = self.neutral_action
     if self.location:
         self.location.add_item(self)
     self.inventory = Container(game,
                                name + '-inv',
                                name + "'s items",
                                traits=Traits(closed=False),
                                capacity=strength)
     self.add_patient_role('greet')
     self.add_patient_role('wave')
     self.add_patient_role('smile')
     self.add_patient_role('give')
     self.add_patient_role('ask')
     self.add_patient_role('kill')
     self.add_patient_role('take')
Beispiel #7
0
    def __init__(self, game, name, aliases=None, traits=None):

        self.game = game
        self.vocabulary = game.vocabulary
        self.id = self.vocabulary.register_noun(self)
        self.name = name
        if aliases:
            self.aliases = aliases
        else:
            self.aliases = []
        self.traits = Traits.merge(self, traits, Thing.DEFAULT_TRAITS)
        self.modifiers = set()
        self.valid_roles = {
            Role.AGENT: [],
            Role.PATIENT: [],
            Role.THEME: [],
            Role.GOAL: [],
            Role.INSTRUMENT: []
        }
Beispiel #8
0
 def __init__(self,
              game,
              name,
              description,
              aliases=None,
              traits=None,
              size=0,
              value=0,
              capacity=MAX_CAPACITY):
     self.traits = Traits.merge(self, traits, Surface.DEFAULT_TRAITS)
     super(Surface, self).__init__(game,
                                   name,
                                   description,
                                   aliases,
                                   traits,
                                   size=size,
                                   value=value,
                                   capacity=capacity)
     self.put_preposition = 'on'
Beispiel #9
0
 def __init__(self,
              game,
              name,
              description,
              aliases=None,
              traits=None,
              size=0,
              value=0,
              damage=10,
              defense=10,
              accuracy=50):
     self.traits = Traits.merge(self, traits, Weapon.DEFAULT_TRAITS)
     super(Weapon, self).__init__(game,
                                  name,
                                  description,
                                  aliases,
                                  size=size,
                                  value=value)
     self.add_instrument_role('hit')
     self.damage = damage
     self.defense = defense
     self.accuracy = accuracy
Beispiel #10
0
 def __init__(self, game, name, description, aliases=None, traits=None):
     self.traits = Traits.merge(self, traits, VisibleThing.DEFAULT_TRAITS)
     super(VisibleThing, self).__init__(game, name, aliases)
     self.description = description
     self.add_patient_role('look')
     self.add_theme_role('throw')
Beispiel #11
0
 def __init__(self, game, name, description=None, aliases=None):
     if description is None:
         description = 'An exit leading ' + name
     self.traits = Traits.merge(self, None, Direction.DEFAULT_TRAITS)
     super(Direction, self).__init__(game, name, description, aliases)
     self.add_goal_role('go')
Beispiel #12
0
 def __init__(self, game, name, description, aliases=None, traits=None):
     self.traits = Traits.merge(self, traits, Key.DEFAULT_TRAITS)
     super(Key, self).__init__(game, name, description, aliases)
     self.add_instrument_role('lock')
     self.add_instrument_role('unlock')
     self.key_for = set()