void DeckHandler::newDrawCard(QString code) { DrawCard drawCard(code); drawCard.listItem = new QListWidgetItem(); drawCardList.append(drawCard); ui->drawListWidget->addItem(drawCard.listItem); drawCard.draw(); emit checkCardImage(code); ui->drawListWidget->setHidden(false); QTimer::singleShot(10, this, SLOT(adjustDrawSize())); if(this->drawDisappear>0) QTimer::singleShot(this->drawDisappear*1000, this, SLOT(removeOldestDrawCard())); }
void DeckHandler::newDeckCard(QString code, int total, bool add) { if(code.isEmpty()) return; //Mazo completo if(deckCardList[0].total < (uint)total) { emit pDebug("Deck is full: Not adding: (" + QString::number(total) + ") " + (*cardsJson)[code].value("name").toString(), Warning); return; } //Ya existe en el mazo bool found = false; for(int i=0; i<deckCardList.length(); i++) { if(deckCardList[i].getCode() == code) { if(!add) { emit pDebug((*cardsJson)[code].value("name").toString() + " already in deck."); return; } found = true; deckCardList[i].total+=total; deckCardList[i].remaining+=total; deckCardList[i].draw(true, this->cardHeight); break; } } if(!found) { DeckCard deckCard(code); deckCard.total = total; deckCard.remaining = total; deckCard.listItem = new QListWidgetItem(); insertDeckCard(deckCard); deckCard.draw(true, this->cardHeight); emit checkCardImage(code); } deckCardList[0].total-=total; deckCardList[0].draw(true, this->cardHeight); if(deckCardList[0].total == 0) deckCardList[0].listItem->setHidden(true); emit pDebug("Add to deck: (" + QString::number(total) + ")" + (*cardsJson)[code].value("name").toString()); }
void SecretsHandler::secretStealed(int id, QString code) { ActiveSecret activeSecret; activeSecret.id = id; activeSecret.root.hero = unknown; activeSecret.root.treeItem = new QTreeWidgetItem(ui->secretsTreeWidget); activeSecret.root.treeItem->setExpanded(true); activeSecret.root.code = code; activeSecret.root.draw(); emit checkCardImage(code); activeSecretList.append(activeSecret); ui->secretsTreeWidget->setHidden(false); if(synchronized) ui->tabWidget->setCurrentWidget(ui->tabEnemy); adjustSize(); }
void SecretsHandler::secretPlayed(int id, SecretHero hero) { ActiveSecret activeSecret; activeSecret.id = id; activeSecret.root.hero = hero; activeSecret.root.treeItem = new QTreeWidgetItem(ui->secretsTreeWidget); activeSecret.root.treeItem->setExpanded(true); activeSecret.root.draw(); switch(hero) { case paladin: activeSecret.children.append(SecretCard(AVENGE)); activeSecret.children.append(SecretCard(NOBLE_SACRIFICE)); activeSecret.children.append(SecretCard(REPENTANCE)); activeSecret.children.append(SecretCard(REDEMPTION)); activeSecret.children.append(SecretCard(EYE_FOR_AN_EYE)); activeSecret.children.append(SecretCard(COMPETITIVE_SPIRIT)); break; case hunter: activeSecret.children.append(SecretCard(FREEZING_TRAP)); activeSecret.children.append(SecretCard(EXPLOSIVE_TRAP)); activeSecret.children.append(SecretCard(BEAR_TRAP)); activeSecret.children.append(SecretCard(SNIPE)); activeSecret.children.append(SecretCard(MISDIRECTION)); activeSecret.children.append(SecretCard(SNAKE_TRAP)); break; case mage: activeSecret.children.append(SecretCard(MIRROR_ENTITY)); activeSecret.children.append(SecretCard(DDUPLICATE)); activeSecret.children.append(SecretCard(ICE_BARRIER)); activeSecret.children.append(SecretCard(EFFIGY)); activeSecret.children.append(SecretCard(VAPORIZE)); activeSecret.children.append(SecretCard(COUNTERSPELL)); activeSecret.children.append(SecretCard(SPELLBENDER)); activeSecret.children.append(SecretCard(ICE_BLOCK)); break; case unknown: break; } for(QList<SecretCard>::iterator it = activeSecret.children.begin(); it != activeSecret.children.end(); it++) { it->treeItem = new QTreeWidgetItem(activeSecret.root.treeItem); it->draw(); emit checkCardImage(it->code); } activeSecretList.append(activeSecret); ui->secretsTreeWidget->setHidden(false); if(synchronized) ui->tabWidget->setCurrentWidget(ui->tabEnemy); adjustSize(); emit pDebug("Secret played. Hero: " + QString::number(hero)); }