diff --git a/src/Server/tier.cpp b/src/Server/tier.cpp index 277d86ed61..fb8aae1d8a 100644 --- a/src/Server/tier.cpp +++ b/src/Server/tier.cpp @@ -324,7 +324,7 @@ void Tier::addBanParent(Tier *t) parent = t; } -QString Tier::bannedReason(const PokeBattle &p) const { +QString Tier::bannedReason(const PokeBattle &p, bool child) const { QString errorList = ""; if(banPokes) { if(bannedPokes.contains(PokemonInfo::NonAestheticForme(p.num()))) { @@ -361,9 +361,18 @@ QString Tier::bannedReason(const PokeBattle &p) const { errorList += QString("Ability %1 is banned, ").arg(AbilityInfo::Name(p.ability())); } } - if(errorList.length() >= 2) { - errorList.resize(errorList.size()-2); - errorList += "."; + if (parent) { + errorList += parent->bannedReason(p, true); + } + if(errorList.length() >= 2 && !child) { + QStringList errors = errorList.split(", ").toSet().toList(); //remove duplicates + QMutableListIterator i(errors); + while (i.hasNext()) { + if (i.next().isEmpty()) { + i.remove(); + } + } + errorList = errors.join(", ") + "."; } return errorList; } diff --git a/src/Server/tier.h b/src/Server/tier.h index bd4e1a684a..d84b632001 100644 --- a/src/Server/tier.h +++ b/src/Server/tier.h @@ -100,7 +100,7 @@ class Tier : public TierNode void addBanParent(Tier *t); bool isBanned(const PokeBattle &p) const; - QString bannedReason(const PokeBattle &p) const; + QString bannedReason(const PokeBattle &p, bool child = false) const; bool isRestricted(const PokeBattle &p) const; bool isValid(const TeamBattle &t) const; bool exists(const QString &name);