本文整理汇总了C++中CItemList::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemList::GetCount方法的具体用法?C++ CItemList::GetCount怎么用?C++ CItemList::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemList
的用法示例。
在下文中一共展示了CItemList::GetCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddItems
void CGroupOfGenerators::AddItems (SItemAddCtx &Ctx)
// AddItems
//
// Add items
{
int i, j;
// If we need to adjust counts, then do a separate algorithm
if (SetsAverageValue())
{
// Get the count adjustment.
Metric rCountAdj = GetCountAdj(Ctx.iLevel);
Metric rLoops = floor(rCountAdj);
Metric rLastLoopAdj = rCountAdj - rLoops;
// Loop if we have extra items
int iFullLoops = (int)rLoops;
for (i = 0; i < iFullLoops + 1; i++)
{
// For a full loop we just add the items
if (i < iFullLoops)
AddItemsInt(Ctx);
// Otherwise we need to add partial items
else
{
// Add the items to a private list.
CItemList LocalList;
CItemListManipulator ItemList(LocalList);
SItemAddCtx LocalCtx(ItemList);
LocalCtx.iLevel = Ctx.iLevel;
AddItemsInt(LocalCtx);
// Now loop over the items and adjust the count appropriately.
for (j = 0; j < LocalList.GetCount(); j++)
{
const CItem &Item = LocalList.GetItem(j);
int iOriginalCount = Item.GetCount();
// Adjust the count
Metric rNewCount = iOriginalCount * rLastLoopAdj;
Metric rNewCountInt = floor(rNewCount);
int iNewCount = (int)rNewCountInt;
Metric rExtra = rNewCount - rNewCountInt;
int iExtraChance = (int)(100000.0 * rExtra);
if (mathRandom(0, 100000) < iExtraChance)
iNewCount++;
// Add the item with the new count
if (iNewCount > 0)
{
if (iNewCount == iOriginalCount)
Ctx.ItemList.AddItem(Item);
else
{
CItem NewItem(Item);
NewItem.SetCount(iNewCount);
Ctx.ItemList.AddItem(NewItem);
}
}
}
}
}
}
else
AddItemsInt(Ctx);
}