本文整理汇总了C++中CItemType::GetNounPhrase方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemType::GetNounPhrase方法的具体用法?C++ CItemType::GetNounPhrase怎么用?C++ CItemType::GetNounPhrase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemType
的用法示例。
在下文中一共展示了CItemType::GetNounPhrase方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: GenerateWeaponEffectChart
//.........这里部分代码省略.........
|| pSystem->CreateStation(pTargetType, NULL, CVector(), &pStation) != NOERROR)
{
printf("ERROR: Unable to create station.\n");
return;
}
// Create the weapon platform some distance away
CSovereign *pPlatformSovereign = Universe.FindSovereign(PLAYER_SOVEREIGN_UNID);
CShip *pPlatform;
if (pPlatformSovereign == NULL
|| pSystem->CreateShip(dwPlatformUNID,
NULL,
NULL,
pPlatformSovereign,
CVector(-5.0 * LIGHT_SECOND, 0.),
CVector(),
0,
NULL,
NULL,
&pPlatform) != NOERROR)
{
printf("ERROR: Unable to create weapons platform.\n");
return;
}
// Set the attacker to hold
IShipController *pController = pPlatform->GetController();
if (pController == NULL)
{
printf("ERROR: No controller for ship.\n");
return;
}
pController->AddOrder(IShipController::orderHold, NULL, IShipController::SData());
pPlatform->SetControllerEnabled(false);
// Install the largest possible reactor on the ship
CItemType *pReactorType = Universe.FindItemType(REACTOR_UNID);
if (pReactorType)
{
CItem ReactorItem(pReactorType, 1);
CItemListManipulator ItemList(pPlatform->GetItemList());
ItemList.AddItem(ReactorItem);
pPlatform->OnComponentChanged(comCargo);
pPlatform->ItemsModified();
pPlatform->InvalidateItemListAddRemove();
pPlatform->InstallItemAsDevice(ItemList);
}
// Set the POV
Universe.SetPOV(pStation);
pSystem->SetPOVLRS(pStation);
// Prepare system
Universe.UpdateExtended();
Universe.GarbageCollectLibraryBitmaps();
Universe.StartGame(true);
// Output each weapon
int xOrigin;
int yOrigin;
CG32bitImage &Image = Output.GetOutputImage(&xOrigin, &yOrigin);
const CG16bitFont &TitleFont = Output.GetStyleFont(STYLE_TITLE);
CG32bitPixel rgbTitleColor = Output.GetStyleColor(STYLE_TITLE);
for (i = 0; i < Selection.GetCount(); i++)
{
CItemType *pType = Selection.GetItemType(i);
// Compute the metrics of this row
int xRow = xOrigin + (i % iColumns) * cxRow;
int yRow = yOrigin + (i / iColumns) * cyRow;
// Paint the weapon title
Image.Fill(xRow, yRow, cxRow, cyRow, CG32bitPixel(0x40, 0x40, 0x40));
TitleFont.DrawText(Image, xRow + 8, yRow, rgbTitleColor, pType->GetNounPhrase());
// Paint the frames
PaintWeaponFrames(Image, pType, pPlatform, iFramesPerItem,
xRow + ITEM_ICON_WIDTH + cxFrameHorzMargin,
yRow + cyRowTitle,
cxMaxDistPerTick,
cyFrame);
}
// Done
Output.Output();
}
示例3: OutputByShipClass
void OutputByShipClass (SItemTableCtx &Ctx, const SItemTypeList &ItemList, bool bShowUsage)
{
int i, j;
// Make a map of ship classes for each item
TSortMap<DWORD, TArray<CShipClass *>> ItemToShipClass;
for (i = 0; i < g_pUniverse->GetShipClassCount(); i++)
{
CShipClass *pClass = g_pUniverse->GetShipClass(i);
// Skip non-generic ones
if (!pClass->HasLiteralAttribute(CONSTLIT("genericClass")))
continue;
// Add the list of types used by the ship
TSortMap<DWORD, bool> TypesUsed;
pClass->AddTypesUsed(&TypesUsed);
// For each item type, add it to the map
for (j = 0; j < TypesUsed.GetCount(); j++)
{
CDesignType *pType = g_pUniverse->FindDesignType(TypesUsed.GetKey(j));
if (pType && pType->GetType() == designItemType)
{
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
pList->Insert(pClass);
}
}
}
// If we want to show usage, then we print each item along with the
// ship classes using each item.
if (bShowUsage)
{
for (i = 0; i < ItemList.GetCount(); i++)
{
CItemType *pType = ItemList[i];
printf("%s\n", (LPSTR)pType->GetNounPhrase());
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
printf("\t%s\n", (LPSTR)pList->GetAt(j)->GetName());
if (pList->GetCount() == 0)
printf("\t(none)\n");
printf("\n");
}
}
// Otherwise we categorize by ship class
else
{
// Now make a list of all ship classes that have our items
SByShipClassTypeList ByShipClassTable;
for (i = 0; i < ItemList.GetCount(); i++)
{
const CString &sKey = ItemList.GetKey(i);
CItemType *pType = ItemList[i];
// Loop over all ship classes
TArray<CShipClass *> *pList = ItemToShipClass.SetAt(pType->GetUNID());
for (j = 0; j < pList->GetCount(); j++)
{
CString sClassName = pList->GetAt(j)->GetName();
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(sClassName, &bNew);
if (bNew)
pEntry->sShipClassName = sClassName;
pEntry->ItemTable.Insert(sKey, pType);
}
// If no ship class
if (pList->GetCount() == 0)
{
bool bNew;
SShipClassEntry *pEntry = ByShipClassTable.SetAt(CONSTLIT("(none)"), &bNew);
if (bNew)
pEntry->sShipClassName = CONSTLIT("(none)");
pEntry->ItemTable.Insert(sKey, pType);
}
}
// Now loop over all attributes
for (i = 0; i < ByShipClassTable.GetCount(); i++)
{
const SShipClassEntry &Entry = ByShipClassTable[i];
//.........这里部分代码省略.........
示例4: GenerateShieldStats
void GenerateShieldStats (CUniverse &Universe, CXMLElement *pCmdLine)
{
int i;
CString sUNID = pCmdLine->GetAttribute(CONSTLIT("unid"));
DWORD dwUNID = strToInt(sUNID, 0, NULL);
CItemType *pItem = Universe.FindItemType(dwUNID);
if (pItem == NULL)
{
CItemCriteria Crit;
CItem::InitCriteriaAll(&Crit);
CItem Item = CItem::CreateItemByName(sUNID, Crit);
pItem = Item.GetType();
if (pItem == NULL)
{
printf("ERROR: Unknown item '%s'\n", sUNID.GetASCIIZPointer());
return;
}
}
if (pItem->GetCategory() != itemcatShields)
{
printf("ERROR: Item '%s' is not a shield generator\n", pItem->GetNounPhrase().GetASCIIZPointer());
return;
}
bool bVerbose = pCmdLine->GetAttributeBool(CONSTLIT("verbose"));
bool bEval = pCmdLine->GetAttributeBool(CONSTLIT("eval"));
// Get the stats for the shield
Metric rHP = (Metric)pItem->GetDataFieldInteger(FIELD_HP);
Metric rHPRegenPerTick = pItem->GetDataFieldInteger(FIELD_REGEN) / 1000.0;
int iDamageAdj[damageCount];
CString sDamageAdj = pItem->GetDataField(CONSTLIT("damageAdj"));
char *pPos = sDamageAdj.GetASCIIZPointer();
int iCount = 0;
while (iCount < damageCount)
{
iDamageAdj[iCount] = strParseInt(pPos, 0, &pPos, NULL);
if (*pPos != '\0')
pPos++;
iCount++;
}
// Print header
printf("%s\n\n", pItem->GetNounPhrase().GetASCIIZPointer());
// Loop over all weapons and sort them by level and then name
CSymbolTable List(FALSE, TRUE);
for (i = 0; i < Universe.GetItemTypeCount(); i++)
{
CItemType *pWeapon = Universe.GetItemType(i);
if (pWeapon->GetCategory() != itemcatWeapon)
continue;
CString sLevel = (pWeapon->GetLevel() < 10 ? strPatternSubst(CONSTLIT("0%d"), pWeapon->GetLevel()) : strFromInt(pWeapon->GetLevel(), FALSE));
CString sSortName = strPatternSubst(CONSTLIT("%s%s"), sLevel, pWeapon->GetNounPhrase());
List.AddEntry(sSortName, (CObject *)pWeapon);
}
// Loop over sorted list and output data
for (i = 0; i < List.GetCount(); i++)
{
CItemType *pWeapon = (CItemType *)List.GetValue(i);
// Get the data for the weapon
int iFireDelay = pWeapon->GetDataFieldInteger(CONSTLIT("fireDelay"));
Metric rAverageDamage = pWeapon->GetDataFieldInteger(CONSTLIT("averageDamage")) / 1000.0;
int iDamageType = pWeapon->GetDataFieldInteger(CONSTLIT("damageType"));
if (iDamageType < 0 || iDamageType >= damageCount)
iDamageType = 0;
// Adjust damage for type
rAverageDamage = rAverageDamage * (iDamageAdj[iDamageType] / 100.0);
if (rAverageDamage < 1.0)
rAverageDamage = 0.0;
// Calculate how many shots it would take to pierce through the shields
char szBuffer[256];
Metric rShotsToDeplete;
Metric rRegenPerShot = rHPRegenPerTick * (Metric)iFireDelay;
if (rRegenPerShot >= rAverageDamage)
{
rShotsToDeplete = 1000000.0;
lstrcpy(szBuffer, "ineffective");
}
else
{
Metric rDrainPerShot = rAverageDamage - rRegenPerShot;
rShotsToDeplete = rHP / rDrainPerShot;
sprintf(szBuffer, "%.2f", rShotsToDeplete);
//.........这里部分代码省略.........
示例5: CreateClassInfoItem
void CUIHelper::CreateClassInfoItem (const CItem &Item, int x, int y, int cxWidth, DWORD dwOptions, const CString &sExtraDesc, int *retcyHeight, IAnimatron **retpInfo) const
// CreateClassInfoItem
//
// Creates an item info animation
{
const CVisualPalette &VI = m_HI.GetVisuals();
const CG16bitFont &MediumFont = VI.GetFont(fontMedium);
const CG16bitFont &MediumBoldFont = VI.GetFont(fontMediumBold);
const CG16bitFont &SubTitleFont = VI.GetFont(fontSubTitle);
// Handle some edge conditions
CItemType *pType = Item.GetType();
if (pType == NULL)
{
if (retcyHeight)
*retcyHeight = 0;
CAniSequencer::Create(CVector(x, y), (CAniSequencer **)retpInfo);
return;
}
// Figure out some dimensions and metrics. Everything is relative to x, y.
bool bRightAlign = ((dwOptions & OPTION_ITEM_RIGHT_ALIGN) ? true : false);
int cxIcon = SMALL_ICON_WIDTH;
int cyIcon = SMALL_ICON_HEIGHT;
int xIcon = (bRightAlign ? -cxIcon : 0);
int yIcon = 0;
int cxText = cxWidth - (cxIcon + ITEM_INFO_SPACING_HORZ);
int xText = (bRightAlign ? -cxWidth : cxIcon + ITEM_INFO_SPACING_HORZ);
int yText = 0;
// Create a sequencer to hold all the controls
CAniSequencer *pRoot;
CAniSequencer::Create(CVector(x, y), &pRoot);
// Create a small item icon
const CObjectImageArray &Image = pType->GetImage();
RECT rcImage = Image.GetImageRect();
if (!Image.IsEmpty())
{
CG16bitImage *pIcon = new CG16bitImage;
pIcon->CreateFromImageTransformed(Image.GetImage(),
rcImage.left,
rcImage.top,
RectWidth(rcImage),
RectHeight(rcImage),
(Metric)SMALL_ICON_WIDTH / RectWidth(rcImage),
(Metric)SMALL_ICON_HEIGHT / RectHeight(rcImage),
0.0);
IAnimatron *pImageFrame = new CAniRect;
pImageFrame->SetPropertyVector(PROP_POSITION, CVector(xIcon, yIcon));
pImageFrame->SetPropertyVector(PROP_SCALE, CVector(SMALL_ICON_WIDTH, SMALL_ICON_HEIGHT));
pImageFrame->SetFillMethod(new CAniImageFill(pIcon, true));
pRoot->AddTrack(pImageFrame, 0);
}
// Create text
int cyText = 0;
IAnimatron *pName = new CAniText;
pName->SetPropertyVector(PROP_POSITION, CVector(xText, yText + cyText));
pName->SetPropertyVector(PROP_SCALE, CVector(cxText, 1000));
pName->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogInput));
pName->SetPropertyFont(PROP_FONT, &MediumBoldFont);
pName->SetPropertyString(PROP_TEXT, pType->GetNounPhrase(nounActual));
if (bRightAlign)
pName->SetPropertyString(PROP_TEXT_ALIGN_HORZ, ALIGN_RIGHT);
pRoot->AddTrack(pName, 0);
cyText += MediumBoldFont.GetHeight();
// Add the damage type adjustment
CItemDataAnimatron *pDamageDesc = new CItemDataAnimatron(VI, Item);
if (!pDamageDesc->IsEmpty())
{
pDamageDesc->SetPropertyVector(PROP_POSITION, CVector(xText, yText + cyText));
pDamageDesc->SetPropertyVector(PROP_SCALE, CVector(cxText, 1000));
if (bRightAlign)
pDamageDesc->SetPropertyString(PROP_TEXT_ALIGN_HORZ, ALIGN_RIGHT);
pRoot->AddTrack(pDamageDesc, 0);
RECT rcRect;
pDamageDesc->GetSpacingRect(&rcRect);
cyText += RectHeight(rcRect);
}
else
delete pDamageDesc;
//.........这里部分代码省略.........
示例6: GenerateItemTable
void GenerateItemTable (CUniverse &Universe, CXMLElement *pCmdLine)
{
ALERROR error;
int i, j;
// Compute the criteria
CItemCriteria Crit;
CString sCriteria;
if (pCmdLine->FindAttribute(CRITERIA_ATTRIB, &sCriteria))
CItem::ParseCriteria(sCriteria, &Crit);
else
CItem::InitCriteriaAll(&Crit);
// Generate a table
CSymbolTable Table(FALSE, TRUE);
// Loop over all items that match and add them to
// a sorted table.
for (j = 0; j < Universe.GetItemTypeCount(); j++)
{
CItemType *pType = Universe.GetItemType(j);
CItem Item(pType, 1);
if (!Item.MatchesCriteria(Crit))
continue;
// Figure out the sort order
char szBuffer[1024];
wsprintf(szBuffer, "%02d%s%02d%s",
pType->GetLevel(),
g_szTypeCode[GetItemType(pType)],
GetItemFreq(pType),
pType->GetNounPhrase().GetASCIIZPointer());
Table.AddEntry(CString(szBuffer), (CObject *)pType);
}
// If we need to output total count, then load the table
CSymbolTable TotalCount(TRUE, TRUE);
if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
{
if (error = LoadTotalCount(TOTAL_COUNT_FILENAME, TotalCount))
return;
}
// If we've got any entries in the table, output now
if (Table.GetCount())
{
// Generate a list of columns to display
CStringArray Cols;
Cols.AppendString(FIELD_LEVEL);
Cols.AppendString(FIELD_TYPE);
Cols.AppendString(FIELD_FREQUENCY);
Cols.AppendString(FIELD_NAME);
// More columns from command-line
if (pCmdLine->GetAttributeBool(FIELD_AVERAGE_COUNT))
Cols.AppendString(FIELD_AVERAGE_COUNT);
if (pCmdLine->GetAttributeBool(FIELD_BALANCE))
Cols.AppendString(FIELD_BALANCE);
if (pCmdLine->GetAttributeBool(FIELD_COST))
Cols.AppendString(FIELD_COST);
if (pCmdLine->GetAttributeBool(FIELD_INSTALL_COST))
Cols.AppendString(FIELD_INSTALL_COST);
if (pCmdLine->GetAttributeBool(FIELD_MASS))
Cols.AppendString(FIELD_MASS);
if (pCmdLine->GetAttributeBool(FIELD_TOTAL_COUNT))
Cols.AppendString(FIELD_TOTAL_COUNT);
if (pCmdLine->GetAttributeBool(FIELD_REFERENCE))
Cols.AppendString(FIELD_REFERENCE);
if (pCmdLine->GetAttributeBool(FIELD_HP))
Cols.AppendString(FIELD_HP);
if (pCmdLine->GetAttributeBool(FIELD_HP_BONUS))
Cols.AppendString(FIELD_HP_BONUS);
if (pCmdLine->GetAttributeBool(FIELD_REGEN))
Cols.AppendString(FIELD_REGEN);
if (pCmdLine->GetAttributeBool(FIELD_FIRE_DELAY))
Cols.AppendString(FIELD_FIRE_DELAY);
if (pCmdLine->GetAttributeBool(FIELD_THRUST))
Cols.AppendString(FIELD_THRUST);
if (pCmdLine->GetAttributeBool(FIELD_POWER))
Cols.AppendString(FIELD_POWER);
if (pCmdLine->GetAttributeBool(FIELD_POWER_PER_SHOT))
Cols.AppendString(FIELD_POWER_PER_SHOT);
if (pCmdLine->GetAttributeBool(FIELD_AVERAGE_DAMAGE))
Cols.AppendString(FIELD_AVERAGE_DAMAGE);
if (pCmdLine->GetAttributeBool(FIELD_MAX_SPEED))
Cols.AppendString(FIELD_MAX_SPEED);
// Output the header
//.........这里部分代码省略.........
示例7: GenerateGameStats
void CPlayerGameStats::GenerateGameStats (CGameStats &Stats, CSpaceObject *pPlayerShip, bool bGameOver) const
// GenerateGameStats
//
// Generates a stats for everything we track
{
int j;
CShip *pShip = (pPlayerShip ? pPlayerShip->AsShip() : NULL);
if (pShip == NULL)
return;
CPlayerShipController *pPlayer = (CPlayerShipController *)pShip->GetController();
if (pPlayer == NULL)
return;
CSovereign *pPlayerSovereign = g_pUniverse->FindSovereign(g_PlayerSovereignUNID);
if (pPlayerSovereign == NULL)
return;
// Base stats
Stats.Insert(CONSTLIT("Genome"), strCapitalize(GetGenomeName(pPlayer->GetPlayerGenome())));
Stats.Insert(CONSTLIT("Score"), strFormatInteger(CalcEndGameScore(), -1, FORMAT_THOUSAND_SEPARATOR | FORMAT_UNSIGNED));
Stats.Insert(CONSTLIT("Ship class"), pShip->GetNounPhrase(0));
CTimeSpan Time = GetPlayTime();
if (!Time.IsBlank())
Stats.Insert(CONSTLIT("Time played"), Time.Format(NULL_STR));
#ifdef REAL_TIME
Time = GetGameTime();
if (!Time.IsBlank())
Stats.Insert(CONSTLIT("Time elapsed in game"), Time.Format(NULL_STR));
#endif
// Some combat stats
CString sDestroyed = GetStat(ENEMY_SHIPS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Enemy ships destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(FRIENDLY_SHIPS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Friendly ships destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(ENEMY_STATIONS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Enemy stations destroyed"), sDestroyed, CONSTLIT("combat"));
sDestroyed = GetStat(FRIENDLY_STATIONS_DESTROYED_STAT);
if (!sDestroyed.IsBlank())
Stats.Insert(CONSTLIT("Friendly stations destroyed"), sDestroyed, CONSTLIT("combat"));
// Add stat for every station destroyed
CStatCounterArray CounterArray;
CMapIterator i;
m_StationStats.Reset(i);
while (m_StationStats.HasMore(i))
{
SStationTypeStats *pStats;
DWORD dwUNID = m_StationStats.GetNext(i, &pStats);
CStationType *pType = g_pUniverse->FindStationType(dwUNID);
if (pType == NULL)
continue;
CString sName = pType->GetNounPhrase(0);
CString sSort = strPatternSubst(CONSTLIT("%03d%s"), 100 - pType->GetLevel(), sName);
if (pType->GetSovereign()->IsEnemy(pPlayerSovereign))
CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Enemy stations destroyed"), sSort);
else
CounterArray.Insert(sName, pStats->iDestroyed, CONSTLIT("Friendly stations destroyed"), sSort);
}
CounterArray.GenerateGameStats(Stats);
// Add stat for every ship class destroyed
CounterArray.DeleteAll();
m_ShipStats.Reset(i);
while (m_ShipStats.HasMore(i))
{
SShipClassStats *pStats;
DWORD dwUNID = m_ShipStats.GetNext(i, &pStats);
CShipClass *pClass = g_pUniverse->FindShipClass(dwUNID);
if (pClass == NULL)
continue;
CString sName = pClass->GetNounPhrase(0);
CString sSort = strPatternSubst(CONSTLIT("%09d%s"), 100000000 - pClass->GetScore(), sName);
if (pStats->iEnemyDestroyed > 0)
CounterArray.Insert(sName, pStats->iEnemyDestroyed, CONSTLIT("Enemy ships destroyed"), sSort);
if (pStats->iFriendDestroyed > 0)
CounterArray.Insert(sName, pStats->iFriendDestroyed, CONSTLIT("Friendly ships destroyed"), sSort);
//.........这里部分代码省略.........