void Player::changeTier(const QString &newtier)
{
    if (tier() == newtier)
        return;
    if (battling()) {
        sendMessage(tr("You can't change tiers while battling."));
        return;
    }
    if (!TierMachine::obj()->exists(newtier)) {
        sendMessage(tr("The tier %1 doesn't exist!").arg(newtier));
        return;
    }
    if (!TierMachine::obj()->isValid(team(), newtier)) {
        Tier *tier = &TierMachine::obj()->tier(newtier);

        if (!tier->allowGen(team().gen)) {
            sendMessage(tr("The generation of your team is invalid for that tier."));
            return;
        }

        QList<int> indexList;
        for(int i = 0; i < 6; i++) {
            if (tier->isBanned(team().poke(i))) {
                indexList.append(i);
            }
        }

        if (indexList.size() > 0) {
            foreach(int i, indexList) {
                sendMessage(tr("The Pokemon '%1' is banned on tier '%2' for the following reasons: %3").arg(PokemonInfo::Name(team().poke(i).num()), newtier, tier->bannedReason(team().poke(i))));
            }
void TierWindow::addNewTier(const QString &name)
{
    TierNode *n = dataTree->getNode(name);

    if (n) {
        QMessageBox::information(this, "Name Taken", "The name is already taken, the tier won't be created");
        return;
    }

    Tier *t = new Tier();
    t->changeName(name);

    dataTree->root.appendChild(t);

    updateTree();
}
void TierMachine::fromString(const QString &s)
{
    /* This, to make sure any threaded code gets treated
      properly before we block it */
    semaphore.acquire(semaphoreMaxLoad);
    clear();
    version += 1;

    tree.loadFromXml(s, this);
    semaphore.release(semaphoreMaxLoad);

    QList<Tier *> tiers = tree.gatherTiers();
    if (tiers.empty()) {
        Tier *t = new Tier(this, &tree.root);
        t->changeName("All");
        tree.root.subNodes.push_back(t);
        tiers.push_back(t);
    }

    QHash<QString, Tier *> tierNames;

    /* Removing duplicates */
    foreach(Tier *t, tiers) {
        if (tierNames.contains(t->name())) {
            t->kill(); /* Destroys the tier */
            continue;
        }
        tierNames.insert(t->name(), t);
    }

    /* Removing useless categories */
    tree.cleanCategories();
    /* Getting the order right if it wasn't alraedy in the file */
    tree.reorder();

    /* Some duplicates may have been removed, so we gather the tiers again */
    tiers = tree.gatherTiers();

    foreach(Tier *t, tiers) {
        m_tierByNames[t->name()] = t;
        m_tierNames.push_back(t->name());
    }
Exemple #4
0
int main()
{
    int round;
    string word;
    char a;
    string b;
    int i;
    Tier t;
    cin >> round;
    for(i=0;i<round+1;i++){
        getline(cin,word);
        if(word=="P"){
            a=word[0];
        }
        else if(word!=""){
            a=word[0];
            b=string(word.begin()+2,word.end());
        }
        else{
            continue;
        }
        if(a=='I'){
            t.insert(b);
        }
        else if(a=='Q'){
            Tier* u = t[b];
            if(u!=NULL){
                cout << "\nY ";
                u->print();
            }
            else {
                cout << "\nN";
            }
        }
        else if(a=='F'){
            if(t.find(b)){
                cout << "\nY";
            } else {
                cout << "\nN";
            }
        }
        else if(a=='P'){
            cout << "\n";
            t.print();
        }
    }
    return 0;
}