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)
def split_item(self, item: Item, split_amount: int = 1) -> None: """ De-stack / Split an item from a pile. """ if item.stack_count > split_amount: if split_amount >= 1: # Create new stack spliten_item = item.duplicate_self(quantity=split_amount) spliten_item.stackable = False # Remove item from stack self.remove_item(item, split_amount) # Drop item to the floor if there is no room in the inventory if len(self.items) >= self.capacity: spliten_item.place(self.parent.x, self.parent.y, self.gamemap) else: self.add_item(spliten_item) # Reset the stackable of the copied item. # NOTE: This line of code is important, since it lets items to be stacked again even after they are spliten. spliten_item.stackable = True # set gamemap spliten_item.gamemap = item.gamemap # return the copy return spliten_item else: raise Impossible(f"The minimum amount you can split is 1.") else: raise Impossible( f"The maximum amount you can split is {item.stack_count - 1}.")
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("You cannot target an area that you cannot see.") if not target: raise Impossible("You must select an enemy to target.") if target is consumer: raise Impossible("You cannot target yourself!") self.activate_internal(consumer, target) self.consume()
def activate(self, action: action.ItemAction) -> None: consumer = action.entity target = None closest_distance = self.maximum_range + 1.0 for actor in self.engine.game_map.actors: # Finds the closest actor 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 lightning bolt strikes the {target.name} with a loud thunder for {self.damage} damage!" ) target.fighter.take_damage(self.damage) self.consume() else: raise Impossible( "No enemy is close enough to strike." ) # Remember that this conveniently doesn't tick the turn over
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.fighter and actor != 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 lightning bold strikes the {target.name} with a loud thunder, for {self.damage} damage!" ) target.fighter.take_damage(self.damage) self.consume() else: raise Impossible("No enemy is close enough to strike.")
def activate(self, action: actions.ItemAction) -> None: consumer = action.entity target = None closest_distance = self.maximum_range + 10 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"You activate the {self.parent.name}. It crackles with mystic power." ) self.engine.message_log.add_message( f"A lightning bolt strikes the {target.name} with a loud thunder for {self.damage} damage", ) target.fighter.take_damage(self.damage) self.consume() else: raise Impossible("There are no enemies close enough to strike")
def activate(self, action: actions.ReadItem) -> None: target_xy = action.target_xy consumer = action.entity if not self.engine.game_map.visible[target_xy]: raise Impossible("You cannot target an area that you cannot see.") # Set fire on the given radius for dx in range(-self.radius, self.radius + 1): for dy in range(-self.radius, self.radius + 1): semiactor_factories.fire.spawn(self.engine.game_map, target_xy[0] + dx, target_xy[1] + dy, 6) targets_hit = False for target in self.engine.game_map.actors: if target.chebyshevDist(*target_xy) <= self.radius: # damage self.damage = target.status.calculate_dmg_reduction( damage=self.damage, damage_type="physical") target.status.take_damage(amount=self.damage, attacked_from=consumer) # Log self.engine.message_log.add_message( f"The {target.name} gets slammed by a meteorite, taking {self.damage} damage!", target=target) targets_hit = True if not targets_hit: # nothing was hit self.engine.message_log.add_message( f"A meteorite falls and slams the ground!") self.consume()
def activate(self, action: actions.ItemAction) -> None: target_xy = action.target_xy if not self.engine.game_map.visible[target_xy]: raise Impossible("You can't target area you 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"{actor.name} is engulfed in flames by the explosion, taking {self.damage} damage" ) actor.fighter.take_damage(self.damage) targets_hit = True if not targets_hit: raise Impossible("There is no target in this area") self.consume()
def activate(self, action: actions.ItemAction) -> None: target_xy = action.target_xy if not self.engine.game_map.visible[target_xy]: raise Impossible("You cannot target an area that you cannot 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}" ) actor.fighter.take_damage(self.damage) targets_hit = True if not targets_hit: raise Impossible("There are no targets in the grenade radius.") self.consume()
def activate(self, action: actions.ItemAction) -> None: consumer = action.entity target_xy = action.target_xy if not self.engine.game_map.visible[target_xy]: raise Impossible("You cannot target an area that you cannot see.") targets_hit = False for target in self.engine.game_map.actors: if is_in(center_xy=(target.x, target.y), radius=self.radius, target_xy=target_xy): self.activate_internal(consumer, target) targets_hit = True if not targets_hit: raise Impossible("There are no targets in the radius.") self.consume()
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('You cannot target an area that you cannot see.') if not target: raise Impossible('You must select a target.') if target is consumer: raise Impossible('You cannot confuse yourself!') self.engine.message_log.add_message( f'The eyes of the {target.name} look vacant, as it starts to stumble around!', color.status_effect_applied) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns) self.consume()
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("You cannot target an area that isn't in your feild of veiw.") if not target: raise Impossible("You have to select an enemy to target.") if target is consumer: raise Impossible("You can't ever confuse yourself!") self.engine.message_log.add_message( f"The eyes of the {target.name} look vacant, as it starts to stumble around!", color.status_effect_applied, ) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns, ) self.consume()
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("You cannot target an area that you cannot see.") if not target: raise Impossible("You must select an enemy to target.") if target is consumer: raise Impossible("You cannot bribe yourself!") self.engine.message_log.add_message( f"The eyes of the {target.name} fill with green!", color.status_effect_applied, ) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns, ) self.consume()
def activate(self, action): target_xy = action.target_xy if not self.engine.game_map.visible[target_xy]: raise Impossible("You cannot target what you 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 hell of your creation, and takes {self.damage} damage.", ) actor.fighter.take_damage(self.damage) targets_hit = True if not targets_hit: raise Impossible("There's not targets in the area.") self.consume()
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_recavered} HP!", CONFIG.get_colour("health_recovered"), ) else: raise Impossible("Your health is already full.")
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() else: raise Impossible(f'Your health is already full.')
def activate(self, action: actions.AbilityAction) -> None: spell_user = action.entity amount_recovered = spell_user.fighter.heal_hp(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, ) else: raise Impossible(f"Your health is already full.")
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)
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('You cannot target what you can\'t see.') if not target: raise Impossible('You must select a valid target') if target is consumer: raise Impossible('Are you actually for real?') self.engine.message_log.add_message( f"You successfully confused the {target.name}. You must feel proud of yourself.", color.status_effect_applied, ) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns, ) self.consume()
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_TEXT, ) self.consume() else: raise Impossible("You are already at full health")
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("You can't see what's over there.") if not target: raise Impossible("You're not targeting anything.") if target is consumer: raise Impossible("You can't target yourself.") self.engine.message_log.add_message( f"{target.name} begins to stumble around, its eyes glassy.", color.status_effect_applied, ) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns, ) self.consume()
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() else: raise Impossible(f"You already had too many cold ones with the boys.")
def activate(self, action: actions.ItemAction) -> None: consumer = action.entity amount_recovered = consumer.fighter.heal_bp(self.amount) if amount_recovered > 0: self.engine.message_log.add_message( f"You consume the {self.parent.name}, and recover {amount_recovered} BP!", color.blood_recovered, ) self.consume() else: raise Impossible(f"Your blood pool is already full.")
def activate(self, action: actions.ReadItem) -> None: consumer = action.entity target = action.target_actor if not self.engine.game_map.visible[action.target_xy]: raise Impossible("You cannot target an area that you cannot see.") if not target: self.effects_on_selected_tile_with_no_actor(consumer=consumer) else: self.effects_on_selected_tile_with_actor(consumer=consumer, target=target) self.consume()
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 chow down the {self.parent.name}, and recover {amount_recovered} HP! You don't know how, but it feels like you did, anyway.", color.health_recovered, ) self.consume() else: raise Impossible( f"Your health is already full. Weird how one can say that.")
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")
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")
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("You cannot target an area you can't see") if not target: raise Impossible("You must select an enemy to target") if target is consumer: raise Impossible("You cannot confuse yourself!") self.engine.message_log.add_message( f"You activate the {self.parent.name}. It shudders with mystic power." ) self.engine.message_log.add_message( f"The {target.name} begins to stumble around with a vacant look in its eyes", color.STATUS_EFFECT_APPLIED, ) target.ai = components.ai.ConfusedEnemy( entity=target, previous_ai=target.ai, turns_remaining=self.number_of_turns) self.consume()
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)
def activate(self, action: actions.ItemAction) -> None: target_xy = action.target_xy if not self.engine.game_map.visible[target_xy]: raise Impossible("You cannot target an area that you cannot see") targets = [] for actor in self.engine.game_map.actors: if actor.distance(*target_xy) <= self.radius: targets.append(actor) if not targets: raise Impossible("There are no targets in the blast radius") self.engine.message_log.add_message( f"You activate the {self.parent.name}. It scorches your hand with mystic power." ) for target in targets: self.engine.message_log.add_message( f"The {target.name} is engulfed in a fiery explosion and takes {self.damage} damage" ) target.fighter.take_damage(self.damage) self.consume()