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


C++ CGameItemPtr::getPhraseId方法代码示例

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


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

示例1: isExchangeAllowed

bool CInterShardExchangeValidator::isExchangeAllowed(const CGameItemPtr& theItem, TShardId shardId0, TShardId shardId1) const
{
	// allow all exchanges between characters from the same shard
	if (shardId0==shardId1) return true;

	// allow all exchanges of plot items
	if ( theItem->getStaticForm()->Family == ITEMFAMILY::SCROLL_R2 ) return true;

	// determine the maximum level for items exchanged between the 2 shards
	TLevelCap levelLimit= std::min(getLevelCap(shardId0),getLevelCap(shardId1));

	// if item is too high level then refuse
	if (theItem->quality()>levelLimit) return false;

	// if item is flagged as non-shardExchangeable then refuse
	if (theItem->getStaticForm()->ShardExchangeable==false) return false;

	// if item is named (and not a plot item) then refuse
	if (!theItem->getPhraseId().empty()) return false;

	// we've found no reason to refuse so return true
	return true;
}
开发者ID:mixxit,项目名称:solinia,代码行数:23,代码来源:inter_shard_exchange_validator.cpp

示例2: loadNamedItemsFromFile

//-----------------------------------------------------------------------------
void CNamedItems::loadNamedItemsFromFile(const std::string & fileName)
{
	CHashMap<std::string, CGameItemPtr>::iterator it;
	for (it = _NamedItems.begin(); it != _NamedItems.end(); ++it)
	{
		GameItemManager.destroyItem((*it).second);
	}
	_NamedItems.clear();

	string path;
	try
	{
		path = CPath::lookup(fileName);
	}
	catch (Exception &)
	{
		nlwarning("<NAMED_ITEMS> file '%s' was not found", fileName.c_str());
		return;
	}

	static CPersistentDataRecord	pdr;
	pdr.clear();
	pdr.readFromTxtFile(path.c_str());
	CInventoryPtr inv = loadFromPdr(pdr);
	if (inv == NULL)
	{
		nlwarning("<NAMED_ITEMS> error while loading items from the PDR");
		return;
	}

	const uint size = inv->getSlotCount();
	nlinfo("loading '%u' named items", size);
	for (uint i = 0; inv->getFreeSlotCount() != inv->getSlotCount() && i < size; ++i)
	{
		if (inv->getItem(i) == NULL)
			continue;
		CGameItemPtr item = inv->removeItem(i);
		if (item != NULL)
		{
			if (item->getSheetId() == CSheetId::Unknown)
			{
				nlwarning("<NAMED_ITEMS> item '%u' has invalid sheet id", i);
				GameItemManager.destroyItem(item);
				continue;
			}
			if (item->getPhraseId().empty())
			{
				nlwarning("<NAMED_ITEMS> item '%u' has no name", i);
				GameItemManager.destroyItem(item);
				continue;
			}
			if (_NamedItems.find(item->getPhraseId()) != _NamedItems.end())
			{
				nlwarning("<NAMED_ITEMS> item '%u', name '%s' exists more than once", i, item->getPhraseId().c_str());
				GameItemManager.destroyItem(item);
				continue;
			}

			// Yoyo: force this item to work with the new form requirement system.
			// BUT: do it only if _UseNewSystemRequirement==false (if LDs put true, we suppose that the named item has special req value)
			if(item->getUseNewSystemRequirement()==false)
				item->computeRequirementFromForm();

			nldebug("<NAMED_ITEMS> creating named item '%s'",item->getPhraseId().c_str());
			_NamedItems.insert(make_pair(item->getPhraseId(), item));
		}
	}
}
开发者ID:mixxit,项目名称:solinia,代码行数:69,代码来源:named_items.cpp


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