void CvGameTextMgr::setUnitHelp(CvWStringBuffer &szBuffer, UnitTypes eUnit, bool bCivilopediaText, bool bStrategyText, bool bTechChooserText, CvCity* pCity)
{
PROFILE_FUNC();
CvWString szTempBuffer;
PlayerTypes ePlayer;
bool bFirst;
int iProduction;
int iI;
if (NO_UNIT == eUnit)
{
return;
}
if (pCity != NULL)
{
ePlayer = pCity->getOwnerINLINE();
}
else
{
ePlayer = GC.getGameINLINE().getActivePlayer();
}
if (!bCivilopediaText)
{
szTempBuffer.Format(SETCOLR L"%s" ENDCOLR , TEXT_COLOR("COLOR_UNIT_TEXT"), GC.getUnitInfo(eUnit).getDescription());
szBuffer.append(szTempBuffer);
if (GC.getUnitInfo(eUnit).getUnitCombatType() != NO_UNITCOMBAT)
{
szTempBuffer.Format(L" (%s)", GC.getUnitCombatInfo((UnitCombatTypes) GC.getUnitInfo(eUnit).getUnitCombatType()).getDescription());
szBuffer.append(szTempBuffer);
}
}
// test for unique unit
UnitClassTypes eUnitClass = (UnitClassTypes)GC.getUnitInfo(eUnit).getUnitClassType();
UnitTypes eDefaultUnit = (UnitTypes)GC.getUnitClassInfo(eUnitClass).getDefaultUnitIndex();
if (NO_UNIT != eDefaultUnit && eDefaultUnit != eUnit)
{
for (iI = 0; iI < GC.getNumCivilizationInfos(); ++iI)
{
UnitTypes eUniqueUnit = (UnitTypes)GC.getCivilizationInfo((CivilizationTypes)iI).getCivilizationUnits((int)eUnitClass);
if (eUniqueUnit == eUnit)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIQUE_UNIT", GC.getCivilizationInfo((CivilizationTypes)iI).getTextKeyWide()));
}
}
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_REPLACES_UNIT", GC.getUnitInfo(eDefaultUnit).getTextKeyWide()));
}
if (isWorldUnitClass(eUnitClass))
{
if (pCity == NULL)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_WORLD_UNIT_ALLOWED", GC.getUnitClassInfo(eUnitClass).getMaxGlobalInstances()));
}
else
{
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_WORLD_UNIT_LEFT", (GC.getUnitClassInfo(eUnitClass).getMaxGlobalInstances() - (ePlayer != NO_PLAYER ? GC.getGameINLINE().getUnitClassCreatedCount(eUnitClass) + GET_TEAM(GET_PLAYER(ePlayer).getTeam()).getUnitClassMaking(eUnitClass) : 0))));
}
}
if (isTeamUnitClass(eUnitClass))
{
if (pCity == NULL)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_TEAM_UNIT_ALLOWED", GC.getUnitClassInfo(eUnitClass).getMaxTeamInstances()));
}
else
{
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_TEAM_UNIT_LEFT", (GC.getUnitClassInfo(eUnitClass).getMaxTeamInstances() - (ePlayer != NO_PLAYER ? GET_TEAM(GET_PLAYER(ePlayer).getTeam()).getUnitClassCountPlusMaking(eUnitClass) : 0))));
}
}
if (isNationalUnitClass(eUnitClass))
{
if (pCity == NULL)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_NATIONAL_UNIT_ALLOWED", GC.getUnitClassInfo(eUnitClass).getMaxPlayerInstances()));
}
else
{
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_NATIONAL_UNIT_LEFT", (GC.getUnitClassInfo(eUnitClass).getMaxPlayerInstances() - (ePlayer != NO_PLAYER ? GET_PLAYER(ePlayer).getUnitClassCountPlusMaking(eUnitClass) : 0))));
}
}
if (0 != GC.getUnitClassInfo(eUnitClass).getInstanceCostModifier())
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_INSTANCE_COST_MOD", GC.getUnitClassInfo(eUnitClass).getInstanceCostModifier()));
}
setBasicUnitHelp(szBuffer, eUnit, bCivilopediaText);
if ((pCity == NULL) || !(pCity->canTrain(eUnit)))
{
if (pCity != NULL)
{
if (GC.getGameINLINE().isNoNukes())
{
if (GC.getUnitInfo(eUnit).getNukeRange() != -1)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_NO_NUKES"));
}
}
}
if (GC.getUnitInfo(eUnit).getHolyCity() != NO_RELIGION)
{
if ((pCity == NULL) || !(pCity->isHolyCity((ReligionTypes)(GC.getUnitInfo(eUnit).getHolyCity()))))
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_REQUIRES_HOLY_CITY", GC.getReligionInfo((ReligionTypes)(GC.getUnitInfo(eUnit).getHolyCity())).getChar()));
}
}
bFirst = true;
if (GC.getUnitInfo(eUnit).getSpecialUnitType() != NO_SPECIALUNIT)
{
if ((pCity == NULL) || !(GC.getGameINLINE().isSpecialUnitValid((SpecialUnitTypes)(GC.getUnitInfo(eUnit).getSpecialUnitType()))))
{
for (iI = 0; iI < GC.getNumProjectInfos(); ++iI)
{
if (GC.getProjectInfo((ProjectTypes)iI).getEveryoneSpecialUnit() == GC.getUnitInfo(eUnit).getSpecialUnitType())
{
szTempBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_REQUIRES").c_str());
CvWString szProject;
szProject.Format(L"<link=literal>%s</link>", GC.getProjectInfo((ProjectTypes)iI).getDescription());
setListHelp(szBuffer, szTempBuffer, szProject, gDLL->getText("TXT_KEY_OR").c_str(), bFirst);
bFirst = false;
}
}
}
}
if (!bFirst)
{
szBuffer.append(ENDCOLR);
}
bFirst = true;
if (GC.getUnitInfo(eUnit).getNukeRange() != -1)
{
if (NULL == pCity || !GC.getGameINLINE().isNukesValid())
{
for (iI = 0; iI < GC.getNumProjectInfos(); ++iI)
{
if (GC.getProjectInfo((ProjectTypes)iI).isAllowsNukes())
{
szTempBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_REQUIRES").c_str());
CvWString szProject;
szProject.Format(L"<link=literal>%s</link>", GC.getProjectInfo((ProjectTypes)iI).getDescription());
setListHelp(szBuffer, szTempBuffer, szProject, gDLL->getText("TXT_KEY_OR").c_str(), bFirst);
bFirst = false;
}
}
for (iI = 0; iI < GC.getNumBuildingInfos(); ++iI)
{
if (GC.getBuildingInfo((BuildingTypes)iI).isAllowsNukes())
{
szTempBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_REQUIRES").c_str());
CvWString szBuilding;
szBuilding.Format(L"<link=literal>%s</link>", GC.getBuildingInfo((BuildingTypes)iI).getDescription());
setListHelp(szBuffer, szTempBuffer, szBuilding, gDLL->getText("TXT_KEY_OR").c_str(), bFirst);
bFirst = false;
}
}
}
}
if (!bFirst)
{
szBuffer.append(ENDCOLR);
}
/*************************************************************************************************/
/** Afforess Vicinity Bonus Start 07/29/09 */
/** */
/** */
/*************************************************************************************************/
if (GC.getUnitInfo(eUnit).getPrereqVicinityBonus() != NO_BONUS)
{
if ((pCity == NULL) || !(pCity->canTrain(eUnit)))
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_REQUIRES_VICINITY_BONUS", GC.getBonusInfo((BonusTypes)(GC.getUnitInfo(eUnit).getPrereqVicinityBonus())).getTextKeyWide()));
}
}
bFirst = true;
for (iI = 0; iI < GC.getNUM_UNIT_PREREQ_OR_BONUSES(); ++iI)
{
if (GC.getUnitInfo(eUnit).getPrereqOrVicinityBonuses(iI) != NO_BONUS)
{
if ((pCity == NULL) || !(pCity->canTrain(eUnit)))
{
szTempBuffer.Format(L"%s%s", NEWLINE, gDLL->getText("TXT_KEY_REQUIRES_IN_CITY_VICINITY").c_str());
setListHelp(szBuffer, szTempBuffer, GC.getBonusInfo((BonusTypes) GC.getUnitInfo(eUnit).getPrereqOrVicinityBonuses(iI)).getDescription(), gDLL->getText("TXT_KEY_OR").c_str(), bFirst);
bFirst = false;
}
}
}
if (!bFirst)
{
szBuffer.append(ENDCOLR);
}
/*************************************************************************************************/
/** Afforess Vicinity Bonus End END */
/*************************************************************************************************/
if (!bCivilopediaText)
{
if (GC.getUnitInfo(eUnit).getPrereqBuilding() != NO_BUILDING)
{
if ((pCity == NULL) || (pCity->getNumBuilding((BuildingTypes)(GC.getUnitInfo(eUnit).getPrereqBuilding())) <= 0))
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_REQUIRES_STRING", GC.getBuildingInfo((BuildingTypes)(GC.getUnitInfo(eUnit).getPrereqBuilding())).getTextKeyWide()));
}
}
//Afforess Start
BuildingTypes eRequiredBuilding = NO_BUILDING;
if (!pCity)
{
if (GC.getGameINLINE().getActivePlayer() != NO_PLAYER)
{
// show unique building for active player
eRequiredBuilding = (BuildingTypes)GC.getCivilizationInfo(GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCivilizationType()).getCivilizationBuildings(iI);
szBuffer.append(NEWLINE L"Unique Building for Active Player");
}
else
{
// show default building
eRequiredBuilding = (BuildingTypes)GC.getBuildingClassInfo((BuildingClassTypes)iI).getDefaultBuildingIndex();
szBuffer.append(NEWLINE L"Default Building");
}
}
else
{
// show unique building for city's owner if city doesn't have any
eRequiredBuilding = (BuildingTypes)GC.getCivilizationInfo(pCity->getCivilizationType()).getCivilizationBuildings(iI);
if (pCity->getNumActiveBuilding(eRequiredBuilding) > 0)
{
eRequiredBuilding = NO_BUILDING;
szBuffer.append(NEWLINE L"City Has Unique Building");
}
else
{
szBuffer.append(NEWLINE L"Unique Building for City");
}
}
if (eRequiredBuilding != NO_BUILDING)
{
szBuffer.append(NEWLINE);
szBuffer.append(gDLL->getText("TXT_KEY_UNIT_REQUIRES_STRING", GC.getBuildingInfo(eRequiredBuilding).getTextKeyWide()));
}
//Afforess END
...}
}