void AuxPokeDataProxy::changeForme(int subnum)
{
    /* TODO: Still need to update the stats */
    if (pokemon()) {
        setAlternateSprite(Pokemon::uniqueId(pokemon()->num().pokenum, subnum));
    }
}
int AuxPokeDataProxy::type2()
{
    if (pokemon()) {
        return PokemonInfo::Type2(pokemon()->num(), pokemon()->gen());
    } else {
        return Type::Curse;
    }
}
int AuxPokeDataProxy::maxStat(int stat)
{
    int st = this->stat(stat);

    if (st) return st;

    if (!pokemon()) return 0;

    int boost = statBoost(stat);

    return (PokemonInfo::Stat(pokemon()->num(), pokemon()->gen(), stat, pokemon()->level(), 31, 255) * 11 / 10)
           * PokeFraction(std::max(2+boost, 2), std::max(2-boost, 2));
}
Beispiel #4
0
void Pokedex::freePokemon(int pokemonID) {
	if (pokemonID <= 0) {
		throw InvalidInput();
	}
	Pokemon pokemon(pokemonID, NO_POKEMON, NO_POKEMON);
	avlNode<Pokemon, pokemonCompareByID>* pokemonNode = mainIdTree.find(
			pokemon);
	if (!pokemonNode) {
		throw Failure();
	}
	Pokemon toRemove(pokemonID, pokemonNode->getData().getTrainerId(),
			pokemonNode->getData().getLevel());
	bool status = mainIdTree.remove(toRemove);
	if (!status) {
		throw Failure();
	}
	bool status2 = mainLevelTree.remove(toRemove);
	if (!status2) {
		throw Failure();
	}
	int trainerID = toRemove.getTrainerId();
	Iterator<Trainer> trainer = trainers.find(TrainerCompare(trainerID));
	bool status3 = (*trainer).getIdTree().remove(toRemove);
	if (!status3) {
		throw Failure();
	}
	bool status4 = (*trainer).getLevelTree().remove(toRemove);
	if (!status4) {
		throw Failure();
	}
	(*trainer).updateMax();
	this->updateMax();
}
Beispiel #5
0
void Pokedex::catchPokemon(int pokemonID, int trainerID, int level) {
	if (pokemonID <= 0 || trainerID <= 0 || level <= 0) {
		throw InvalidInput();
	}
	Iterator<Trainer> trainer = trainers.find(TrainerCompare(trainerID));
	if (trainer == trainers.end()) {
		throw Failure();
	}
	Pokemon pokemon(pokemonID, trainerID, level);
	bool status = mainIdTree.insert(pokemon);
	if (!status) {
		throw Failure();
	}
	bool status2 = mainLevelTree.insert(pokemon);
	if (!status2) {
		throw Failure();
	}
	bool status3 = (*trainer).getIdTree().insert(pokemon);
	if (!status3) {
		throw Failure();
	}
	bool status4 = (*trainer).getLevelTree().insert(pokemon);
	if (!status4) {
		throw Failure();
	}
	(*trainer).updateMax();
	this->updateMax();
}
int AuxPokeDataProxy::stat(int stat)
{
    if (pokemon() && pokemon()->gen().num <= 2 && basestats[stat] == 0) {
        int boost = statBoost(stat);

        return PokemonInfo::Stat(pokemon()->num(), pokemon()->gen(), stat, pokemon()->level(), 15, 255)
               * PokeFraction(std::max(2+boost, 2), std::max(2-boost, 2));
    }

    if (!playerPoke) {
        return 0;
    }

    if (basestats[stat] == 0) {
        return 0;
    }

    return boostedstats[stat];
}
QScriptValue ScriptEngine::baseStats(int poke, int stat, int gen)
{
    //gen is largely irrelevent outside of specifying for gen 1
    int result = 0;
    Pokemon::uniqueId pokemon(poke);
    if (gen == 1 && stat == SpAttack) {
        result = PokemonInfo::SpecialStat(pokemon);
    } else {
        result = PokemonInfo::BaseStats(pokemon).baseStat(stat);
    }
    return result;
}
QScriptValue ScriptEngine::pokeAbility(int poke, int slot, int _gen)
{
    Pokemon::uniqueId pokemon(poke);
    Pokemon::gen gen(_gen);

    if (PokemonInfo::Exists(pokemon, gen) && gen.num >= GEN_MIN && gen.num <= GenInfo::GenMax()
            && (gen.subnum == gen.wholeGen || gen.subnum <= GenInfo::NumberOfSubgens(gen.num))
            && (slot >= 0) && (slot <= 2)) {
        return PokemonInfo::Ability(pokemon, slot, gen);
    }
    return myengine.undefinedValue();
}
Beispiel #9
0
void Pokedex::levelUp(int pokemonID, int levelIncrease) {
	if (pokemonID <= 0 || levelIncrease <= 0) {
		throw InvalidInput();
	}
	Pokemon pokemon(pokemonID, NO_POKEMON, NO_POKEMON);
	avlNode<Pokemon, pokemonCompareByID>* pokemonNode = mainIdTree.find(
			pokemon);
	if (!pokemonNode) {
		throw Failure();
	}
	int trainerID = pokemonNode->getData().getTrainerId();
	int level = pokemonNode->getData().getLevel();
	this->freePokemon(pokemonID);
	this->catchPokemon(pokemonID, trainerID, level + levelIncrease);
}