// ***************************************************************************
static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
{
	if(args.size()!=1)
	{
		nlwarning("<getOutpostBuildingDesc> requires 1 arg (int=sheet)");
		return false;
	}

	// get arg
	uint32	nSheet = (uint32)args[0].getInteger();
	if (nSheet == 0)
	{
		result.setUCString(string(""));
		return true;
	}

	// get sheet name
	ucstring name;
	CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
	COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
	if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
	{
		// Don't display description if the building is an empty slot
		name = "";
	}
	else
	{
		STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
		name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet));
	}


	result.setUCString(name);

	return true;
}
Ejemplo n.º 2
0
// ***************************************************************************
void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather)
{
	H_AUTO(CDBGroupListSheetTrade_updateViewText);
	ucstring text;
	Ctrl->getContextHelp(text);
	// Append first the type of the sheet to select
	switch ( Ctrl->getSheetCategory() )
	{
		case CDBCtrlSheet::Item:		break;		// none for item. consider useless
		case CDBCtrlSheet::Pact:		text= CI18N::get("uiBotChatPact") + text; break;
		case CDBCtrlSheet::Skill:		text= CI18N::get("uiBotChatSkill") + text; break;
		case CDBCtrlSheet::GuildFlag:	text= CI18N::get("uiBotChatSkill") + text; break;
		case CDBCtrlSheet::Phrase:		text= CI18N::get("uiBotChatPhrase") + text; break;
		default: break;
	}

	// For outpost building get description from string manager
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_OutpostBuilding)
	{
		const COutpostBuildingSheet *pOBS = Ctrl->asOutpostBuildingSheet();
		if (pOBS != NULL)
		{
			STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
			text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()));
			text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper));
			text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
			if ((pOBS->CostTime % 60) != 0)
				text += toString(pOBS->CostTime%60) + CI18N::get("uiBotChatTimeSecond");
		}
	}

	// For Phrase, if combat, add Weapon compatibility
	if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase)
	{
		// For combat action, Append weapon restriction
		ucstring	weaponRestriction;
		CSPhraseManager	*pPM= CSPhraseManager::getInstance();
		bool melee,range;
		pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range);
		// don't add also if no combat restriction
		if(!weaponRestriction.empty() && weaponRestriction!=CI18N::get("uiawrSF"))
		{
			weaponRestriction= CI18N::get("uiPhraseWRHeader") + weaponRestriction;
			text+= "\n" + weaponRestriction;
		}
	}

	// Get the Text color
	ucstring colorTag("@{FFFF}");
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
	{
		if(!Ctrl->checkItemRequirement())
			colorTag= CI18N::get("uiItemCannotUseColor");
	}

	// For item, add some information
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
	{
		const CItemSheet *pIS = Ctrl->asItemSheet();
		if(pIS)
		{
			// Add craft info for MP
			if(pIS->Family==ITEMFAMILY::RAW_MATERIAL)
			{
				ucstring	ipList;
				pIS->getItemPartListAsText(ipList);
				if(ipList.empty())
				{
					if(pIS->isUsedAsCraftRequirement())
						text+= "\n" + CI18N::get("uiItemMpCraftRequirement");
					else
						text+= "\n" + CI18N::get("uiItemMpNoCraft");
				}
				else
					text+= "\n" + CI18N::get("uiItemMpCanCraft") + ipList;
			}
		}
	}

	// get the price
	CDBGroupListSheetTrade *zeFather = safe_cast<CDBGroupListSheetTrade*>(pFather);
	if (zeFather->priceWanted())
	{
		if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase)
		{
			if (LastPrice != -1)
				text+= "\n" + CI18N::get("uiBotChatSkillPointCost") + toString(LastPrice);
			else
				text+= "\n" + CI18N::get("uiBotChatSkillPointCostNotReceived");
		}
		else
		{
			bool	guildOption= false;

			// Special case if its a guild option
			if (Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
			{
				const CItemSheet *pIS = Ctrl->asItemSheet();
				if (pIS && pIS->Family == ITEMFAMILY::GUILD_OPTION)
				{
					text+= "\n" + CI18N::get("uiBotChatSkillPointCost") + toString(pIS->GuildOption.XPCost);
					text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pIS->GuildOption.MoneyCost));
					guildOption= true;
				}
			}

			// if not a guild option
			if(!guildOption)
			{
				if (LastPrice != -1)
				{
					const CItemSheet *pIS = Ctrl->asItemSheet();

					uint	factor= 1;
					if(zeFather->getMultiplyPriceByQuantityFlag())
						factor= LastQuantity;

					// factor on price
					float priceFactor = 1.0f;

					// Append std price
					bool	displayMulPrice= pIS && pIS->Stackable>1 && zeFather->getMultiplyPriceByQuantityFlag();
					// If seller type wanted, don't mul price if the item comes from a NPC
					if(zeFather->sellerTypeWanted() && LastSellerType==BOTCHATTYPE::NPC)
						displayMulPrice= false;

					// check if we should apply fame factor
					if( zeFather->applyFamePriceFactor() )
					{
						priceFactor = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR")->getValue16()/10000.0f;
					}

					// display with correct format
					if (LastPrice > 0)
					{
						if(displayMulPrice)
							text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(sint32(LastPrice * priceFactor))) + " ("
								+ NLMISC::formatThousands(toString( sint32(factor) * sint32(LastPrice * priceFactor) )) + ")";
						else
							text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString( sint32(factor * LastPrice * priceFactor) ));
					}

					if ((LastFactionPointPrice != 0) && (LastFactionType >= PVP_CLAN::BeginClans) && (LastFactionType <= PVP_CLAN::EndClans))
					{
						if (LastPrice > 0)
							text += ". ";
						else
							text+= "\n";

						text+= CI18N::get("uiBotChatFactionType") + PVP_CLAN::toString((PVP_CLAN::TPVPClan)LastFactionType)
							+  CI18N::get("uiBotChatFactionPointPrice") + NLMISC::formatThousands(toString(LastFactionPointPrice));
					}

					// some additional info for resale
					if(zeFather->sellerTypeWanted())
					{
						// Append retire price if reseller type OK (only if the item belongs to the player)
						if(LastSellerType == BOTCHATTYPE::User || LastSellerType == BOTCHATTYPE::ResaleAndUser ||
							LastSellerType == BOTCHATTYPE::UserRetirable || LastSellerType == BOTCHATTYPE::ResaleAndUserRetirable )
						{
							// append price
							if(pIS && pIS->Stackable>1 && zeFather->getMultiplyPriceByQuantityFlag())
								text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(LastPriceRetire)) + " ("
									+ NLMISC::formatThousands(toString(factor * LastPriceRetire)) + ")";
							else
								text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire));
							// set resale time left
							ucstring	fmt= CI18N::get("uiBotChatResaleTimeLeft");
							strFindReplace(fmt, "%d", toString(LastResaleTimeLeft/RYZOM_DAY_IN_HOUR));
							strFindReplace(fmt, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR));
							text+= "\n" + fmt;
							// force special color (according if retirable or not)
							if(LastSellerType == BOTCHATTYPE::UserRetirable || LastSellerType == BOTCHATTYPE::ResaleAndUserRetirable)
								colorTag= CI18N::get("uiItemUserSellColor");
							else
								colorTag= CI18N::get("uiItemUserSellColorNotRetirable");
						}

						// Append (NPC) tag if NPC item
						if(LastSellerType == BOTCHATTYPE::NPC)
						{
							text+= "\n" + CI18N::get("uiBotChatNPCTag");
						}
						// else display the name of the vendor (not if this is the player himself, to avoid flood)
						else if (LastSellerType == BOTCHATTYPE::Resale)
						{
							text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString;
						}
					}
				}
				else
				{
					// If comes from User List, -1 means "Already Sold"
					if(zeFather->sellerTypeWanted() &&
						(LastSellerType == BOTCHATTYPE::User || LastSellerType == BOTCHATTYPE::UserRetirable) )
					{
						text+= "\n" + CI18N::get("uiItemSold");
						// force special color
						colorTag= CI18N::get("uiItemSoldColor");
					}
					// error case
					else
					{
						text+= "\n" + CI18N::get("uiPriceNotReceived");
					}
				}
			}
		}
	}

	// setup color and text
	text= colorTag + text;
	Text->setTextFormatTaged(text);
}