void PokePersonal::reset() { num() = Pokemon::NoPoke; level() = 100; for (int i = 0; i < 4; i++) m_moves[i] = 0; happiness() = 0; shiny() = false; gender() = Pokemon::Neutral; ability() = 0; nickname() = ""; nature() = 0; item() = 0; for (int i = 0; i < 6; i ++) { if (gen() >= 3) { m_EVs[i] = 0; m_DVs[i] = 31; } else { m_EVs[i] = 255; m_DVs[i] = 15; } } }
/** * Print the content of a simple type on a stream */ ostream& SimpleType::print(ostream& dst) const { return dst << "NR"[nature()] << "KB?S"[variability()] << "CI?E"[computability()] << "VS?TS"[vectorability()] << "N?B"[boolean()] << " " << fInterval; }
QDomElement & PokeTeam::toXml(QDomElement &el) const { const_cast<PokeTeam*>(this)->sanityCheck(); QDomDocument doc; el.setAttribute("Nickname", nickname()); el.setAttribute("Num", num().pokenum); el.setAttribute("Item", item()); el.setAttribute("Ability", ability()); el.setAttribute("Nature", nature()); el.setAttribute("Gender", gender()); el.setAttribute("Shiny", shiny()); el.setAttribute("Happiness", happiness()); el.setAttribute("Forme", num().subnum); el.setAttribute("Lvl", level()); el.setAttribute("Gen", gen().num); el.setAttribute("SubGen", gen().subnum); for(int i = 0; i < 4; i++) { QDomElement move = doc.createElement("Move"); el.appendChild(move); QDomText name = doc.createTextNode(QString("%1").arg(this->move(i))); move.appendChild(name); } for(int i = 0; i < 6; i++) { QDomElement Dv = doc.createElement("DV"); el.appendChild(Dv); QDomText Dvname = doc.createTextNode(QString("%1").arg(DV(i))); Dv.appendChild(Dvname); } for(int i = 0; i < 6; i++) { QDomElement Ev = doc.createElement("EV"); el.appendChild(Ev); QDomText Evname = doc.createTextNode(QString("%1").arg(EV(i))); Ev.appendChild(Evname); } return el; }
void PokeTeam::loadFromXml(const QDomElement &poke, int version) { if (poke.hasAttribute("Gen")) { setGen(Pokemon::gen(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt(), poke.attribute("SubGen", QString::number(GenInfo::NumberOfSubgens(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt())-1)).toInt())); } reset(); /* Code to import old teams which had different formes registered as different pokemon numbers */ int num = poke.attribute("Num").toInt(); int forme = poke.attribute("Forme").toInt(); if (gen().num == 4 && num > 493 && forme == 0 && !PokemonInfo::Exists(Pokemon::uniqueId(num, 0), 4)) { //Old way int indexes[] = { 479,479,479,479,479,386,386,386,413,413,492,487 }; int formes[] = { 1,2,3,4,5,1,2,3,1,2,1,1 }; int i = num - 494; setNum(Pokemon::uniqueId(indexes[i], formes[i])); } else { setNum(Pokemon::uniqueId(num, forme)); } bool outdated = gen() < 5 && version < 1; load(); nickname() = poke.attribute("Nickname"); item() = poke.attribute("Item").toInt(); ability() = poke.attribute("Ability").toInt(); if (outdated) { ability() = AbilityInfo::ConvertFromOldAbility(ability()); } nature() = poke.attribute("Nature").toInt(); gender() = poke.attribute("Gender").toInt(); shiny() = QVariant(poke.attribute("Shiny")).toBool(); happiness() = poke.attribute("Happiness").toInt(); level() = poke.attribute("Lvl").toInt(); int cptMove=0; QDomElement moveElement = poke.firstChildElement("Move"); while(!moveElement.isNull()) { int movenum = moveElement.text().toInt(); if (outdated) { movenum = MoveInfo::ConvertFromOldMove(movenum); } setMove(movenum,cptMove,false); cptMove++; moveElement = moveElement.nextSiblingElement("Move"); } int cptDV=0; QDomElement DVElement = poke.firstChildElement("DV"); while(!DVElement.isNull()) { setDV(outdated ? NatureInfo::ConvertToStat(cptDV) : cptDV,DVElement.text().toInt()); cptDV++; DVElement = DVElement.nextSiblingElement("DV"); } int cptEV=0; QDomElement EVElement = poke.firstChildElement("EV"); while(!EVElement.isNull()) { setEV(outdated ? NatureInfo::ConvertToStat(cptEV) : cptEV,EVElement.text().toInt()); cptEV++; EVElement = EVElement.nextSiblingElement("EV"); } }
int PokeTeam::stat(int statno) const { return PokemonInfo::FullStat(num(), gen(), nature(), statno, level(),DV(statno),EV(statno)); }
int PokePersonal::natureBoost(int stat) const { return NatureInfo::Boost(nature(), stat); }
void PokePersonal::runCheck() { if (!PokemonInfo::Exists(num(), gen())) { reset(); return; } if (!PokemonInfo::AFormesShown(num())) { num() = num().original(); } if (gen() <= 2) { ability() = 0; nature() = 0; } else { AbilityGroup ab = PokemonInfo::Abilities(num(), gen()); if (ability() == 0 || (ability() != ab.ab(2) && ability() != ab.ab(1))) ability() = ab.ab(0); } if (gen().num == 2) controlGender(); if (!ItemInfo::Exists(item(), gen())) { item() = 0; } for (int i = 0; i < 6; i++) controlEVs(i); if (gen() <= 2) { for (int i = 0; i < 6; i++) { if (DV(i) >= 15) setDV(i, 15); } } if (gen().num == 2) { setEV(SpDefense, EV(SpAttack)); setDV(SpDefense, DV(SpAttack)); } int avail = PokemonInfo::Gender(num()); if (avail != Pokemon::MaleAndFemaleAvail) { gender() = avail; } else if (gender() == Pokemon::Neutral){ gender() = Pokemon::Male; } int minLevel = PokemonInfo::AbsoluteMinLevel(num(), gen()); if (MoveSetChecker::enforceMinLevels && level() < minLevel) { level() = minLevel; } QSet<int> invalidMoves; MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves); while (invalidMoves.size() > 0) { for (int i = 0; i < 4; i++) { if (invalidMoves.contains(move(i))) { setMove(0, i, false); } } invalidMoves.clear(); MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves); } if (num().pokenum == Pokemon::Keldeo) { if (move(0) == Move::SecretSword || move(1) == Move::SecretSword || move(2) == Move::SecretSword || move(3) == Move::SecretSword) { num() = Pokemon::Keldeo_R; } else { num() = num().original(); } } }