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


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

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


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

示例1: Quest_complete

	/**
	 * Silently sets the quest completed/finished flag, this does not fire any events.
	 *
	 * @param boolean completed Sets if the quest has been completed/finished.
	 * @returns am.quest This
	 */
	int Quest_complete(lua_State *lua)
	{
		Quest *quest = castUData<Quest>(lua, 1);
		if (quest)
		{
			if (lua_gettop(lua) == 1)
			{
				lua_pushboolean(lua, quest->isCompleted());
				return 1;
			}
			else if (lua_isbool(lua, 2))
			{
				quest->setCompleted(lua_tobool(lua, 2));
				lua_first(lua);
			}
			return LuaState::expectedArgs(lua, "complete", "boolean complete");
		}
		return LuaState::expectedContext(lua, "complete", "am.quest");
	}
开发者ID:astrellon,项目名称:Rouge,代码行数:25,代码来源:lua_quest.cpp

示例2: QuestL_IsComplete

static int QuestL_IsComplete(lua_State* luaVM)
{
   bool complete = false;
   int nargs = lua_gettop(luaVM);
   
   switch(nargs)
   {
      case 1:
      {
         Quest* quest = luaW_check<Quest>(luaVM, 1);
         if(quest != NULL)
         {
            complete = quest->isCompleted();
         }
         break;
      }
   }
   
   lua_pushboolean(luaVM, complete);
   return 1;
}
开发者ID:linwang,项目名称:EDEn,代码行数:21,代码来源:LuaQuest.cpp

示例3: testSimple

	bool TestLuaQuest::testSimple() {
		LuaState lua;

		Engine *prevEng = Engine::getEngine();
		Engine *eng = new Engine();
		Engine::setEngine(eng);

		Handle<Game> game(new Game(eng));
		eng->setCurrentGame(game);

		Handle<Character> main(new Character());
		main->setGameId("testMainChar");
		game->setMainCharacter(main);

		int loadResult = lua.loadString("Quest, Character, Engine, Game, CoinPurse = import("
			"\"Quest\", \"Character\", \"Engine\", \"Game\", \"CoinPurse\")\n"

			"local quest = Quest.new(\"testQuest\")\n"
			"Quest.add_quest(quest)\n"
			"local game = Engine.game()\n"
			"local main = game:main()\n"
			"local questStarted = false\n"

			"function startQuest(event)\n"
			"	main:on(\"talk\", finishQuest)\n"
			"	main:off(\"talk\", startQuest)\n"
			"end\n"

			"function finishQuest(event)\n"
			"	main:off(\"talk\", finishQuest)\n"
			"	main:add_experience(1000)\n"
			"	main:coin_purse():add_coin(50)\n"
			"	quest:set_complete(true)\n"
			"end\n"
			"main:on(\"talk\", startQuest)\n"
			);

		if (!loadResult)
		{
			lua.logStack("LOAD ERR");
		}
		assert(loadResult);

		lua_Debug ar;
		lua_getstack(lua, 1, &ar);

		Quest *quest = Engine::getGame()->getQuest("testQuest");
		assert(!quest->isCompleted());
		
		am_equals(0, main->getExperience());
		am_equals(0, main->getLevel());
		am_equals(0u, main->getCoinPurse()->getCoin());

		Handle<Event> startEvent(new Event("talk"));
		main->fireEvent<Event>(startEvent);
		main->fireEvent<Event>(startEvent);

		am_equals(1000, main->getExperience());
		am_equals(1, main->getLevel());
		am_equals(50u, main->getCoinPurse()->getCoin());

		Engine::setEngine(prevEng);

		delete eng;

		return true;
	}
开发者ID:astrellon,项目名称:GPP,代码行数:67,代码来源:test_lua_quest.cpp


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