Exemplo n.º 1
0
    def activate(self, action: actions.ItemAction) -> None:
        target_xy = action.target_xy
        consumer = action.entity

        if not self.engine.game_map.visible[target_xy]:
            raise Impossible("I can't target what I can't see.")

        targets_hit = False
        for actor in self.engine.game_map.actors:
            if actor.distance(*target_xy) <= self.radius:
                if not actor is consumer:
                    self.engine.message_log.add_message(
                        f"The {actor.name} is flashed",
                        color.status_effect_applied,
                    )
                targets_hit = True
                actor.ai = components.ai.ConfusedEnemy(
                    entity=actor,
                    previous_ai=actor.ai,
                    turns_remaining=self.number_of_turns,
                )

        if not targets_hit:
            raise Impossible("No one is close to the effective range")
        self.consume()
        clip = AudioClip('sfx/rumble.flac')
        SoundHandler.play(clip)
Exemplo n.º 2
0
    def perform(self) -> None:
        target = self.target_actor
        if not target:
            raise exceptions.Impossible("Nothing to attack.")

        damage = self.entity.fighter.power - target.fighter.defense

        attack_desc = f"{self.entity.name.capitalize()} attacks {target.name}"
        if self.entity is self.engine.player:
            attack_color = color.player_atk
        else:
            attack_color = color.enemy_atk

        if damage > 0:
            self.engine.message_log.add_message(
                f"{attack_desc} for {damage} hit points.", attack_color
            )
            target.fighter.hp -= damage
            clip = AudioClip('sfx/Socapex - new_hits_5.wav')
            SoundHandler.play(clip)
        else:
            self.engine.message_log.add_message(
                f"{attack_desc} but barely damages him.", attack_color
            )
            target.fighter.hp -= 1
            clip = AudioClip('sfx/swosh-20.flac')
            SoundHandler.play(clip)
Exemplo n.º 3
0
 def activate(self, action: actions.ItemAction) -> None:
     consumer = action.entity
     amount_recovered = consumer.fighter.heal(self.amount)
     if amount_recovered > 0:
         self.engine.message_log.add_message(
             f"You consume the {self.parent.name}, and recover {amount_recovered} HP!",
             color.health_recovered,
         )
         self.consume()
         clip = AudioClip('sfx/heal.wav')
         SoundHandler.play(clip)
     else:
         raise Impossible(f"Can't heal what's not hurt")
Exemplo n.º 4
0
 def activate(self, action: actions.ItemAction) -> None:
     consumer = action.entity
     amount_recovered = consumer.fighter.eat(self.amount)
     if amount_recovered > 0:
         self.engine.message_log.add_message(
             f"You eat the {self.parent.name}, and fill your hunger by {amount_recovered}!",
             color.health_recovered,
         )
         self.consume()
         clip = AudioClip('sfx/heal.wav')
         SoundHandler.play(clip)
     else:
         raise Impossible(f"I'm full")
Exemplo n.º 5
0
 def die(self) -> None:
     if self.engine.player is self.parent:
         death_message = "You died!"
         death_message_color = color.player_die
         clip = AudioClip("sfx/swosh-20.flac")
         SoundHandler.play(clip)
     else:
         death_message = f"{self.parent.name} is dead!"
         death_message_color = color.enemy_die
     self.parent.char = "%"
     self.parent.color = (191, 0, 0)
     self.parent.blocks_movement = False
     self.parent.ai = None
     self.parent.name = f"dead body of {self.parent.name}"
     self.parent.render_order = RenderOrder.CORPSE
     self.engine.message_log.add_message(death_message, death_message_color)
     self.engine.player.level.add_xp(self.parent.level.xp_given)
Exemplo n.º 6
0
    def perform(self) -> None:
        dest_x, dest_y = self.dest_xy

        if not self.engine.game_map.in_bounds(dest_x, dest_y):
            # Destination is out of bounds.
            raise exceptions.Impossible("I don't want to go there")
        if not self.engine.game_map.tiles["walkable"][dest_x, dest_y]:
            # Destination is blocked by a tile.
            raise exceptions.Impossible("There's a wall in there")
        if self.engine.game_map.get_blocking_entity_at_location(dest_x, dest_y):
            # Destination is blocked by an entity.
            raise exceptions.Impossible("Something blocks me")

        if self.entity is self.engine.player:
            self.engine.player.fighter.starve()
        self.entity.move(self.dx, self.dy)
        clip = AudioClip('sfx/stepdirt_1.wav')
        SoundHandler.play(clip)
Exemplo n.º 7
0
 def perform(self) -> None:
     """
     Take the stairs, if any exist at the entity's location.
     """
     if (self.entity.x, self.entity.y) == self.engine.game_map.downstairs_location:
         self.engine.game_world.generate_floor()
         if random.random() <0.5:
             self.engine.message_log.add_message(
             "You descend the staircase, you're filled with hope.", color.descend
             )
         else:
             self.engine.message_log.add_message(
                 "You descend the staircase, you feel a chill on your spine"
             )
         clip = AudioClip('sfx/stepdirt_1.wav')
         SoundHandler.play(clip)
     else:
         raise exceptions.Impossible("There are no stairs here.")
Exemplo n.º 8
0
    def activate(self, action: actions.ItemAction) -> None:
        target_xy = action.target_xy

        if not self.engine.game_map.visible[target_xy]:
            raise Impossible("I can't target what I can't see.")

        targets_hit = False
        for actor in self.engine.game_map.actors:
            if actor.distance(*target_xy) <= self.radius:
                self.engine.message_log.add_message(
                    f"The {actor.name} is engulfed in a fiery explosion, taking {self.damage} damage!"
                )
                actor.fighter.take_damage(self.damage)
                targets_hit = True

        if not targets_hit:
            raise Impossible("No one is close to the effective range")
        self.consume()
        clip = AudioClip('sfx/rumble.flac')
        SoundHandler.play(clip)
Exemplo n.º 9
0
    def activate(self, action: actions.ItemAction) -> None:
        consumer = action.entity
        target = action.target_actor

        if not self.engine.game_map.visible[action.target_xy]:
            raise Impossible("I can't target what I can't see.")
        if not target:
            raise Impossible("No one is close to the effective range")
        if target is consumer:
            raise Impossible("I'm not this dumb.")

        self.engine.message_log.add_message(
            f"The {target.name} has been blinded",
            color.status_effect_applied,
        )
        target.ai = components.ai.ConfusedEnemy(
            entity=target,
            previous_ai=target.ai,
            turns_remaining=self.number_of_turns,
        )
        self.consume()
        clip = AudioClip('sfx/toggle.wav')
        SoundHandler.play(clip)
Exemplo n.º 10
0
    def activate(self, action: actions.ItemAction) -> None:
        consumer = action.entity
        target = None
        closest_distance = self.maximum_range + 1.0

        for actor in self.engine.game_map.actors:
            if actor is not consumer and self.parent.gamemap.visible[actor.x,
                                                                     actor.y]:
                distance = consumer.distance(actor.x, actor.y)

                if distance < closest_distance:
                    target = actor
                    closest_distance = distance

        if target:
            self.engine.message_log.add_message(
                f"A brick was thrown at {target.name}, breaking on impact and dealing {self.damage} damage."
            )
            target.fighter.take_damage(self.damage)
            self.consume()
            clip = AudioClip('sfx/impact.wav')
            SoundHandler.play(clip)
        else:
            raise Impossible("There's no one close enough to get bricked.")
Exemplo n.º 11
0
def load_game(filename: str) -> Engine:
    """Load an Engine instance from a file."""
    with open(filename, "rb") as f:
        engine = pickle.loads(lzma.decompress(f.read()))
    assert isinstance(engine, Engine)
    curFloor = engine.game_world.current_floor
    musHandler = SoundHandler()
    if curFloor < 4:
        musHandler.playBGM("music/Desolate Hallways.mp3")
    else:
        musHandler.playBGM("music/what we make from it.mp3")
    return engine
Exemplo n.º 12
0
    def generate_floor(self) -> None:
        from procgen import generate_dungeon

        self.current_floor += 1

        musHandler = SoundHandler()

        if not musHandler.isBusy():
            musHandler.playBGM("music/Desolate Hallways.mp3")

        if self.current_floor > 4:
            if musHandler.isBusy():
                musHandler.overrideBGM("music/what we make from it.mp3")

        self.engine.game_map = generate_dungeon(
            max_rooms=self.max_rooms,
            room_min_size=self.room_min_size,
            room_max_size=self.room_max_size,
            map_width=self.map_width,
            map_height=self.map_height,
            engine=self.engine,
        )
Exemplo n.º 13
0
from intent_service import YesNoClassifier, IntentClassifier
from sound_handler import SoundHandler
from verify_service import Verifier
from db import Database
from session import Session

intent_classifier = IntentClassifier()
yesno_classifier = YesNoClassifier()
sound_handler = SoundHandler()
sound_handler.start()
db = Database()
verifier = Verifier(db)
while (True):
    phone_num = input("Phone number: ")
    sess = Session(phone_num, intent_classifier, yesno_classifier,
                   sound_handler, verifier, db)
    sess.run()