def setUp(self):
     super().setUp()
     self._parent = Mock()
     self._parent.pre = Mock()
     G.add_event(self._parent.pre, "pre")
     self._parent.post = Mock()
     G.add_event(self._parent.post, "post")
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     _G.add_event(_CoffeeTick(self), "pre")
     insanity = _G.player.insanity.value
     desc = extra_description.get_interval(
         insanity, extra_description.coffee_descriptions)
     self.description = self.idle_description = self.name = desc
Ejemplo n.º 3
0
def gary():
    npc = actor.create_actor(
        1000,
        10,
        1000,
        10,
        "gary",
        ai=ai.Chill(),
    )

    class _GaryJoke(event.Event):
        def execute(self):
            insanity = _G.player.insanity.value
            jokes = extra_description.get_interval(
                insanity, extra_description.gary_jokes
            )
            if insanity <= 10:
                say.insayne("Gary starts to tell a joke...")
            elif insanity <= 20:
                say.insayne("Gary sneers...")
            for line in random.choice(jokes).split("\n"):
                say.insayne(line)
            if insanity < 10:
                say.insayne("You groan.")
                _G.player.insanity.modify(2)
            elif insanity <= 20:
                say.insayne("You try not to make eye contact.")
                say.insayne("Gary laughs uproariously, spittle flying all over you.")

    class _GaryHit(event.Event):
        def execute(self):
            insanity = _G.player.insanity.value
            if insanity >= 20:
                say.insayne("Gary smiles.")
                say.insayne('"I\'ve been waiting so long for this..."')
                npc.ai = ai.HatesPlayer()
            else:
                say.insayne('"Ow!"')

    class _GaryTick(event.Event):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)

        def execute(self):
            insanity = _G.player.insanity.value
            desc = extra_description.get_interval(
                insanity, extra_description.gary_descriptions
            )
            npc.idle_text = desc

    def gary_death_throes(actor):
        pass

    npc.ai.add_event(_GaryJoke(), "talk")
    npc.ai.add_event(_GaryHit(), "attack")
    _G.add_event(_GaryTick(), "pre")
    npc.upon_death(gary_death_throes)

    return npc
Ejemplo n.º 4
0
 def on_enter(self):
     super().on_enter()
     if self._event is None:
         self._event = _AltarEvent()
         # TODO: Use add_event here and elsewhere;
         # omit _maybe_append_event from Room.add_event.
         self._event.room = self
         G.add_event(self._event, "post")
Ejemplo n.º 5
0
 def create(cls, room):
     event = _FadingSmokeEvent()
     room.add_event(event)
     _G.add_event(event, "post")
     return cls(
         "smoke",
         description="plumes of smoke",
         idle_description="Thick wreaths of acrid smoke hang in the air.",
     )
Ejemplo n.º 6
0
 def execute(self):
     self._counter += 1
     if self.room is not G.player.current_room:
         return
     if self._counter % self._TURNS_TO_CHIME == 0:
         say.insayne(
             "Suddenly, the bells begin to chime in simultaneity, if not "
             "exactly unison. From the chaos can be discerned a discordant "
             "melody. It is a blasphemous all-bells rendition of Hanson's "
             "'MMMBop.' As the final incomprehensible peal subsides, you "
             "realize the song is stuck in your head, threatening the "
             "sinews of your very sanity.")
         G.player.insanity.heal_or_harm(15)
         G.add_event(_SongInHeadEvent(), "pre")
Ejemplo n.º 7
0
def office_copier():
    npc = actor.create_actor(
        1000,
        10,
        10,
        10,
        "copier",
        idle_text="The office's byzantine copier looks to be broken again.",
        ai=ai.Chill(),
    )

    def use_office_copier(consumer):
        insanity = _G.player.insanity.value
        if insanity < 20:
            say.insayne("The copier seems to be broken, as usual.")
        elif insanity < 29:
            bodyparts = ["fingers", "tongues", "arms", "lips", "nipples"]
            say.insayne(
                "The copier moans lasciviously. You feel its hot breath on your neck. It envelops you, and penetrates you."
            )
            say.insayne(
                "Abruptly, orgasmically, new "
                f"{random.choice(bodyparts)} erupt from your skin."
            )
            _G.player.insanity.modify(3)
        else:
            say.insayne("The copier sighs.")
            say.insayne(
                "You hear a meaty thumping coming from the direction of the meeting room."
            )

    class _CopierTick(event.Event):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)

        def execute(self):
            insanity = _G.player.insanity.value
            desc = extra_description.get_interval(
                insanity, extra_description.copier_descriptions
            )
            npc.idle_text = desc

    def office_copier_death_throes(actor):
        pass

    _G.add_event(_CopierTick(), "pre")
    npc.upon_death(office_copier_death_throes)
    npc.consume = use_office_copier

    return npc
Ejemplo n.º 8
0
def office_computer():
    npc = actor.create_actor(
        1000,
        10,
        1000,
        10,
        "your computer",
        "computer",
        "pc",
        idle_text="Your computer hums gently beneath your desk.",
        ai=ai.Chill(),
    )

    def use_computer(consumer):
        insanity = _G.player.insanity.value
        desc = extra_description.get_interval(
            insanity, extra_description.use_computer_descriptions
        )
        say.insayne(desc)
        if insanity >= 10 and insanity < 20:
            _G.player.insanity.modify(2)
        elif insanity >= 25:
            _G.player.health.heal_or_harm(-10)

    class _ComputerTick(event.Event):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)

        def execute(self):
            insanity = _G.player.insanity.value
            desc = extra_description.get_interval(
                insanity, extra_description.office_computer_descriptions
            )
            npc.idle_text = desc

    def computer_death_throes(actor):
        say.insayne("The computer falls to pieces.")

    _G.add_event(_ComputerTick(), "pre")
    npc.upon_death(computer_death_throes)

    npc.consume = use_computer

    return npc
Ejemplo n.º 9
0
def coffee_machine():
    npc = actor.create_actor(
        10,
        10,
        10,
        10,
        "coffee machine",
        idle_text="A coffee machine gurgles pleasantly on the counter.",
        ai=ai.Chill(),
    )

    def coffee_machine_death_throes(librarian):
        say.insayne(
            "The librarian grins impossibly wide. A thin rivulet of blood "
            "appears between his teeth. His eyes roll back and, with a giggle, "
            "he falls backward onto the ground as though reclining on a divan."
        )
        say.insayne("The edge of a hidebound book peeks from his rags.")

    npc.upon_death(coffee_machine_death_throes)

    def use_coffee_machine(consumer):
        # TODO: add text?
        _G.player.inventory.add(items.Coffee.create())

    class _CoffeeMachineTick(event.Event):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)

        def execute(self):
            insanity = _G.player.insanity.value
            desc = extra_description.get_interval(
                insanity, extra_description.coffee_machine_descriptions
            )
            npc.idle_text = desc

    _G.add_event(_CoffeeMachineTick(), "pre")
    npc.consume = use_coffee_machine

    return npc
Ejemplo n.º 10
0
 def tearDown():
     G.reset()
Ejemplo n.º 11
0
 def setUp():
     self._mock_parent = Mock()
     self._mock_parent.pre = Mock()
     G.add_event(self._mock_parent.pre, "pre")
     self._mock_parent.post = Mock()
     G.add_event(self._mock_parent.post, "post")
Ejemplo n.º 12
0
 def setUp(self):
     super().setUp()
     G.reset()
     # G.player must always exist.
     G.player = actor.create_actor(10, 10, 10, 10, "player")
Ejemplo n.º 13
0
 def on_enter(self):
     super().on_enter()
     self._event = _BoilerHeatEvent()
     G.add_event(self._event, "post")
Ejemplo n.º 14
0
 def on_enter(self):
     super().on_enter()
     if not self._entered:
         G.add_event(_IntestineRoomEvent(), "post")
         self._entered = True
Ejemplo n.º 15
0
 def on_enter(self):
     super().on_enter()
     self._event = _AcidDropEvent()
     G.add_event(self._event, "post")
Ejemplo n.º 16
0
 def on_enter(self):
     super().on_enter()
     if self._event is None:
         self._event = _BelfryEvent()
         self._event.room = self
         G.add_event(self._event, "post")