def _apply_health(game_state: GameState): if not game_state.player_state.health_resource.is_at_max(): create_potion_visual_effect_at_player(game_state) player_receive_healing(HEALING_AMOUNT, game_state) return ConsumableWasConsumed() else: return ConsumableFailedToBeConsumed("Already at full health!")
def _apply_mana(game_state: GameState): if not game_state.player_state.mana_resource.is_at_max(): create_potion_visual_effect_at_player(game_state) player_receive_mana(MANA_AMOUNT, game_state) return ConsumableWasConsumed() else: return ConsumableFailedToBeConsumed("Already at full mana!")
def _apply_scroll(game_state: GameState): player_entity = game_state.game_world.player_entity summon_size = NON_PLAYER_CHARACTERS[NpcType.PLAYER_SUMMON_DRAGON].size player_size = game_state.game_world.player_entity.pygame_collision_rect.w, game_state.game_world.player_entity.h candidate_relative_positions = [ (0, - summon_size[1]), # top (player_size[0], - summon_size[1]), # top right (player_size[0], 0), # right (player_size[0], player_size[1]), # down right (0, player_size[1]), # down (-summon_size[0], player_size[1]), # down left (-summon_size[0], 0), # left (-summon_size[0], -summon_size[1]) # top left ] for relative_pos in candidate_relative_positions: summon_pos = sum_of_vectors(player_entity.get_position(), relative_pos) summon = create_npc(NpcType.PLAYER_SUMMON_DRAGON, summon_pos) is_valid_pos = not game_state.game_world.would_entity_collide_if_new_pos(summon.world_entity, summon_pos) if is_valid_pos: game_state.game_world.remove_all_player_summons() game_state.game_world.add_non_player_character(summon) summon.gain_buff_effect(get_buff_effect(BuffType.SUMMON_DIE_AFTER_DURATION), DURATION_SUMMON) game_state.game_world.visual_effects.append( VisualCircle((200, 200, 30), player_entity.get_position(), 40, 70, Millis(140), 3)) game_state.game_world.visual_effects.append( VisualCircle((200, 200, 30), summon_pos, 40, 70, Millis(140), 3)) return ConsumableWasConsumed("Summoned dragon") return ConsumableFailedToBeConsumed("No space to summon dragon")
def _apply(game_state: GameState): player_state = game_state.player_state if not (player_state.health_resource.is_at_max() and player_state.mana_resource.is_at_max()): player_state.gain_buff_effect(get_buff_effect(BUFF_TYPE), BUFF_DURATION) return ConsumableWasConsumed() else: return ConsumableFailedToBeConsumed("Already at full health and mana!")
def _apply(game_state: GameState): # TODO Verify that the destination is clear from collisions destination = translate_in_direction(game_state.player_spawn_position, Direction.DOWN, 50) teleport_buff_effect: AbstractBuffEffect = get_buff_effect( BuffType.TELEPORTING_WITH_WARP_STONE, destination) game_state.player_state.gain_buff_effect(teleport_buff_effect, PORTAL_DELAY) return ConsumableWasConsumed()
def _apply(game_state: GameState): pos = game_state.game_world.player_entity.get_center_position() effect1 = VisualCircle((100, 150, 100), pos, 40, 120, Millis(2200), 2) effect2 = VisualCircle((100, 150, 100), pos, 40, 130, Millis(2000), 1) game_state.game_world.visual_effects += [effect1, effect2] affected_enemies = game_state.game_world.get_enemies_within_x_y_distance_of( 120, pos) for enemy in affected_enemies: enemy.gain_buff_effect(get_buff_effect(BUFF_TYPE), DEBUFF_DURATION) return ConsumableWasConsumed()
def _apply(game_state: GameState): create_potion_visual_effect_at_player(game_state) game_state.player_state.gain_buff_effect(get_buff_effect(BUFF_TYPE), DURATION) return ConsumableWasConsumed()
def _apply_speed(game_state: GameState): create_potion_visual_effect_at_player(game_state) game_state.player_state.gain_buff_effect( get_buff_effect(BuffType.INCREASED_MOVE_SPEED), DURATION) return ConsumableWasConsumed()
def _apply_invis(game_state: GameState): create_potion_visual_effect_at_player(game_state) game_state.player_state.gain_buff_effect( get_buff_effect(BuffType.INVISIBILITY), Millis(5000)) return ConsumableWasConsumed()