def _useless_self_hit(self, battle, order: BattleOrder): # Eliminate easy conditions in which this is not a useless self hit if not order or not order.is_move(): return False if not (order.order.damage or order.order.base_power > 0): return False if order.order.self_switch: return False # If it's a self-hit affected_targets = BattleOrder.get_affected_targets(battle, order) if affected_targets and min(affected_targets) < 0: # Get the mon who is going to be hit target_mon = battle.active_pokemon[min(affected_targets)] # Only allow this as a potential move under these conditions if target_mon.item == 'weaknesspolicy' and order.order.type.damage_multiplier( *target_mon.types) >= 2: return True elif target_mon.ability == 'Berserk': return False elif target_mon.ability == 'Justified' and order.order.type == 'DARK': return False elif target_mon.ability == 'Water Absorb' and order.order.type == 'WATER': return False elif target_mon.ability == 'Volt Absorb' and order.order.type == 'ELECTRIC': return False elif target_mon.ability == 'Flash Fire' and order.order.type == 'FIRE': return False else: return True return False
def _useless_battle_condition(self, battle, order: BattleOrder): if not order or not order.is_move(): return False if order.order.side_condition and order.order.side_condition in battle.side_conditions: return True if order.order.weather and battle.weather and order.order.weather == battle.weather: return True if order.order.terrain and battle.fields and order.order.terrain in battle.fields: return True if order.order.pseudo_weather and battle.fields and order.order.pseudo_weather in battle.fields: return True return False
def _useless_self_boost(self, order: BattleOrder): if order and order.is_move(): # Only consider self- or ally-boosting moves if you have boosts left, or if you dont, if the other pokemon has sucker punch if order.order.boosts and order.order.target == 'self': num_failed = 0 for stat in order.order.boosts: if (order.actor.boosts[stat] == 6 and order.order.boosts[stat] > 0) or ( order.order.boosts[stat] == -6 and order.order.boosts[stat] < 0): num_failed += 1 if num_failed < len(order.order.boosts): return True return False