mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-22 23:54:02 +00:00
e2f4ce0649
Adds a new component effectively handling negative resource trickles. Prevents resources from going negative and provides an effect for not being able to pay. The effect chosen for 0 A.D. is having the entity not being controllable. Not used in the public mod itself, but it is in quite some mods. Based on an idea of @Nescio Differential revision: D1323 Comments by: @Angen, (@smiley,) @Stan This was SVN commit r25191.
71 lines
1.8 KiB
JavaScript
71 lines
1.8 KiB
JavaScript
/**
|
|
* This class contains code common to the Structure Tree, Template Viewer, and any other "Reference Page" that may be added in the future.
|
|
*/
|
|
class ReferencePage
|
|
{
|
|
constructor()
|
|
{
|
|
this.civData = loadCivData(true, false);
|
|
|
|
this.TemplateLoader = new TemplateLoader();
|
|
this.TemplateLister = new TemplateLister(this.TemplateLoader);
|
|
this.TemplateParser = new TemplateParser(this.TemplateLoader);
|
|
|
|
this.activeCiv = this.TemplateLoader.DefaultCiv;
|
|
|
|
this.currentTemplateLists = {};
|
|
}
|
|
|
|
setActiveCiv(civCode)
|
|
{
|
|
if (civCode == this.TemplateLoader.DefaultCiv)
|
|
return;
|
|
|
|
this.activeCiv = civCode;
|
|
|
|
this.currentTemplateLists = this.TemplateLister.compileTemplateLists(this.activeCiv, this.civData);
|
|
this.TemplateParser.deriveModifications(this.activeCiv);
|
|
this.TemplateParser.derivePhaseList(this.currentTemplateLists.techs.keys(), this.activeCiv);
|
|
}
|
|
|
|
/**
|
|
* Concatanates the return values of the array of passed functions.
|
|
*
|
|
* @param {Object} template
|
|
* @param {array} textFunctions
|
|
* @param {string} joiner
|
|
* @return {string} The built text.
|
|
*/
|
|
static buildText(template, textFunctions=[], joiner="\n")
|
|
{
|
|
return textFunctions.map(func => func(template)).filter(tip => tip).join(joiner);
|
|
}
|
|
}
|
|
|
|
ReferencePage.prototype.IconPath = "session/portraits/";
|
|
|
|
/**
|
|
* List of functions that get the statistics of any template or entity,
|
|
* formatted in such a way as to appear in a tooltip.
|
|
*
|
|
* The functions listed are defined in gui/common/tooltips.js
|
|
*/
|
|
ReferencePage.prototype.StatsFunctions = [
|
|
getResourceDropsiteTooltip,
|
|
getHealthTooltip,
|
|
getAttackTooltip,
|
|
getHealerTooltip,
|
|
getResistanceTooltip,
|
|
getGarrisonTooltip,
|
|
getTurretsTooltip,
|
|
getProjectilesTooltip,
|
|
getSpeedTooltip,
|
|
getGatherTooltip,
|
|
getResourceSupplyTooltip,
|
|
getTreasureTooltip,
|
|
getPopulationBonusTooltip,
|
|
getResourceTrickleTooltip,
|
|
getUpkeepTooltip,
|
|
getLootTooltip
|
|
];
|