Esempio n. 1
0
def fill_in_unrevealed_attrs(foe):
    attrs, all_known = foe.known_attrs()
    if all_known:
        return

    log.d("Filling in %s's attrs: %s", foe, attrs)
    rb_index = rbstats_key(foe)

    if foe.item == itemdex['_unrevealed_']:
        probability = {rbstats.attr_probability(rb_index, item, attrs): item
                       for item in rbstats[rb_index]['item']}
        item = itemdex[probability[max(probability)]]
        foe.item = item
        if foe.is_active:
            foe.set_effect(item())
        attrs.append(item.name)

    if foe.ability == abilitydex['_unrevealed_']:
        probability = {rbstats.attr_probability(rb_index, ability, attrs): ability
                       for ability in rbstats[rb_index]['ability']}
        ability = abilitydex[probability[max(probability)]]
        foe.base_ability = foe.ability = ability
        if foe.is_active:
            foe.set_effect(ability())
        attrs.append(ability.name)

    while len(foe.moves) < 4:
        probability = {rbstats.attr_probability(rb_index, move, attrs): move
                       for move in rbstats[rb_index]['moves'] if not movedex[move] in foe.moves}
        move = movedex[probability[max(probability)]]
        foe.moves[move] = move.max_pp
        attrs.append(move.name)

    log.d("Filled in: %s", attrs)
Esempio n. 2
0
    def describe_possible_foe_moves(self, my_active, foe):
        if len(foe.moves) >= 4 or foe.base_species == 'ditto':
            return ''

        foe_index = rbstats_key(foe)

        for move in foe.moves:
            if (move.name not in rbstats.probability[foe_index]['moves'] and
                move.type != Type.NOTYPE):
                log.w('%s not in rbstats for %s: Stale showdown data?', move.name, foe)

        possible_moves = [movedex[move] for move in rbstats[foe_index]['moves']
                          if movedex[move] not in foe.moves]
        data = []
        known_attrs = [move_.name for move_ in foe.moves if move_.type != Type.NOTYPE]
        if not rbstats.possible_sets(foe_index, known_attrs):
            log.w("%s's move probabilities cannot be calculated: unexpected attribute in %s",
                  foe_index, known_attrs)
            calculate_prob = False
        else:
            calculate_prob = True

        for move in possible_moves[:]:
            if calculate_prob:
                prob = rbstats.attr_probability(foe_index, move.name, known_attrs)
                if not prob:
                    possible_moves.remove(move)
                    continue
            else:
                prob = 0.5

            dmg_range = self.calculate_damage_range(foe, move, my_active)
            data.append((move.name, prob, dmg_range))

        return sorted(data, key=lambda x: -x[1])