Пример #1
0
def _get_initial_player_state_god() -> InitialPlayerStateData:
    health = 9999
    mana = 9999
    mana_regen = 100
    level_bonus = PlayerLevelBonus(0, 0, 0)
    armor = 99
    dodge_chance = 0.05
    consumable_slots = {1: [], 2: [], 3: [], 4: [], 5: []}
    abilities = [AbilityType.KILL_EVERYTHING, AbilityType.TELEPORT]
    new_level_abilities = {}
    talents_state = TalentsConfig({2: TALENT_CHOICE_ARMOR_DAMAGE})
    block_chance = 0
    return InitialPlayerStateData(health, mana, mana_regen, consumable_slots,
                                  abilities, new_level_abilities, HERO_ID,
                                  armor, dodge_chance, level_bonus,
                                  talents_state, block_chance, [])
Пример #2
0
def _get_initial_player_state_warrior() -> InitialPlayerStateData:
    health = 60
    mana = 30
    mana_regen = 2
    health_per_level = 15
    mana_per_level = 5
    armor_per_level = 1
    level_bonus = PlayerLevelBonus(health_per_level, mana_per_level,
                                   armor_per_level)
    armor = 3
    dodge_chance = 0.05
    consumable_slots = {1: [], 2: [], 3: [], 4: [], 5: []}
    abilities = [AbilityType.SWORD_SLASH]
    new_level_abilities = {
        2: AbilityType.CHARGE,
        5: AbilityType.BLOOD_LUST,
        7: AbilityType.STOMP
    }

    talents_state = TalentsConfig({
        3:
        TALENT_CHOICE_ARMOR_DAMAGE,
        4:
        TalentTierConfig(
            TalentTierOptionConfig(
                "Close combat",
                "Your Charge ability deals full damage even when used at close range",
                HeroUpgradeId.ABILITY_CHARGE_MELEE,
                UiIconSprite.ABILITY_CHARGE),
            TalentTierOptionConfig(
                "Brawl",
                "Your Slash ability deals max damage if at least 2 enemies are hit",
                HeroUpgradeId.ABILITY_SLASH_AOE_BONUS_DAMAGE,
                UiIconSprite.ABILITY_SWORD_SLASH)),
        5:
        TALENT_CHOICE_HEALTH_MANA,
        6:
        TalentTierConfig(
            TalentTierOptionConfig(
                "Bloodthirst",
                "The duration of your Bloodlust ability is now increased by " +
                "{:.1f}".format(
                    BLOODLUST_UPGRADED_INCREASED_DURATION_FROM_KILL / 1000) +
                "s on kills", HeroUpgradeId.ABILITY_BLOODLUST_DURATION,
                UiIconSprite.ABILITY_BLOODLUST),
            TalentTierOptionConfig(
                "Berserker", "Reduces the cooldown of your Slash ability to " +
                "{:.1f}".format(ABILITY_SLASH_UPGRADED_COOLDOWN / 1000) + "s",
                HeroUpgradeId.ABILITY_SLASH_CD,
                UiIconSprite.ABILITY_SWORD_SLASH)),
        7:
        TALENT_CHOICE_HEALTH_MANA_REGEN,
        8:
        TalentTierConfig(
            TalentTierOptionConfig(
                "Juggernaut",
                "Hitting an enemy with your Charge ability resets the cooldown of War Stomp",
                HeroUpgradeId.ABILITY_CHARGE_RESET_STOMP_COOLDOWN,
                UiIconSprite.ABILITY_STOMP),
            TalentTierOptionConfig(
                "Retribution", "Increases your block chance by " +
                str(int(BUFF_RETRIBUTION_BONUS_BLOCK_CHANCE * 100)) +
                "%. Blocking an enemy attack gives +" +
                str(int(BUFF_RETRIBUTION_BONUS_DAMAGE * 100)) +
                "% damage for " +
                "{:.1f}".format(BUFF_RETRIBUTION_DURATION / 1000) + "s",
                RetributionHeroUpgrade(HeroUpgradeId.WARRIOR_RETRIBUTION),
                UiIconSprite.ITEM_SKULL_SHIELD)),
    })
    block_chance = 0.2
    return InitialPlayerStateData(
        health, mana, mana_regen, consumable_slots, abilities,
        new_level_abilities, HERO_ID, armor, dodge_chance, level_bonus,
        talents_state, block_chance, [
            randomized_item_id(ItemType.PRACTICE_SWORD),
            randomized_item_id(ItemType.WOODEN_SHIELD)
        ])
Пример #3
0
def _get_initial_player_state_mage() -> InitialPlayerStateData:
    health = 40
    mana = 60
    mana_regen = 3.5
    health_per_level = 5
    mana_per_level = 10
    armor_per_level = 0.3
    level_bonus = PlayerLevelBonus(health_per_level, mana_per_level, armor_per_level)
    armor = 1
    dodge_chance = 0.05
    consumable_slots = {
        1: [],
        2: [],
        3: [],
        4: [],
        5: []
    }
    abilities = [AbilityType.FIREBALL]
    new_level_abilities = {
        2: AbilityType.WHIRLWIND,
        5: AbilityType.ENTANGLING_ROOTS,
        7: AbilityType.ARCANE_FIRE
    }

    talents_state = TalentsConfig(
        {
            3: TALENT_CHOICE_ARMOR_DAMAGE,
            4: TalentTierConfig(
                TalentTierOptionConfig("Raging fire", "Enemies hit by your fireballs take additional " +
                                       str(FIREBALL_TALENT_BURN_TOTAL_DAMAGE) + " damage over " +
                                       "{:.1f}".format(FIREBALL_TALENT_BURN_DURATION / 1000) + "s",
                                       HeroUpgradeId.ABILITY_FIREBALL_BURN, UiIconSprite.ABILITY_FIREBALL),
                TalentTierOptionConfig("Hurricane", "Whirlwind has a chance to stun affected enemies for " +
                                       "{:.1f}".format(WHIRLWIND_TALENT_STUN_DURATION / 1000) + "s",
                                       HeroUpgradeId.ABILITY_WHIRLWIND_STUN, UiIconSprite.ABILITY_WHIRLWIND)),
            5: TALENT_CHOICE_HEALTH_MANA,
            6: TalentTierConfig(
                TalentTierOptionConfig("Swift justice", "Reduces the cooldown of your Entangling Roots ability to " +
                                       "{:.1f}".format(ENTANGLING_ROOTS_UPGRADED_COOLDOWN / 1000) + "s",
                                       HeroUpgradeId.ABILITY_ENTANGLING_ROOTS_COOLDOWN,
                                       UiIconSprite.ABILITY_ENTANGLING_ROOTS),
                TalentTierOptionConfig("Flamethrower", "Reduces the mana-cost of your Fireball ability to " +
                                       str(FIREBALL_UPGRADED_MANA_COST),
                                       HeroUpgradeId.ABILITY_FIREBALL_MANA_COST, UiIconSprite.ABILITY_FIREBALL)),
            7: TALENT_CHOICE_HEALTH_MANA_REGEN,
            8: TalentTierConfig(
                TalentTierOptionConfig("Power hungry",
                                       "Reduces the cooldown of your Arcane Fire ability to " +
                                       "{:.1f}".format(ARCANE_FIRE_UPGRADED_COOLDOWN / 1000) +
                                       "s, but increases its mana-cost to " + str(ARCANE_FIRE_UPGRADED_MANA_COST),
                                       HeroUpgradeId.ABILITY_ARCANE_FIRE_COOLDOWN,
                                       UiIconSprite.ABILITY_ARCANE_FIRE),
                TalentTierOptionConfig("Light-footed", "Lets you keep moving while casting Fireball and Whirlwind",
                                       HeroUpgradeId.MAGE_LIGHT_FOOTED, UiIconSprite.TALENT_LIGHT_FOOTED)),
            9: TALENT_CHOICE_MOVE_SPEED_MAGIC_RESIST,

        })
    block_chance = 0.1
    return InitialPlayerStateData(
        health, mana, mana_regen, consumable_slots, abilities, new_level_abilities, HERO_ID, armor, dodge_chance,
        level_bonus, talents_state, block_chance, [randomized_item_id(ItemType.NOVICE_WAND)])
Пример #4
0
    def __init__(self, pygame_screen, camera_size: Tuple[int, int],
                 screen_size: Tuple[int, int],
                 images_by_ui_sprite: Dict[UiIconSprite, Any],
                 big_images_by_ui_sprite: Dict[UiIconSprite, Any],
                 images_by_portrait_sprite: Dict[PortraitIconSprite, Any],
                 ability_key_labels: List[str]):

        # INIT PYGAME FONTS
        pygame.font.init()

        # SETUP FUNDAMENTALS
        self.screen_render = DrawableArea(pygame_screen)
        self.ui_render = DrawableArea(pygame_screen,
                                      self._translate_ui_position_to_screen)
        self.ui_screen_area = Rect(0, camera_size[1], screen_size[0],
                                   screen_size[1] - camera_size[1])
        self.camera_size = camera_size
        self.screen_size = screen_size
        self.ability_key_labels = ability_key_labels

        # FONTS
        self.font_splash_screen = pygame.font.Font(
            DIR_FONTS + 'Arial Rounded Bold.ttf', 64)
        self.font_ui_stat_bar_numbers = pygame.font.Font(
            DIR_FONTS + 'Monaco.dfont', 12)
        self.font_ui_money = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 12)
        self.font_tooltip_details = pygame.font.Font(
            DIR_FONTS + 'Monaco.dfont', 12)
        self.font_buttons = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 12)
        self.font_stats = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 9)
        self.font_buff_texts = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 12)
        self.font_message = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 14)
        self.font_debug_info = pygame.font.Font(DIR_FONTS + 'Monaco.dfont', 12)
        self.font_ui_icon_keys = pygame.font.Font(
            DIR_FONTS + 'Courier New Bold.ttf', 12)
        self.font_level = pygame.font.Font(DIR_FONTS + 'Courier New Bold.ttf',
                                           11)

        # IMAGES
        self.images_by_ui_sprite = images_by_ui_sprite
        self.big_images_by_ui_sprite = big_images_by_ui_sprite
        self.images_by_portrait_sprite = images_by_portrait_sprite
        self.images_by_item_category = {
            ItemEquipmentCategory.HEAD:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_HELMET],
            ItemEquipmentCategory.CHEST:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_CHEST],
            ItemEquipmentCategory.MAIN_HAND:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_MAINHAND],
            ItemEquipmentCategory.OFF_HAND:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_OFFHAND],
            ItemEquipmentCategory.NECK:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_NECK],
            ItemEquipmentCategory.RING:
            self.images_by_ui_sprite[UiIconSprite.INVENTORY_TEMPLATE_RING],
        }

        # UI COMPONENTS
        self.ability_icons_row: Rect = Rect(0, 0, 0, 0)
        self.ability_icons: List[AbilityIcon] = []
        self.consumable_icons_row: Rect = Rect(0, 0, 0, 0)
        self.consumable_icons: List[ConsumableIcon] = []
        self.inventory_icons_rect: Rect = Rect(0, 0, 0, 0)
        self.inventory_icons: List[ItemIcon] = []
        self.exp_bar = ExpBar(self.ui_render, Rect(135, 8, 300, 2),
                              self.font_level)
        self.minimap = Minimap(self.ui_render, Rect(475, 52, 80, 80),
                               Rect(0, 0, 1, 1), (0, 0))
        self.buffs = Buffs(self.ui_render, self.font_buff_texts, (10, -35))
        self.money_text = Text(self.ui_render, self.font_ui_money, (24, 150),
                               "NO MONEY")
        self.talents_window: TalentsWindow = None
        self.quests_window: QuestsWindow = None
        self.message = Message(self.screen_render, self.font_message,
                               self.ui_screen_area.w // 2,
                               self.ui_screen_area.y - 30)
        self.paused_splash_screen = PausedSplashScreen(
            self.screen_render, self.font_splash_screen,
            Rect(0, 0, self.screen_size[0], self.screen_size[1]))
        self.controls_window = ControlsWindow(self.ui_render,
                                              self.font_tooltip_details,
                                              self.font_stats)

        # SETUP UI COMPONENTS
        self._setup_ability_icons()
        self._setup_consumable_icons()
        self._setup_inventory_icons()
        self._setup_health_and_mana_bars()
        self._setup_stats_window()
        self._setup_talents_window(TalentsState(TalentsConfig({})))
        self._setup_quests_window()
        self._setup_toggle_buttons()
        self._setup_portrait()
        self._setup_dialog()

        # QUICKLY CHANGING STATE
        self.hovered_component = None
        self.fps_string = ""
        self.game_mode_string = ""
        self.enabled_toggle: ToggleButton = None
        self.item_slot_being_dragged: ItemIcon = None
        self.consumable_slot_being_dragged: ConsumableIcon = None
        self.is_mouse_hovering_ui = False
        self.mouse_screen_position = (0, 0)
        self.dialog_state = DialogState()

        self._ticks_since_last_consumable_action = 0
        self._ticks_since_last_ability_action = 0
        self.highlighted_consumable_action: Optional[int] = None
        self.highlighted_ability_action: Optional[AbilityType] = None
        self.manually_highlighted_inventory_item: Optional[
            ItemId] = None  # used for dialog

        self.info_message = InfoMessage()
Пример #5
0
def _get_initial_player_state_rogue() -> InitialPlayerStateData:
    health = 50
    mana = 50
    mana_regen = 2.5
    health_per_level = 10
    mana_per_level = 10
    armor_per_level = 0.7
    level_bonus = PlayerLevelBonus(health_per_level, mana_per_level, armor_per_level)
    armor = 2
    dodge_chance = 0.1
    consumable_slots = {
        1: [],
        2: [],
        3: [],
        4: [],
        5: []
    }
    abilities = [AbilityType.SHIV]
    new_level_abilities = {
        2: AbilityType.STEALTH,
        5: AbilityType.DASH,
        7: AbilityType.INFUSE_DAGGER
    }

    talents_state = TalentsConfig({
        3: TALENT_CHOICE_ARMOR_DAMAGE,
        4: TalentTierConfig(
            TalentTierOptionConfig("Shadowmeld", "Reduces the mana-cost of your Stealth ability to " +
                                   str(STEALTH_UPGRADED_MANA_COST),
                                   HeroUpgradeId.ABILITY_STEALTH_MANA_COST,
                                   UiIconSprite.ABILITY_STEALTH),
            TalentTierOptionConfig("Ambush",
                                   "Increases the damage bonus that Shiv gets from being used from stealth to " +
                                   str(int(SHIV_UPGRADED_STEALTH_DAMAGE_MULTIPLIER * 100)) + "%",
                                   HeroUpgradeId.ABILITY_SHIV_SNEAK_BONUS_DAMAGE,
                                   UiIconSprite.ABILITY_SHIV)),
        5: TALENT_CHOICE_HEALTH_MANA,
        6: TalentTierConfig(
            TalentTierOptionConfig("Acrobatics",
                                   "The cooldown and mana-cost of your dash ability is reset if it kills an enemy",
                                   HeroUpgradeId.ABILITY_DASH_KILL_RESET,
                                   UiIconSprite.ABILITY_DASH),
            TalentTierOptionConfig("First strike",
                                   "Shiv deals " +
                                   str(int(SHIV_TALENT_FULL_HEALTH_DAMAGE_MULTIPLIER * 100)) +
                                   "% damage on enemies that are at full health, unless you're stealthed",
                                   HeroUpgradeId.ABILITY_SHIV_FULL_HEALTH_BONUS_DAMAGE,
                                   UiIconSprite.ABILITY_SHIV)),
        7: TALENT_CHOICE_HEALTH_MANA_REGEN,
        8: TalentTierConfig(
            TalentTierOptionConfig("Master Assassin",
                                   "Stealth doesn't reduce movement speed",
                                   HeroUpgradeId.ABILITY_STEALTH_MOVEMENT_SPEED,
                                   UiIconSprite.ABILITY_STEALTH),
            TalentTierOptionConfig("Leap",
                                   "Dash gives +40% movement speed for 2 seconds",
                                   HeroUpgradeId.ABILITY_DASH_MOVEMENT_SPEED,
                                   UiIconSprite.ABILITY_DASH)),
        9: TALENT_CHOICE_MOVE_SPEED_MAGIC_RESIST,
    })
    block_chance = 0.15
    return InitialPlayerStateData(
        health, mana, mana_regen, consumable_slots, abilities, new_level_abilities, HERO_ID, armor, dodge_chance,
        level_bonus, talents_state, block_chance, [randomized_item_id(ItemType.PRACTICE_SWORD)])