Ejemplo n.º 1
0
    def open(self, player, args):
        if not player.container:
            return

        desc      = ' '.join(args)
        container = player.find_best_match(desc)

        if not container:
            container = player.container.find_best_match(desc)

        if not container or not isinstance(container, Container) or not container.is_closeable:
            # Open what?
            player.text('Öppna vad?')
            return

        unlockable_class = enigmus.get_entity_class('special/unlockable.py:Unlockable')
        if isinstance(container, unlockable_class) and container.is_locked:
            # {} is locked.
            player.text(language.sentence('{} är låst.',
                        container.get_description(indefinite=False)))
            return

        if container.is_open:
            # {} is already open.
            player.text(language.sentence('{} är redan öppen.',
                        container.get_description(indefinite=False)))
            return

        if not player.open(container):
            player.emote('försöker öppna', container, 'men misslyckas')
Ejemplo n.º 2
0
    def open(self, player, args):
        if not player.container:
            return

        desc = ' '.join(args)
        container = player.find_best_match(desc)

        if not container:
            container = player.container.find_best_match(desc)

        if not container or not isinstance(
                container, Container) or not container.is_closeable:
            # Open what?
            player.text('Öppna vad?')
            return

        unlockable_class = enigmus.get_entity_class(
            'special/unlockable.py:Unlockable')
        if isinstance(container, unlockable_class) and container.is_locked:
            # {} is locked.
            player.text(
                language.sentence('{} är låst.',
                                  container.get_description(indefinite=False)))
            return

        if container.is_open:
            # {} is already open.
            player.text(
                language.sentence('{} är redan öppen.',
                                  container.get_description(indefinite=False)))
            return

        if not player.open(container):
            player.emote('försöker öppna', container, 'men misslyckas')
Ejemplo n.º 3
0
    def is_dark(self):
        light_class = enigmus.get_entity_class('special/light.py:Light')
        num_lights = 0

        # Find all lights in room and inventories.

        inventories = [
            actor.inventory.entities for actor in self.room.entities
            if isinstance(actor, Actor)
        ]

        lights = [
            light for light in self.room.entities
            if isinstance(light, light_class)
        ]

        lights.extend([
            item for inventory in inventories for item in inventory
            if isinstance(item, light_class)
        ])

        for light in lights:
            if not light.is_on:
                continue

            num_lights += 1
            if num_lights >= self.lights_required:
                return False

        return True
Ejemplo n.º 4
0
#-----------------------------------------------------------
# IMPORTS
#-----------------------------------------------------------

import enigmus
import messages

from entities import Item
from command  import Command

#-----------------------------------------------------------
# CLASSES
#-----------------------------------------------------------

light_class = enigmus.get_entity_class('special/light.py:Light')
class Flashlight(Item, light_class):
    def __init__(self):
        super(Flashlight, self).__init__()

        self.describe('en' , ['svart' ], ['ficklampa' , 'lampa' ],
                      'den', ['svarta'], ['ficklampan', 'lampan'],
                      'En liten svart ficklampa. Den är av stilren modell och '
                      'får lätt plats i fickan tack vare sin storlek. Den ser '
                      'dyr ut.')

    def switch_on(self):
        super(Flashlight, self).switch_on()

        self.description.add_indefinite_adjective('*tänd*')
Ejemplo n.º 5
0
#-----------------------------------------------------------
# IMPORTS
#-----------------------------------------------------------

import enigmus
import messages

from entities import Item
from command import Command

#-----------------------------------------------------------
# CLASSES
#-----------------------------------------------------------

light_class = enigmus.get_entity_class('special/light.py:Light')


class Flashlight(Item, light_class):
    def __init__(self):
        super(Flashlight, self).__init__()

        self.describe(
            'en', ['svart'], ['ficklampa', 'lampa'], 'den', ['svarta'],
            ['ficklampan', 'lampan'],
            'En liten svart ficklampa. Den är av stilren modell och '
            'får lätt plats i fickan tack vare sin storlek. Den ser '
            'dyr ut.')

    def switch_on(self):
        super(Flashlight, self).switch_on()