Esempio n. 1
0
    def perform_activation_skill_on_target(self, card, skill, target, opposing_board, can_payback=True):
        # Enfeeble, Heal, Jam, Mimic, Rally, Siege, Strike, Weaken
        # Account for: Evade, Payback, Regenerate

        if log_enabled(): log("        Skill target is: {" + target.description() + "}")
        hostile = skill.is_hostile_activation_skill()
        if hostile and target.evade():
            if coin_toss():
                if log_enabled(): log("        Evade! {" + target.description() + "} evaded " + skill.description())
                if log_enabled(): log("      --Final skill target status: {" + target.description() + "}")
                return

        can_payback = can_payback and hostile and card.type() == "assault"

        skill_name = skill.name()
        if skill_name == "heal":
            target.heal(skill.value())
        elif skill_name == "weaken":
            target.weaken(skill.value())
        elif skill_name == "rally":
            target.rally(skill.value())
        elif skill_name == "strike":
            damage = skill.value()
            enfeebled = target.enfeebled()
            if enfeebled > 0:
                damage += enfeebled
                if log_enabled(): log("        Enfeeble bonus damage: " + str(enfeebled))
            target.take_damage(damage)
        elif skill_name == "siege":
            target.take_damage(skill.value())
            can_payback = False
        elif skill_name == "jam":
            if coin_toss():
                target.suffer_jam()
            else:
                if log_enabled(): log("        Jam failed on {" + target.description() + "}")
                # no chance for payback if it misses
                can_payback = False
        elif skill_name == "enfeeble":
            target.suffer_enfeeble(skill.value())
        elif skill_name == "mimic":
            mimiced_skills = target.activation_skills_for_mimic()
            self.perform_activation_skill_list(card, mimiced_skills, opposing_board)
            can_payback = False

        if log_enabled(): log("      --Final skill target status: {" + target.description() + "}")

        if target.payback() and can_payback:
            if coin_toss():
                if log_enabled(): log("        Payback! {" + target.description() + "} will attempt " + skill.description() + " on {" + card.description() + "}")
                opposing_board.perform_activation_skill_on_target(target, skill, card, self, can_payback=False)
Esempio n. 2
0
    def perform_attack_on_target(self, target, attacker, opposing_board):
        attacks = 1
        flurry = attacker.flurry()
        if flurry > 0 and coin_toss():
            attacks += flurry
            if log_enabled(): log("      Flurry! performing " + str(attacks) + " total attacks")

            for i in range(1, attacks + 1):
                if i > 0 and attacker.cannot_attack():
                    return
                if log_enabled(): log("      === Attack \#" + str(i) + " ===")
                self.perform_single_attack_on_target(target, attacker, opposing_board)
                if target.is_dead():
                    target = opposing_board.commander_target()
        else:
            self.perform_single_attack_on_target(target, attacker, opposing_board)
Esempio n. 3
0
    def perform_single_attack_on_target(self, target, attacker, opposing_board):
        if log_enabled(): log("        Attack target is: {" + target.description() + "}")

        damage = attacker.attack()
        if log_enabled(): log("        Base damage (including rally/weaken): " + str(damage))

        enfeebled = target.enfeebled()
        if enfeebled > 0:
            damage += enfeebled
            if log_enabled(): log("         Enfeeble bonus damage: " + str(enfeebled))

        valor = attacker.valor()
        if valor > 0 and self.assault_count() < opposing_board.assault_count():
            damage += valor
            if log_enabled(): log("        Valor bonus damage: " + str(valor))

        if target.flying():
            antiair = attacker.antiair()
            if antiair:
                damage += antiair
                if log_enabled(): log("        Antiair bonus damage: " + str(antiair))
            elif not attacker.flying():
                if coin_toss():
                    if log_enabled(): log("         Flying! Unit {" + attacker.description() + "} missed {" + target.description() + "}")
                    return

        armor = target.armored()
        if armor > 0:
            pierce = attacker.pierce()
            if pierce:
                if log_enabled(): log("        Armor reduced from " + str(armor) + " by pierce " + str(pierce))
                armor = max(0, armor - pierce)
            if log_enabled(): log("        Damage reduced by armor: " + str(armor))
            damage -= armor

        if damage <= 0:
            if log_enabled(): log("        Blocked: {" + attacker.description() + "} has modified damage " + str(damage))
            return

        if attacker.immobilize():
            if coin_toss():
                if log_enabled(): log("        Immobilize! Unit {" + attacker.description() + "} immobilizes {" + target.description() + "}")
                target.suffer_immobilize()
    
        poison = attacker.poison()
        if poison > 0:
            if log_enabled(): log("        Poison! Unit {" + attacker.description() + "} inflicts " + str(poison) + " poison on target {" + target.description() + "}")
            target.suffer_poison(poison)

        target_died = target.take_damage(damage)
        if log_enabled(): log("        Unit {" + attacker.description() + "} does " + str(damage) + " attack damage to {" + target.description() + "}")

        crush = attacker.crush()
        if crush > 0 and target_died:
            crush_target = opposing_board.commander_target()
            if log_enabled(): log("        Crush! Unit {" + attacker.description() + "} does {" + str(damage) + "} crush damage to {" + crush_target.description() + "}")
            crush_target.take_damage(damage)
            if log_enabled(): log("      --Final crushed unit status: {" + crush_target.description() + "}")

        counter = target.counter()
        if counter > 0:
            if log_enabled(): log("        Unit {" + attacker.description() + "} suffers " + str(counter) + " counter damage from {" + target.description() + "}")
            attacker.take_damage(counter)

        target_is_assault = target.type() == "assault"
        leech = attacker.leech()
        if leech > 0 and target_is_assault and not attacker.is_dead():
            if log_enabled(): log("        Leech! Unit {" + attacker.description() + "} leeches for " + str(leech) + "hp")
            attacker.heal(leech)

        siphon = attacker.siphon()
        if siphon > 0 and target_is_assault:
            if log_enabled(): log("        Siphon! Commander {" + self._commander.description() + "} receives siphon for " + str(siphon) + "hp from {" + attacker.description() + "}")
            self._commander.heal(siphon)

        if log_enabled(): log("      --Final attacking unit status: {" + attacker.description() + "}")
        if log_enabled(): log("      --Final defending unit status: {" + target.description() + "}")