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


C++ Option::setNextState方法代码示例

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


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

示例1: addAnomalyState

void addAnomalyState(map<int, State*> & states){
	State* state = states.at(8);
	Option* option = new Option();
	option->setChoice("Watch her to see what she will do");
	option->setNextState(states.at(7));
	state->addOption(option);
}
开发者ID:Zinbo,项目名称:EternityOfTheBrokenKings,代码行数:7,代码来源:TextAdventure.cpp

示例2: readInStory

void readInStory(map<int, State*> &statesMap){
	ifstream myReadFile;
	string storyLine;
	smatch match;
	regex numberPattern("(\\d+)");
	regex statePattern("^STATE");
	regex descPattern("^DESCRIPTION");
	regex noOfOptionsPattern("^NO_OF_CHOICES");
	regex stringPattern("\"([^\"]*)\"");

	myReadFile.open("story.txt");
	State* state;
	Option* option;
	int noOfChoices;

	if (myReadFile.is_open()) {
		while (!myReadFile.eof()) {

			//retrieve the next line in the text file.
			getline(myReadFile,storyLine);
			
			//If the line is a state, then create a new state.
			if(isMatch(storyLine, statePattern)){
				int value = atoi(showMatch(storyLine, numberPattern, match).c_str());
				state = new State();
				statesMap[value] = state;
			//Else if the line is a description, add it to the current state.
			}else if(isMatch(storyLine, descPattern)){
				string description = showMatch(storyLine, stringPattern, match);
				state->setDescript(description);
			}
			//Else if the line gives the number of options for the state, then create that many choices.
			else if(isMatch(storyLine, noOfOptionsPattern)){
				noOfChoices = atoi(showMatch(storyLine, numberPattern, match).c_str());
				for(int i = 0; i < noOfChoices; i++){
					option = new Option();
					//Each option has a choice, consequence, and nextStateNumber, so we read all 3 of these in for each option.	
					getline(myReadFile,storyLine);
					string choice = showMatch(storyLine, stringPattern, match);
					option->setChoice(choice);

					getline(myReadFile,storyLine);
					string consequence = showMatch(storyLine, stringPattern, match);
					option->setConsequence(consequence);

					getline(myReadFile,storyLine);
					int nextStateNumber = atoi(showMatch(storyLine, numberPattern, match).c_str());
					option->setNextState(statesMap.at(nextStateNumber));
					state->addOption(option);
				}
			}

		}
	}
	myReadFile.close();

}
开发者ID:Zinbo,项目名称:EternityOfTheBrokenKings,代码行数:57,代码来源:TextAdventure.cpp


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