当前位置: 首页>>代码示例>>C++>>正文


C++ Quest::isReturnRequired方法代码示例

本文整理汇总了C++中Quest::isReturnRequired方法的典型用法代码示例。如果您正苦于以下问题:C++ Quest::isReturnRequired方法的具体用法?C++ Quest::isReturnRequired怎么用?C++ Quest::isReturnRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quest的用法示例。


在下文中一共展示了Quest::isReturnRequired方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doQuest

/**
 * @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;
	}
}
开发者ID:Tommalla,项目名称:KronikiAndarii,代码行数:71,代码来源:GameMaster.cpp


注:本文中的Quest::isReturnRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。