Exemple #1
0
 def plan(self) -> Action:
     if self.actor.location.distance_to(*self.target_pos) > 1:
         # Enforces that the actor is only moving a short distance.
         raise Impossible(
             "Can't move from %s to %s." % (self.actor.location.xy, self.target_pos)
         )
     if self.actor.location.xy == self.target_pos:
         return self
     if self.map.fighter_at(*self.target_pos):
         return Attack(self.actor, self.target_pos).plan()
     if self.map.is_blocked(*self.target_pos):
         raise Impossible("That way is blocked.")
     return self
 def action_activate(self, action: ActionWithItem) -> None:
     targets = list(self.iter_targets(action))
     if not targets:
         raise Impossible("No enemy is close enough to strike.")
     target = min(targets,
                  key=functools.partial(self.target_distance, action.actor))
     if self.target_distance(action.actor, target) > self.max_range:
         raise Impossible("The enemy is too far away to strike.")
     damage = self.damage
     action.report(
         f"A lighting bolt strikes the {target.fighter.name} for {damage} damage!"
     )
     target.damage(damage)
     self.consume(action)
    def action_activate(self, action: ActionWithItem) -> None:
        selected_xy = states.ingame.PickLocation(
            action.model, "Select where to cast a teleport.",
            action.actor.location.xy).loop()
        if not selected_xy:
            raise Impossible("Targeting canceled.")
        if not action.map.visible.T[selected_xy]:
            raise Impossible(
                "You cannot target a tile outside your field of view.")
        if action.map.is_blocked(*selected_xy):
            raise Impossible("This tile is blocked.")

        action.actor.location = action.map[selected_xy]
        action.map.update_fov()
        self.consume(action)
    def action_activate(self, action: ActionWithItem) -> None:
        selected_xy = states.ingame.PickLocation(
            action.model, "Select who to genecide.",
            action.actor.location.xy).loop()
        if not selected_xy:
            raise Impossible("Targeting canceled.")
        if not action.map.visible.T[selected_xy]:
            raise Impossible(
                "You cannot target a enemy outside your field of view.")

        selected_actor = action.map.fighter_at(*selected_xy)
        if not selected_actor or selected_actor.is_player():
            raise Impossible("No enemy selected to genocide.")

        type_fighter = type(selected_actor.fighter)
        # Use a copy of the actors list since it may be edited during the loop.
        for actor in list(action.map.actors):
            if isinstance(actor.fighter, type_fighter):
                actor.die()

        action.report(f"The {selected_actor.fighter.name} has been genocided")
        self.consume(action)
    def action_activate(self, action: ActionWithItem) -> None:
        selected_xy = states.ingame.PickLocation(
            action.model, "Select where to cast a fireball.",
            action.actor.location.xy).loop()
        if not selected_xy:
            raise Impossible("Targeting canceled.")
        if not action.map.visible.T[selected_xy]:
            raise Impossible(
                "You cannot target a tile outside your field of view")

        action.report(
            f"The fireball explodes, burning everything within {self.radius} tiles!"
        )

        # Use a copy of the actors list since it may be edited during the loop.
        for actor in list(action.map.actors):
            if actor.location.distance_to(*selected_xy) > self.radius:
                continue
            action.report(
                f"The {actor.fighter.name} gets burned for {self.damage} hit points"
            )
            actor.damage(self.damage)
        self.consume(action)
Exemple #6
0
 def plan(self) -> Action:
     if not self.map.items.get(self.location.xy):
         raise Impossible("There is nothing to pick up.")
     return self
Exemple #7
0
 def plan(self) -> Attack:
     if self.location.distance_to(*self.target_pos) > 1:
         raise Impossible("That space is too far away to attack.")
     return self
Exemple #8
0
 def action_eat(self, action: ActionWithItem) -> None:
     """Eat this item."""
     raise Impossible("You can't eat that.")
Exemple #9
0
 def action_drink(self, action: ActionWithItem) -> None:
     """Drink this item."""
     raise Impossible("You can't drink that.")
Exemple #10
0
 def action_activate(self, action: ActionWithItem) -> None:
     raise Impossible(f"You can do nothing with the {self.name}.")
 def plan(self) -> Action:
     if not self.path_xy:
         raise Impossible("End of path reached.")
     self.subaction = actions.common.MoveTo(self.actor,
                                            self.path_xy[0]).plan()
     return self