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


C++ CItemType类代码示例

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


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

示例1:

CArmorClass *CItemCtx::GetArmorClass(void)

//	GetArmorClass
//
//	Returns the armor class

	{
	//	Get it from the installed device

	if (m_pArmor)
		return m_pArmor->GetClass();

	//	Otherwise, get it from the item

	if (m_pItem)
		{
		CItemType *pType = m_pItem->GetType();
		if (pType)
			return pType->GetArmorClass();
		}

	//	Couldn't get it

	return NULL;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:25,代码来源:CItemCtx.cpp

示例2: FindAmmoDataField

bool CDeviceClass::FindAmmoDataField (CItemType *pItem, const CString &sField, CString *retsValue)

//	FindAmmoDataField
//
//	Finds the device that fires this item and returns the given field

	{
	int i;

	for (i = 0; i < g_pUniverse->GetItemTypeCount(); i++)
		{
		CItemType *pType = g_pUniverse->GetItemType(i);
		CDeviceClass *pWeapon;

		if (pType->IsDevice() 
				&& (pWeapon = pType->GetDeviceClass()))
			{
			int iVariant = pWeapon->GetAmmoVariant(pItem);
			if (iVariant != -1)
				return pWeapon->FindDataField(iVariant, sField, retsValue);
			}
		}

	return false;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:25,代码来源:Devices.cpp

示例3: mathRandom

void CRandomItems::AddItems (SItemAddCtx &Ctx)

//	AddItems
//
//	Add items

	{
	int i, j;
	int iRoll = mathRandom(1, 1000);
	bool bAllAtOnce = (m_iDamaged == 0 && m_Enhanced.GetChance() == 0);

	for (i = 0; i < m_iCount; i++)
		{
		iRoll -= m_Table[i].iProbability;

		if (iRoll <= 0)
			{
			CItemType *pType = m_Table[i].pType;
			int iCount = pType->GetNumberAppearing().Roll();

			//	If we don't have a chance of enhancement or damage, just optimize the
			//	result by adding a group of items.

			if (bAllAtOnce)
				Ctx.ItemList.AddItem(CItem(m_Table[i].pType, iCount));

			//	If this is armor, then treat them as a block

			else if (pType->GetCategory() == itemcatArmor)
				{
				CItem Item(m_Table[i].pType, iCount);

				if (mathRandom(1, 100) <= m_iDamaged)
					Item.SetDamaged();
				else
					m_Enhanced.EnhanceItem(Item);

				Ctx.ItemList.AddItem(Item);
				}

			//	Otherwise, enhance/damage each item individually

			else
				{
				for (j = 0; j < iCount; j++)
					{
					CItem Item(m_Table[i].pType, 1);

					if (mathRandom(1, 100) <= m_iDamaged)
						Item.SetDamaged();
					else
						m_Enhanced.EnhanceItem(Item);

					Ctx.ItemList.AddItem(Item);
					}
				}
			break;
			}
		}
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:60,代码来源:CItemTable.cpp

示例4: GetWeaponType

bool CWeaponFireDesc::FindEventHandler (const CString &sEvent, SEventHandlerDesc *retEvent) const

//	FindEventHandler
//
//	Returns an event handler (if found)

	{
	//	Look for an event handler at the weapon fire level

	ICCItem *pCode;
	if (m_Events.FindEvent(sEvent, &pCode))
		{
		if (retEvent)
			{
			retEvent->pExtension = m_pExtension;
			retEvent->pCode = pCode;
			}

		return true;
		}

	//	Then look for an event handler at the item level

	CItemType *pDevice;
	CItemType *pAmmo = GetWeaponType(&pDevice);
	if (pAmmo && pAmmo->FindEventHandler(sEvent, retEvent))
		return true;

	if (pDevice && pAmmo != pDevice && pDevice->FindEventHandler(sEvent, retEvent))
		return true;

	//	Otherwise, we have no event

	return false;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:35,代码来源:CWeaponFireDesc.cpp

示例5: FindWeaponFor

bool CDeviceClass::FindWeaponFor (CItemType *pItem, CDeviceClass **retpWeapon, int *retiVariant, CWeaponFireDesc **retpDesc)

//	FindWeaponFor
//
//	Returns weapon data for the given item (which may be a weapon or a missile).

	{
	int i;
	CDeviceClass *pDevice;
	int iVariant;

	//	Get the device and variant

	if (pItem->IsMissile())
		{
		iVariant = -1;

		for (i = 0; i < g_pUniverse->GetItemTypeCount(); i++)
			{
			CItemType *pType = g_pUniverse->GetItemType(i);

			if (pDevice = pType->GetDeviceClass())
				{
				iVariant = pDevice->GetAmmoVariant(pItem);
				if (iVariant != -1)
					break;
				}
			}

		if (iVariant == -1)
			return false;
		}
	else
		{
		pDevice = pItem->GetDeviceClass();
		if (pDevice == NULL)
			return false;

		iVariant = 0;
		}

	CWeaponClass *pWeapon = pDevice->AsWeaponClass();
	if (pWeapon == NULL)
		return false;

	CWeaponFireDesc *pDesc = pWeapon->GetVariant(iVariant);

	//	Done

	if (retpWeapon)
		*retpWeapon = pDevice;

	if (retiVariant)
		*retiVariant = iVariant;

	if (retpDesc)
		*retpDesc = pDesc;

	return true;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:60,代码来源:Devices.cpp

示例6: OutputTable

void OutputTable (SItemTableCtx &Ctx, const SItemTypeList &ItemList)
	{
	int i, j;

	if (ItemList.GetCount() == 0)
		return;

	//	Output each row

	for (i = 0; i < ItemList.GetCount(); i++)
		{
		CItemType *pType = ItemList[i];

		for (j = 0; j < Ctx.Cols.GetCount(); j++)
			{
			if (j != 0)
				printf("\t");

			const CString &sField = Ctx.Cols[j];

			//	Get the field value

			CString sValue;
			CItem Item(pType, 1);
			CItemCtx ItemCtx(Item);
			CCodeChainCtx CCCtx;

			ICCItem *pResult = Item.GetProperty(&CCCtx, ItemCtx, sField);

			if (pResult->IsNil())
				sValue = NULL_STR;
			else
				sValue = pResult->Print(&g_pUniverse->GetCC(), PRFLAG_NO_QUOTES | PRFLAG_ENCODE_FOR_DISPLAY);

			pResult->Discard(&g_pUniverse->GetCC());

			//	Format the value

			if (strEquals(sField, FIELD_AVERAGE_DAMAGE) || strEquals(sField, FIELD_POWER_PER_SHOT))
				printf("%.2f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_POWER))
				printf("%.1f", strToInt(sValue, 0, NULL) / 1000.0);
			else if (strEquals(sField, FIELD_TOTAL_COUNT))
				{
				SDesignTypeInfo *pInfo = Ctx.TotalCount.GetAt(pType->GetUNID());
				double rCount = (pInfo ? pInfo->rPerGameMeanCount : 0.0);
				printf("%.2f", rCount);
				}
			else
				printf(sValue.GetASCIIZPointer());
			}

		printf("\n");
		}
	}
开发者ID:bmer,项目名称:Transmuter,代码行数:55,代码来源:ItemTable.cpp

示例7: OutputByAttribute

void OutputByAttribute (SItemTableCtx &Ctx, const SItemTypeList &ItemList)
	{
	int i, j;

	//	Make a categorized list by attribute

	SByAttributeTypeList ByAttributeTable;
	for (i = 0; i < ItemList.GetCount(); i++)
		{
		const CString &sKey = ItemList.GetKey(i);
		CItemType *pType = ItemList[i];

		//	Loop over all attributes

		TArray<CString> Attribs;
		ParseAttributes(pType->GetAttributes(), &Attribs);
		for (j = 0; j < Attribs.GetCount(); j++)
			{
			bool bNew;
			SAttributeEntry *pEntry = ByAttributeTable.SetAt(Attribs[j], &bNew);
			if (bNew)
				pEntry->sAttribute = Attribs[j];

			pEntry->ItemTable.Insert(sKey, pType);
			}

		//	If no attribute

		if (Attribs.GetCount() == 0)
			{
			bool bNew;
			SAttributeEntry *pEntry = ByAttributeTable.SetAt(CONSTLIT("(none)"), &bNew);
			if (bNew)
				pEntry->sAttribute = CONSTLIT("(none)");

			pEntry->ItemTable.Insert(sKey, pType);
			}
		}

	//	Now loop over all attributes

	for (i = 0; i < ByAttributeTable.GetCount(); i++)
		{
		const SAttributeEntry &Entry = ByAttributeTable[i];
		printf("%s\n\n", Entry.sAttribute.GetASCIIZPointer());

		OutputHeader(Ctx);
		OutputTable(Ctx, Entry.ItemTable);
		printf("\n");
		}
	}
开发者ID:bmer,项目名称:Transmuter,代码行数:51,代码来源:ItemTable.cpp

示例8: throw

IContentItem* CRootItem::addContentItem(string text, int posInParent) throw (ExMalformedPatch)
{
	string path = stripFirstSection(text);
	CItemType itemType = getItemType(text);
	if(itemType.getType() == CItemType::E_INVAL ) {
		throw ExMalformedPatch("invalid item type", -1);
	}

	CCategoryItem* parent = getCategoryPtr(path);
	if(parent == 0) {
		parent = mkPath(path);
	}

	//beginInsertItems(posInParent, 1, parent );
	IContentItem* newItem = IContentItem::itemFactory( itemType, this, text, parent, posInParent);
	//endInsertItems();
	return newItem;
}
开发者ID:martinrunge,项目名称:muroa,代码行数:18,代码来源:CRootItem.cpp

示例9: InitTable

CurrencyValue CRandomItems::GetAverageValue (int iLevel)

//	GetAverageValue
//
//	Returns the average value.

	{
	int i;

	//	If this is a dynamic table we need to compute all levels

	if (m_bDynamicLevelFrequency)
		{
		Metric rTotal = 0.0;
		InitTable(GenerateLevelFrequency(m_sLevelFrequency, iLevel));
		m_iDynamicLevel = iLevel;

		for (i = 0; i < m_iCount; i++)
			{
			CItemType *pType = m_Table[i].pType;
			CurrencyValue ItemValue = CEconomyType::ExchangeToCredits(pType->GetCurrencyType(), pType->GetValue(CItemCtx(), true));
			rTotal += (pType->GetNumberAppearing().GetAveValueFloat() * (Metric)ItemValue * (Metric)m_Table[i].iProbability / 1000.0);
			}

		return (CurrencyValue)(rTotal + 0.5);
		}

	//	Otherwise the table is already initialized.

	else
		{
		//	Average value is proportional to chances.

		Metric rTotal = 0.0;
		for (i = 0; i < m_iCount; i++)
			{
			CItemType *pType = m_Table[i].pType;
			CurrencyValue ItemValue = CEconomyType::ExchangeToCredits(pType->GetCurrencyType(), pType->GetValue(CItemCtx(), true));
			rTotal += (pType->GetNumberAppearing().GetAveValueFloat() * (Metric)ItemValue * (Metric)m_Table[i].iProbability / 1000.0);
			}

		return (CurrencyValue)(rTotal + 0.5);
		}
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:44,代码来源:CItemTable.cpp

示例10: setContentPtr

void CRootItem::setContentPtr(const CItemType& type, IContentItem* ptr, const uint32_t hash) {
	pair<map<uint32_t, IContentItem*>::iterator, bool> ret;
	map<uint32_t, IContentItem*>* content_map = m_content_maps[type.getType()];

	ret = content_map->insert(pair<uint32_t, IContentItem*>(hash, ptr));
	if (ret.second==false)
	{
	    std::cerr << "setContentPtr: element '" << ret.first->first << "' already existed";
	    std::cerr << " with a value of " << ret.first->second << std::endl;
	}
}
开发者ID:martinrunge,项目名称:muroa,代码行数:11,代码来源:CRootItem.cpp

示例11: GetItemType

ALERROR CArmorClass::OnBindDesign (SDesignLoadCtx &Ctx)

//	OnBindDesign
//
//	Called on Bind

	{
	ALERROR error;

	//	Compute armor damage adjustments

	if (error = m_DamageAdj.Bind(Ctx, g_pUniverse->GetArmorDamageAdj(m_iDamageAdjLevel)))
		return error;

	//	Cache some events

	CItemType *pType = GetItemType();
	pType->InitCachedEvents(evtCount, CACHED_EVENTS, m_CachedEvents);

	return NOERROR;
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:21,代码来源:CArmorClass.cpp

示例12: GenerateStats

void GenerateStats (CUniverse &Universe, CXMLElement *pCmdLine)
	{
	int i;

	printf("STATS\n\n");

	int iItemTypes = 0;
	for (i = 0; i < Universe.GetItemTypeCount(); i++)
		{
		CItemType *pType = Universe.GetItemType(i);

		//	Do not count virtual items

		if (pType->IsVirtual())
			continue;

		iItemTypes++;
		}

	printf("Item types:\t\t%d\n", iItemTypes);
	printf("Ship classes:\t\t%d\n", Universe.GetShipClassCount());
	printf("Station types:\t\t%d\n", Universe.GetStationTypeCount());
	}
开发者ID:AvanWolf,项目名称:Transcendence,代码行数:23,代码来源:Stats.cpp

示例13: SortTable

void SortTable (SItemTableCtx &Ctx, const TArray<CItemType *> &List, SItemTypeList *retSorted)
	{
	int i;

	//	Loop over all items that match and add them to
	//	a sorted table.

	retSorted->DeleteAll();
	for (i = 0; i < List.GetCount(); i++)
		{
		CItemType *pType = List[i];

		//	Add with sort key

		char szBuffer[1024];
		wsprintf(szBuffer, "%02d%s%02d%s", 
				pType->GetLevel(),
				g_szTypeCode[GetItemType(pType)], 
				GetItemFreq(pType), 
				pType->GetNounPhrase().GetASCIIZPointer());
		retSorted->Insert(CString(szBuffer), pType);
		}
	}
开发者ID:bmer,项目名称:Transmuter,代码行数:23,代码来源:ItemTable.cpp

示例14: InitArmorTable

bool CWeaponBenchmarkCtx::InitArmorTable (void)

//  InitArmorTable
//
//  Initializes the armor table, which lists armor by level.

    {
    int i;

    //  If we've already initialized the table, then nothing to do.

    if (m_ArmorTable.GetCount() != 0)
        return true;

    //  Create table

    for (i = 0; i < g_pUniverse->GetItemTypeCount(); i++)
        {
        CItemType *pType = g_pUniverse->GetItemType(i);

        //  Skip non-armor

        if (!pType->IsArmor()
                || pType->IsVirtual())
            continue;

        //  Add to our list, indexed by level.

        TArray<CItemType *> *pTable = m_ArmorTable.SetAt(pType->GetLevel());
        pTable->Insert(pType);
        }

    //  Done

    return true;
    }
开发者ID:AvanWolf,项目名称:Transcendence,代码行数:36,代码来源:CWeaponBenchmarkCtx.cpp

示例15: if

CWeaponFireDesc *CWeaponFireDesc::FindWeaponFireDescFromFullUNID (const CString &sUNID)

//	FindWeaponFireDesc
//
//	Finds the descriptor by name

	{
	char *pPos = sUNID.GetPointer();

	//	Get the UNID of the type

	DWORD dwUNID = (DWORD)strParseInt(pPos, 0, &pPos);
	if (dwUNID == 0)
		return NULL;

	//	Get the type

	CDesignType *pType = g_pUniverse->FindDesignType(dwUNID);
	if (pType == NULL)
		return NULL;

	//	If this is an item, then it must be a weapon

	if (pType->GetType() == designItemType)
		{
		CItemType *pItemType = CItemType::AsType(pType);
		ASSERT(pItemType);

		CDeviceClass *pDevice = pItemType->GetDeviceClass();
		if (pDevice == NULL)
			return NULL;

		CWeaponClass *pClass = pDevice->AsWeaponClass();
		if (pClass == NULL)
			return NULL;

		//	Get the ordinal

		ASSERT(*pPos == '/');
		pPos++;
		int iOrdinal = strParseInt(pPos, 0, &pPos);

		//	Get the weapon fire desc of the ordinal

		CWeaponFireDesc *pDesc = pClass->GetVariant(iOrdinal);
		if (pDesc == NULL)
			return NULL;

		//	Continue parsing

		return pDesc->FindWeaponFireDesc(CString(pPos));
		}

	//	If this is an effect, then get it from that

	else if (pType->GetType() == designEffectType)
		{
		CEffectCreator *pEffectType = CEffectCreator::AsType(pType);
		ASSERT(pEffectType);

		//	Expect /d

		ASSERT(*pPos == '/');
		pPos++;
		ASSERT(*pPos == 'd');
		pPos++;

		CWeaponFireDesc *pDesc = pEffectType->GetDamageDesc();
		if (pDesc == NULL)
			return NULL;

		//	Continue parsing

		return pDesc->FindWeaponFireDesc(CString(pPos));
		}

	//	Otherwise, we don't know

	else
		return NULL;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:81,代码来源:CWeaponFireDesc.cpp


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