Exemple #1
0
def effi_pkm(battle, pkm1: Pokemon, pkm2: Pokemon, team1: Team,
             team2: Team) -> int:
    """
    Efficiency of pokemon against other.
    Based on move efficiency functions.
    If efficiency of a pokemon > 150 and is faster, efficiency of the other pokemon is not taken.
    effi_pkm(a, b, team_a) = - effi_pkm(b, a, team_b)
    :param battle: Battle object, current battle.
    :param pkm1: Pokemon that will use move.
    :param pkm2: Pokemon that will receive move.
    :param team1: Team of pkm1.
    :param team2: Team of pkm2.
    :return: Integer, can be negative.
    """
    pkm1_spe = pkm1.compute_stat(Stats.SPE)
    pkm2_spe = pkm2.compute_stat(Stats.SPE)

    effi1 = max(
        [effi_move(battle, move, pkm1, pkm2, team2) for move in pkm1.moves])
    if effi1 >= base_damages(150, pkm1, pkm2) and pkm1_spe > pkm2_spe:
        return effi1
    effi2 = max(
        [effi_move(battle, move, pkm2, pkm1, team1) for move in pkm2.moves])
    if effi2 >= base_damages(150, pkm2, pkm1) and pkm2_spe > pkm1_spe:
        return -effi2
    return effi1 - effi2
Exemple #2
0
def effi_boost(move: dict, pkm1: Pokemon, pkm2: Pokemon) -> bool:
    """
    Calculate if boost is worth or not. Currently only working on speed.
    :param move: Json object, status move.
    :param pkm1: Pokemon that will use move.
    :param pkm2: Pokemon that will receive move.
    :return: Boolean, True if worth, else False
    """
    pkm1_spe = stat_calculation(pkm1.stats[Stats.SPE], pkm1.level, 252)
    move = next((i for i in pkm1.moves if i['name'] == move['move']))
    value = ((move.get('secondary') if move.get('secondary') else move)
        .get('self', move).get('boosts', {}).get('spe', 0))
    if not value:
        return False
    return (pkm2.compute_stat(Stats.SPE) > pkm1.compute_stat(Stats.SPE)
        and pkm1_spe * (value + pkm1.buff_affect(Stats.SPE)) > pkm2.compute_stat(Stats.SPE))
Exemple #3
0
def base_damages(power: float, pkm1: Pokemon, pkm2: Pokemon) -> int:
    """
    Used to compare damage done by pk1 to comparative values (100, 150, etc.).
    Because we want exact values, modificators, stab, burn and efficiency are
    not taken into account.
    :param power: value to compare
    :param pkm1: Pokemon that will use move.
    :param pkm2: Pokemon that will receive move.
    :return: Integer, damage of comparative value after calculation [0, +oo[
    """
    categories = Stats.SPA, Stats.SPD
    if pkm1.stats[Stats.ATK] > pkm1.stats[Stats.SPA]:
        categories = Stats.ATK, Stats.DEF
    atk = pkm1.compute_stat(categories[0])
    defe = pkm2.compute_stat(categories[1])
    return floor(((0.4 * pkm1.level + 2) * (atk / defe) * power) / 50 + 2)