Skip to content

Commit

Permalink
Hackmons
Browse files Browse the repository at this point in the history
  • Loading branch information
CrystalMoogle committed Apr 6, 2015
1 parent 161437f commit 07a9229
Show file tree
Hide file tree
Showing 26 changed files with 523 additions and 283 deletions.
22 changes: 20 additions & 2 deletions src/BattleServer/battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ BattleChoices BattleSituation::createChoice(int slot)
}

//Mega Evolution is not hindered by Embargo, etc.
if (((ItemInfo::isMegaStone(poke(slot).item()) && ItemInfo::MegaStoneForme(poke(slot).item()).original() == poke(slot).num()) || (poke(slot).num() == Pokemon::Rayquaza && hasMove(slot, Move::DragonAscent))) && !megas[player(slot)]) {
if (canMegaEvolve(slot)) {
Pokemon::uniqueId forme = poke(slot).num() == Pokemon::Rayquaza ? Pokemon::Rayquaza_Mega : ItemInfo::MegaStoneForme(poke(slot).item());
if (!bannedPokes[0].contains(PokemonInfo::Name(forme)) && !bannedPokes[1].contains(PokemonInfo::Name(forme))) {
ret.mega = true;
Expand Down Expand Up @@ -902,7 +902,7 @@ void BattleSituation::megaEvolve(int slot)
//Split to allow Mega Evo to activate on Special Pursuit
//Mega Evolution is not hindered by Embargo, etc.
if (choice(slot).mega()) {
if ((ItemInfo::isMegaStone(poke(slot).item()) && ItemInfo::MegaStoneForme(poke(slot).item()).original() == poke(slot).num()) || (poke(slot).num() == Pokemon::Rayquaza && hasMove(slot, Move::DragonAscent))) {
if (canMegaEvolve(slot)) {
Pokemon::uniqueId forme = poke(slot).num() == Pokemon::Rayquaza ? Pokemon::Rayquaza_Mega : ItemInfo::MegaStoneForme(poke(slot).item());
if (!bannedPokes[0].contains(PokemonInfo::Name(forme)) && !bannedPokes[1].contains(PokemonInfo::Name(forme))) {
sendItemMessage(66, slot, 0, 0, 0, forme.toPokeRef());
Expand Down Expand Up @@ -4442,3 +4442,21 @@ bool BattleSituation::preTransPoke(int s, Pokemon::uniqueId check)
}
return false;
}

bool BattleSituation::canMegaEvolve (int slot) {
if (megas[player(slot)]) {
return false;
}
if (ItemInfo::isMegaStone(poke(slot).item())) {
if (ItemInfo::MegaStoneForme(poke(slot).item()).original() == poke(slot).num()) {
return true;
}
if (ItemInfo::MegaStoneForme(poke(slot).item()).original() == Pokemon::uniqueId(poke(slot).num().pokenum,0)) {
return true;
}
}
if ((poke(slot).num() == Pokemon::Rayquaza && hasMove(slot, Move::DragonAscent))) {
return true;
}
return false;
}
1 change: 1 addition & 0 deletions src/BattleServer/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class BattleSituation : public BattleBase
void symbiosisPass(int s);
bool canPassMStone(int target, int item);
bool preTransPoke(int s, Pokemon::uniqueId check);
bool canMegaEvolve(int slot);
void inflictStatus(int player, int Status, int inflicter, int minturns = 0, int maxturns = 0);
void inflictConfused(int player, int source, bool tell=true);
void inflictRecoil(int source, int target);
Expand Down
10 changes: 10 additions & 0 deletions src/Server/scriptengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,16 @@ bool ScriptEngine::hasTeamPoke(int id, int team, int pokemonnum)
return false;
}

bool ScriptEngine::teamPokeIllegal(int id, int team, int slot)
{
if (!testPlayer("teamPokeIllegal(id, team, slot)", id) || !testTeamCount("teamPokeIllegal(id, team, slot)", id, team)
|| !testRange("teamPokeIllegal(id, team, slot)", slot, 0, 5)) {
return false;
}

return myserver->player(id)->team(team).poke(slot).illegal();
}

QScriptValue ScriptEngine::indexOfTeamPoke(int id, int team, int pokenum)
{
if (!testPlayer("indexOfTeamPoke(id, team, pokenum)", id)
Expand Down
1 change: 1 addition & 0 deletions src/Server/scriptengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class ScriptEngine : public QObject
Q_INVOKABLE QScriptValue teamPokePP(int id, int team, int slot, int moveslot);
Q_INVOKABLE QScriptValue teamPoke(int id, quint32 teamLo, int index, quint32 teamHi = 0);
Q_INVOKABLE QScriptValue teamPokeName(int id, int team, int pokemonnum);
Q_INVOKABLE bool teamPokeIllegal(int id, int team, int slot);
Q_INVOKABLE bool hasTeamPoke(int id, int team, int pokemonnum);
Q_INVOKABLE QScriptValue indexOfTeamPoke(int id, int team, int pokenum);
Q_INVOKABLE bool hasDreamWorldAbility(int id, int team, int slot, int gen = 5);
Expand Down
27 changes: 18 additions & 9 deletions src/Server/tier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,45 +326,48 @@ void Tier::addBanParent(Tier *t)

QString Tier::bannedReason(const PokeBattle &p, bool child) const {
QString errorList = "";
if(banPokes) {
if(bannedPokes.contains(PokemonInfo::NonAestheticForme(p.num()))) {
if (banPokes) {
if (bannedPokes.contains(PokemonInfo::NonAestheticForme(p.num()))) {
errorList += QString("Pokemon %1 is banned, ").arg(PokemonInfo::Name(p.num()));
}
if(bannedMoves.size() > 0) {
if (bannedMoves.size() > 0) {
for(int i = 0; i < 4; i++) {
if(bannedMoves.contains(p.move(i).num())) {
errorList += QString("Move %1 is banned, ").arg(MoveInfo::Name(p.move(i).num()));
}
}
}
if(bannedItems.contains(p.item())) {
if (bannedItems.contains(p.item())) {
errorList += QString("Item %1 is banned, ").arg(ItemInfo::Name(p.item()));
}
if (bannedAbilities.contains(p.ability())) {
errorList += QString("Ability %1 is banned, ").arg(AbilityInfo::Name(p.ability()));
}
} else {
if(bannedPokes.size() > 0 && !bannedPokes.contains(PokemonInfo::NonAestheticForme(p.num()))) {
if (bannedPokes.size() > 0 && !bannedPokes.contains(PokemonInfo::NonAestheticForme(p.num()))) {
errorList += QString("Pokemon %1 is banned, ").arg(PokemonInfo::Name(p.num()));
}
if(bannedMoves.size() > 0) {
if (bannedMoves.size() > 0) {
for(int i = 0; i < 4; i++) {
if(p.move(i).num() != 0 && !bannedMoves.contains(p.move(i).num())) {
errorList += QString("Move %1 is banned, ").arg(MoveInfo::Name(p.move(i).num()));
}
}
}
if(bannedItems.size() > 0 && p.item() != 0 && !bannedItems.contains(p.item())) {
if (bannedItems.size() > 0 && p.item() != 0 && !bannedItems.contains(p.item())) {
errorList += QString("Item %1 is banned, ").arg(ItemInfo::Name(p.item()));
}
if (bannedAbilities.size() > 0 && p.ability() != 0 && !bannedAbilities.contains(p.ability())) {
errorList += QString("Ability %1 is banned, ").arg(AbilityInfo::Name(p.ability()));
}
}
if (allowIllegal != "true" && p.illegal()) {
errorList += QString("Pokemon %1 has an illegal set, ").arg(PokemonInfo::Name(p.num()));
}
if (parent) {
errorList += parent->bannedReason(p, true);
}
if(errorList.length() >= 2 && !child) {
if (errorList.length() >= 2 && !child) {
QStringList errors = errorList.split(", ").toSet().toList(); //remove duplicates
QMutableListIterator<QString> i(errors);
while (i.hasNext()) {
Expand Down Expand Up @@ -432,7 +435,9 @@ bool Tier::isBanned(const PokeBattle &p) const {
return true;
}
}

if (allowIllegal != "true" && p.illegal()) {
return true;
}
if (parent) {
return parent->isBanned(p);
} else {
Expand Down Expand Up @@ -893,6 +898,7 @@ void Tier::loadFromXml(const QDomElement &elem)
}

minGen = elem.attribute("minGen", "-1").toInt();
allowIllegal = elem.attribute("allowIllegal", "false");
maxLevel = elem.attribute("maxLevel", "100").toInt();
numberOfPokemons = elem.attribute("numberOfPokemons", "6").toInt();
maxRestrictedPokes = elem.attribute("numberOfRestricted", "1").toInt();
Expand Down Expand Up @@ -990,6 +996,7 @@ QDomElement & Tier::toXml(QDomElement &dest) const {
dest.setAttribute("gen", m_gen.num);
dest.setAttribute("subgen", m_gen.subnum);
dest.setAttribute("minGen", minGen);
dest.setAttribute("allowIllegal", allowIllegal);
dest.setAttribute("maxLevel", maxLevel);
dest.setAttribute("numberOfPokemons", numberOfPokemons);
dest.setAttribute("numberOfRestricted", maxRestrictedPokes);
Expand Down Expand Up @@ -1231,6 +1238,7 @@ Tier::Tier(TierMachine *boss, TierCategory *cat) : boss(boss), node(cat), holder
parent = nullptr;
m_gen = Pokemon::gen(GenInfo::GenMax(), GenInfo::NumberOfSubgens(GenInfo::GenMax())-1);
minGen = -1;
allowIllegal = "false";
maxLevel = 100;
numberOfPokemons = 6;
maxRestrictedPokes = 1;
Expand Down Expand Up @@ -1298,6 +1306,7 @@ Tier *Tier::dataClone() const
t.maxLevel = maxLevel;
t.m_gen = m_gen;
t.minGen = minGen;
t.allowIllegal = allowIllegal;
t.banParentS = banParentS;
t.bannedItems = bannedItems;
t.bannedMoves = bannedMoves;
Expand Down
1 change: 1 addition & 0 deletions src/Server/tier.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class Tier : public TierNode
int maxLevel;
Pokemon::gen m_gen;
int minGen;
QString allowIllegal;
QString banParentS;
Tier *parent;
QSet<int> bannedItems;
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

#include <qglobal.h>

#define VERSION QString("2.5.2")
#define VERSION QString("2.6.0")

static const quint16 PROTOCOL_VERSION = 3;
static const quint16 PROTOCOL_SUBVERSION = 2;
static const quint16 CLIENT_VERSION_NUMBER = 2520;
static const quint16 CLIENT_VERSION_NUMBER = 2600;
static const int UPDATE_ID = 4;

#ifdef Q_OS_LINUX
Expand Down
25 changes: 20 additions & 5 deletions src/Teambuilder/Teambuilder/evbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <TeambuilderLibrary/theme.h>
#include "evbox.h"
#include "ui_evbox.h"
#include "Teambuilder/pokeedit.h"

EvBox::EvBox(QWidget *parent) :
QWidget(parent),
Expand All @@ -15,7 +16,7 @@ EvBox::EvBox(QWidget *parent) :
QLabel *labels[6] = {ui->hplabel, ui->atklabel, ui->deflabel, ui->satklabel, ui->sdeflabel, ui->speedlabel};
QLineEdit *edits[6] = {ui->hpedit, ui->atkedit, ui->defedit, ui->satkedit, ui->sdefedit, ui->speededit};
QImageButtonLR *boosts[6] = {ui->hpboost, ui->atkboost, ui->defboost, ui->satkboost, ui->sdefboost, ui->speedboost};

PokeEdit::hackMons ? ui->maxEVs->show() : ui->maxEVs->hide();
memcpy(m_sliders, sliders, sizeof(sliders));
memcpy(m_descs, descs, sizeof(descs));
memcpy(m_stats, labels, sizeof(labels));
Expand All @@ -34,6 +35,7 @@ EvBox::EvBox(QWidget *parent) :
connect(m_boosts[i], SIGNAL(rightClick()), this, SLOT(changeToMinusBoost()));
connect(m_boosts[i], SIGNAL(leftClick()), this, SLOT(changeToPlusBoost()));
}
connect(ui->maxEVs, SIGNAL(clicked()), this, SLOT(maxEVs()));
}

void EvBox::updateNatureButtons()
Expand Down Expand Up @@ -138,18 +140,18 @@ void EvBox::updateMain()
ui->totallabel->setText(QString::number(poke().EVSum()));
}

void EvBox::changeEV(int newValue)
void EvBox::changeEV(int newValue, int sentStat)
{
int stat = sender()->property("stat").toInt();
poke().setEV(stat, newValue/4*4);
int stat = sentStat == -1 ? sender()->property("stat").toInt() : sentStat;
poke().setEV(stat, newValue/4*4, PokeEdit::hackMons);
updateEV(stat);
updateMain();
}

void EvBox::changeEV(const QString &newValue)
{
int stat = sender()->property("stat").toInt();
poke().setEV(stat, std::max(std::min(newValue.toInt(), 252), 0));
poke().setEV(stat, std::max(std::min(newValue.toInt(), 252), 0), PokeEdit::hackMons);
updateEV(stat);
updateMain();
}
Expand Down Expand Up @@ -183,3 +185,16 @@ void EvBox::changeToMinusBoost()
emit natureChanged(NatureInfo::NatureOf(plus,minus));
emit natureBoostChanged();
}

void EvBox::changeMaximumEv(bool hack)
{
ui->totalslider->setProperty(("maximum"), hack ? 1512 : 508);
hack ? ui->maxEVs->show() : ui->maxEVs->hide();
}

void EvBox::maxEVs()
{
for (int i = 0; i < 6; i++) {
changeEV(252, i);
}
}
6 changes: 4 additions & 2 deletions src/Teambuilder/Teambuilder/evbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class QSlider;
class QLabel;
class QLineEdit;
class QImageButtonLR;
class PokeEdit;

class EvBox : public QWidget
{
Expand All @@ -21,7 +22,7 @@ class EvBox : public QWidget
explicit EvBox(QWidget *parent = 0);
void setPoke(PokeTeam *poke);
void updateAll();

void changeMaximumEv(bool hack);
~EvBox();

signals:
Expand All @@ -30,9 +31,10 @@ class EvBox : public QWidget

private slots:
void changeEV(const QString &newValue);
void changeEV(int newValue);
void changeEV(int newValue, int sentStat = -1);
void changeToPlusBoost();
void changeToMinusBoost();
void maxEVs();

public slots:
void updateEVs();
Expand Down
Loading

0 comments on commit 07a9229

Please sign in to comment.