(Reference Suite) Support aura-based civilization bonuses

As a side effect of 6b7a80b260, this is now trivial to do.

We don't (currently) have any aura-based civ bonuses in Vanilla 0A.D.,
but hopefully modders will find it useful.

This was SVN commit r25690.
This commit is contained in:
s0600204 2021-06-05 16:39:59 +00:00
parent 6b7a80b260
commit 3bb5f364c2
2 changed files with 15 additions and 6 deletions

View File

@ -8,13 +8,18 @@ class BonusesSubsection extends Subsection
update(civCode, civInfo)
{
// Not all civ bonuses can be represented by a single auto-researched technology (e.g.
// Athenian "Silver Owls", Roman "Testudo Formation"). Thus we also display descriptions
// of civ bonuses as written in the {civ}.json files.
const player = this.page.TemplateParser.getPlayer(civCode);
// Civilization bonuses can be represented by a single auto-researched technology...
let civBonuses = this.getTechnologyCaptions(
this.page.TemplateLoader.autoResearchTechList,
civCode
);
// ...or as a globally applied aura...
Array.prototype.push.apply(civBonuses, this.getAuraCaptions(player.civbonuses));
// ...however some fit into neither of the two above categories (e.g. Athenian "Silver
// Owls", Roman "Testudo Formation"). Thus we also display descriptions of civ bonuses
// as written in the {civ}.json files.
for (let bonus of civInfo.CivBonuses)
civBonuses.push(this.page.formatEntry(
bonus.Name,
@ -29,7 +34,7 @@ class BonusesSubsection extends Subsection
);
let teamBonuses = this.getAuraCaptions(
this.page.TemplateParser.getPlayer(civCode).teambonuses,
player.teambonuses,
civCode
);
teamBonuses.unshift(

View File

@ -220,13 +220,17 @@ class TemplateParser
let template = this.TemplateLoader.loadPlayerTemplate(civCode);
let parsed = {
"civbonuses": [],
"teambonuses": [],
};
if (template.Auras)
for (let auraTemplateName of template.Auras._string.split(/\s+/))
if (AuraTemplateExists(auraTemplateName) && this.getAura(auraTemplateName).affectsTeam)
parsed.teambonuses.push(auraTemplateName);
if (AuraTemplateExists(auraTemplateName))
if (this.getAura(auraTemplateName).affectsTeam)
parsed.teambonuses.push(auraTemplateName);
else
parsed.civbonuses.push(auraTemplateName);
this.players[civCode] = parsed;
return parsed;