diff --git a/src/BattleServer/battlebase.cpp b/src/BattleServer/battlebase.cpp index 8316021710..8478411dfa 100644 --- a/src/BattleServer/battlebase.cpp +++ b/src/BattleServer/battlebase.cpp @@ -36,6 +36,7 @@ void BattleBase::init(const BattlePlayer &p1, const BattlePlayer &p2, const Chal restricted[1] = p2.restrictedPokes; bannedPokes[0] = p1.bannedPokes.split(", "); bannedPokes[1] = p2.bannedPokes.split(", "); + bannedZMoves = p1.bannedZMoves.split(", "); ratings[0] = p1.rating; ratings[1] = p2.rating; winMessage[0] = p1.win; @@ -975,6 +976,9 @@ bool BattleBase::validChoice(const BattleChoice &b) return true; } + QString move = MoveInfo::Name(this->move(player, b.attackSlot())); + int item = this->poke(b.slot()).item(); + if (b.attackingChoice()){ /* It's an attack, we check the target is valid */ if (b.target() < 0 || b.target() >= numberOfSlots()) @@ -998,6 +1002,9 @@ bool BattleBase::validChoice(const BattleChoice &b) return false; } } + if (bannedZMoves.contains(move) && item >= 3000 && item <= 3017) { + return false; + } } return true; } diff --git a/src/BattleServer/battlebase.h b/src/BattleServer/battlebase.h index 2f11251343..f8b67fc763 100644 --- a/src/BattleServer/battlebase.h +++ b/src/BattleServer/battlebase.h @@ -189,6 +189,7 @@ protected slots: QString loseMessage[2]; QString tieMessage[2]; QStringList bannedPokes[2]; + QStringList bannedZMoves; bool allowIllegal; /* timers */ diff --git a/src/Server/battlecommunicator.cpp b/src/Server/battlecommunicator.cpp index 246e685912..cb972deda8 100644 --- a/src/Server/battlecommunicator.cpp +++ b/src/Server/battlecommunicator.cpp @@ -62,9 +62,9 @@ void BattleCommunicator::startBattle(Player *p1, Player *p2, const ChallengeInfo Tier & t = TierMachine::obj()->tier(tier); BattlePlayer pb1(p1->name(), p1->id(), p1->rating(team1.tier), p1->avatar(), p1->winningMessage(), p1->losingMessage(), - p1->tieMessage(), t.getMaxLevel(), t.restricted(team1), t.maxRestrictedPokes, t.numberOfPokemons, t.getBannedPokes(), t.allowIllegal == "true"); + p1->tieMessage(), t.getMaxLevel(), t.restricted(team1), t.maxRestrictedPokes, t.numberOfPokemons, t.getBannedPokes(), t.allowIllegal == "true", t.getBannedZMoves(true)); BattlePlayer pb2(p2->name(), p2->id(), p2->rating(team2.tier), p2->avatar(), p2->winningMessage(), p2->losingMessage(), - p2->tieMessage(), t.getMaxLevel(), t.restricted(team2), t.maxRestrictedPokes, t.numberOfPokemons, t.getBannedPokes(), t.allowIllegal == "true"); + p2->tieMessage(), t.getMaxLevel(), t.restricted(team2), t.maxRestrictedPokes, t.numberOfPokemons, t.getBannedPokes(), t.allowIllegal == "true", t.getBannedZMoves(true)); relay->startBattle(id, pb1, pb2, c, team1, team2); } else { BattlePlayer pb1(p1->name(), p1->id(), p1->rating(team1.tier), p1->avatar(), p1->winningMessage(), p1->losingMessage(), diff --git a/src/Server/tier.cpp b/src/Server/tier.cpp index 5c0ff582a2..2bf0de43ac 100644 --- a/src/Server/tier.cpp +++ b/src/Server/tier.cpp @@ -940,6 +940,7 @@ void Tier::loadFromXml(const QDomElement &elem) last_count_time = 0; importBannedMoves(elem.attribute("moves")); + importBannedZMoves(elem.attribute("zmoves")); importBannedItems(elem.attribute("items")); importBannedPokes(elem.attribute("pokemons")); importBannedAbilities(elem.attribute("abilities", "")); @@ -1027,6 +1028,7 @@ QDomElement & Tier::toXml(QDomElement &dest) const { dest.setAttribute("mode", mode); dest.setAttribute("displayOrder", displayOrder); dest.setAttribute("moves", getBannedMoves()); + dest.setAttribute("zmoves", getBannedZMoves()); dest.setAttribute("items", getBannedItems()); dest.setAttribute("abilities", getBannedAbilities()); dest.setAttribute("pokemons", getBannedPokes()); @@ -1105,6 +1107,19 @@ QString Tier::getBannedMoves() const return bannedMovesS.join(", "); } +QString Tier::getBannedZMoves(bool parentNeeded) const +{ + QStringList bannedZMovesS; + foreach(int zmove, bannedZMoves) { + bannedZMovesS.append(MoveInfo::Name(zmove)); + } + if (parent && parentNeeded) { + bannedZMovesS.append(parent->getBannedZMoves()); + } + bannedZMovesS.sort(); + return bannedZMovesS.join(", "); +} + QString Tier::getBannedAbilities() const { QStringList bannedAbilitiesS; @@ -1175,6 +1190,20 @@ void Tier::importBannedMoves(const QString &s) } } +void Tier::importBannedZMoves(const QString &s) +{ + bannedZMoves.clear(); + if (s.length() == 0) + return; + QStringList zmoves = s.split(","); + foreach(QString zmove, zmoves) { + int num = MoveInfo::Number(zmove.trimmed()); + + if (num != 0) + bannedZMoves.insert(num); + } +} + void Tier::importBannedAbilities(const QString &s) { bannedAbilities.clear(); @@ -1347,6 +1376,7 @@ Tier *Tier::dataClone() const t.banParentS = banParentS; t.bannedItems = bannedItems; t.bannedMoves = bannedMoves; + t.bannedZMoves = bannedZMoves; t.bannedAbilities = bannedAbilities; t.bannedPokes = bannedPokes; t.restrictedPokes = restrictedPokes; diff --git a/src/Server/tier.h b/src/Server/tier.h index 44a86eb31b..c1f2e04592 100644 --- a/src/Server/tier.h +++ b/src/Server/tier.h @@ -126,6 +126,7 @@ class Tier : public TierNode QString getBannedPokes(bool parentNeeded = false) const; QString getRestrictedPokes() const; QString getBannedMoves() const; + QString getBannedZMoves(bool parentNeeded = false) const; QString getBannedItems() const; QString getBannedAbilities() const; int getGeneration(); @@ -133,6 +134,7 @@ class Tier : public TierNode void importBannedPokes(const QString &); void importRestrictedPokes(const QString &); void importBannedMoves(const QString &); + void importBannedZMoves(const QString &); void importBannedItems(const QString &); void importBannedAbilities(const QString &); @@ -196,6 +198,7 @@ class Tier : public TierNode Tier *parent; QSet bannedItems; QSet bannedMoves; + QSet bannedZMoves; QSet bannedAbilities; QSet bannedPokes; QSet restrictedPokes; diff --git a/src/Server/tierwindow.cpp b/src/Server/tierwindow.cpp index 8024ef2010..164537ff24 100644 --- a/src/Server/tierwindow.cpp +++ b/src/Server/tierwindow.cpp @@ -159,6 +159,7 @@ void TierWindow::openTierEdit(Tier *t) helper->addConfigHelper(new ConfigSpin("Max number of pokemon", t->numberOfPokemons, 1, 6)); helper->addConfigHelper(new ConfigLine("Pokemon", pokemons)); helper->addConfigHelper(new ConfigLine("Moves", moves)); + helper->addConfigHelper(new ConfigLine("ZMoves", zmoves)); helper->addConfigHelper(new ConfigLine("Items", items)); helper->addConfigHelper(new ConfigLine("Abilities", abilities)); helper->addConfigHelper(new ConfigSpin("Max number of restricted pokemon", t->maxRestrictedPokes, 0, 6)); @@ -167,6 +168,7 @@ void TierWindow::openTierEdit(Tier *t) pokemons = t->getBannedPokes(); moves = t->getBannedMoves(); + zmoves = t->getBannedZMoves(); items = t->getBannedItems(); abilities = t->getBannedAbilities(); restrPokemons = t->getRestrictedPokes(); @@ -274,6 +276,7 @@ void TierWindow::updateTier() currentTier->importBannedItems(items); currentTier->importBannedPokes(pokemons); currentTier->importBannedMoves(moves); + currentTier->importBannedZMoves(zmoves); currentTier->importBannedAbilities(abilities); currentTier->importRestrictedPokes(restrPokemons); diff --git a/src/Server/tierwindow.h b/src/Server/tierwindow.h index 193c05f050..fd4b8e24d6 100644 --- a/src/Server/tierwindow.h +++ b/src/Server/tierwindow.h @@ -45,7 +45,7 @@ private slots: void clearCurrentEdit(); /* Data used to configure categories / tiers */ QString parent; - QString pokemons, restrPokemons, moves, items, abilities; + QString pokemons, restrPokemons, moves, zmoves, items, abilities; TierCategory *currentTierCat; Tier *currentTier; Type currentType; diff --git a/src/libraries/PokemonInfo/battlestructs.cpp b/src/libraries/PokemonInfo/battlestructs.cpp index 42988d5593..ac9c1d197f 100644 --- a/src/libraries/PokemonInfo/battlestructs.cpp +++ b/src/libraries/PokemonInfo/battlestructs.cpp @@ -1130,12 +1130,12 @@ DataStream & operator << (DataStream &out, const ChallengeInfo & c) { } DataStream & operator >> (DataStream &in, BattlePlayer & c) { - in >> c.id >> c.name >> c.avatar >> c.rating >> c.win >> c.lose >> c.tie >> c.restrictedCount >> c.restrictedPokes >> c.teamCount >> c.maxlevel >> c.bannedPokes >> c.allowIllegal; + in >> c.id >> c.name >> c.avatar >> c.rating >> c.win >> c.lose >> c.tie >> c.restrictedCount >> c.restrictedPokes >> c.teamCount >> c.maxlevel >> c.bannedPokes >> c.allowIllegal >> c.bannedZMoves; return in; } DataStream & operator << (DataStream &out, const BattlePlayer & c) { - out << c.id << c.name << c.avatar << c.rating << c.win << c.lose << c.tie << c.restrictedCount << c.restrictedPokes << c.teamCount << c.maxlevel << c.bannedPokes << c.allowIllegal; + out << c.id << c.name << c.avatar << c.rating << c.win << c.lose << c.tie << c.restrictedCount << c.restrictedPokes << c.teamCount << c.maxlevel << c.bannedPokes << c.allowIllegal << c.bannedZMoves; return out; } diff --git a/src/libraries/PokemonInfo/battlestructs.h b/src/libraries/PokemonInfo/battlestructs.h index d5fa4a8198..335f40a1c6 100644 --- a/src/libraries/PokemonInfo/battlestructs.h +++ b/src/libraries/PokemonInfo/battlestructs.h @@ -575,11 +575,12 @@ struct BattlePlayer quint8 teamCount; QString bannedPokes; bool allowIllegal; + QString bannedZMoves; BattlePlayer(){} BattlePlayer(const QString &name, int id, int rating=0, int avatar=0, const QString &win="", const QString &lose="", - const QString &tie="", int maxlevel=100, int restrictedPokes=0, int restrictedCount=0, int teamCount=6, const QString &bannedPokes="", bool allowIllegal = false) + const QString &tie="", int maxlevel=100, int restrictedPokes=0, int restrictedCount=0, int teamCount=6, const QString &bannedPokes="", bool allowIllegal = false, const QString &bannedZMoves="") : name(name), win(win), lose(lose), tie(tie), rating(rating), avatar(avatar), id(id), maxlevel(maxlevel), - restrictedPokes(restrictedPokes), restrictedCount(restrictedCount), teamCount(teamCount), bannedPokes(bannedPokes), allowIllegal(allowIllegal){} + restrictedPokes(restrictedPokes), restrictedCount(restrictedCount), teamCount(teamCount), bannedPokes(bannedPokes), allowIllegal(allowIllegal), bannedZMoves(bannedZMoves){} }; DataStream & operator >> (DataStream &in, BattlePlayer &p);