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!")
Ejemplo n.º 2
0
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!")
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
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!")
Ejemplo n.º 5
0
def _apply(game_state: GameState):
    if not game_state.is_dungeon:
        # 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()
    else:
        return ConsumableFailedToBeConsumed("Can't warp inside a dungeon!")