Skip to content

Commit

Permalink
Add ban parent's reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
CrystalMoogle committed Apr 4, 2015
1 parent 1498d77 commit 380e9f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/Server/tier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))) {
Expand Down Expand Up @@ -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<QString> i(errors);
while (i.hasNext()) {
if (i.next().isEmpty()) {
i.remove();
}
}
errorList = errors.join(", ") + ".";
}
return errorList;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Server/tier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 380e9f6

Please sign in to comment.