/** * @brief GameMaster::wybranoAkcje Jeżeli ta metoda została wywołana, * to grafika zgłasza kliknięcie na przycisk * @param name opcja, która została wybrana */ void GameMaster::doAction(int action) { int fieldIndex = board_->fieldIdToIndex(currentPlayer_->position()); if (action >= PVPActions) { startFight(action); return; } switch ((Action)action) { case EndTurn: currentPlayer_->setHasFoughtRecently(false); gameCycle_->endTurn(); break; case EnemyEasy: case EnemyHard: startFight(action); break; case Market: board_->disablePlayerMove(); marketWindow_ = new MarketWindow(currentPlayer_, playerWindow_, waresInCities_[fieldIndex]); //NOTE CFiend moze lepiej nie alokowac na stercie marketWindow_->setWindowModality(Qt::ApplicationModal); marketWindow_->setAttribute(Qt::WA_DeleteOnClose); marketWindow_->show(); break; case Tavern: board_->disablePlayerMove(); tavernWindow_ = new TavernWindow(currentPlayer_, board_, this, playerWindow_, &questsInCities_[fieldIndex]); //NOTE CFiend moze lepiej nie alokowac na stercie tavernWindow_->setWindowModality(Qt::ApplicationModal); tavernWindow_->setAttribute(Qt::WA_DeleteOnClose); tavernWindow_->show(); break; case Healer: board_->disablePlayerMove(); healerWindow_ = new HealerWindow(currentPlayer_, playerWindow_); //NOTE CFiend moze lepiej nie alokowac na stercie healerWindow_->setWindowModality(Qt::ApplicationModal); healerWindow_->setAttribute(Qt::WA_DeleteOnClose); healerWindow_->show(); break; default: qDebug() << QString::fromUtf8("Błędna opcja"); } }
void QTELayer::countDown(float dt) { if (countDownTime == 0) { countDownLabel->setString("GO!"); }else if(countDownTime > 0){ countDownLabel->setString(String::createWithFormat("%d",countDownTime)->getCString()); }else{//-1 startFight(); unschedule(schedule_selector(QTELayer::countDown)); return; } countDownTime--; countDownLabel->setScale(2.0); countDownLabel->setOpacity(200); countDownLabel->setVisible(true); countDownLabel->runAction(ScaleTo::create(1.0, 0)); }
/** * @brief GameMaster::wykonajQuest Wykonuje zadanie o podanym id. * Działanie jest uzależnione od stopnia wykonania zadania. * Metoda zakłada, że zadanie o podany * @param gracz dane gracza, wykonującego zadanie * @param id id zadania */ void GameMaster::doQuest(int questId) { currentPlayer_->setHasFoughtRecently(false); int questIndex = 0; while (currentPlayer_->quest(questIndex)->id() != questId) ++questIndex; Quest *quest = currentPlayer_->quest(questIndex); switch (quest->type()) { case przynies: if (quest->isPartiallyCompleted()) { grantPrize(currentPlayer_, quest->prize(), false); currentPlayer_->removeQuest(questId); determinePossibleActions(); actionPanel_->displayActions(possibleActions_); } else { quest->setIsPartiallyCompleted(true); quest->setTargetField(quest->employerField()); gameCycle_->endTurn(); } break; case odnajdz: { if (quest->isPartiallyCompleted()) { grantPrize(currentPlayer_, quest->prize(), false); currentPlayer_->removeQuest(questId); determinePossibleActions(); actionPanel_->displayActions(possibleActions_); break; } int chance = BAZOWA_SZANSA_NA_ODNALEZIENIE + currentPlayer_->perception() * BONUS_Z_PERCEPCJI; bool success = qrand() % 100 < chance; QMessageBox::information( gameCycle_->mainWindow(), quest->title(), success ? QString::fromUtf8("Udało Ci się wykonać zadanie.") : QString::fromUtf8("Niestety, nie udało Ci się wykonać zadania.") ); if (success) { if (quest->isReturnRequired()) { quest->setIsPartiallyCompleted(true); quest->setTargetField(quest->employerField()); } else { grantPrize(currentPlayer_, quest->prize(), true); currentPlayer_->removeQuest(questId); } } gameCycle_->endTurn(); break; } case pokonaj: if (quest->isPartiallyCompleted()) { grantPrize(currentPlayer_, quest->prize(), false); currentPlayer_->removeQuest(questId); determinePossibleActions(); actionPanel_->displayActions(possibleActions_); } else { currentQuest_ = quest; startFight(QuestEnemy); } break; } }