Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/common-api/gamestate.js
Show All 29 Lines | m.GameState.prototype.init = function(SharedScript, state, player) | ||||
let cctemplate = this.getTemplate(this.applyCiv("structures/{civ}_civil_centre")); | let cctemplate = this.getTemplate(this.applyCiv("structures/{civ}_civil_centre")); | ||||
if (!cctemplate) | if (!cctemplate) | ||||
return; | return; | ||||
let civ = this.getPlayerCiv(); | let civ = this.getPlayerCiv(); | ||||
let techs = cctemplate.researchableTechs(this, civ); | let techs = cctemplate.researchableTechs(this, civ); | ||||
let phaseData = {}; | let phaseData = {}; | ||||
let phaseMap = {}; | let phaseMap = {}; | ||||
for (let techName of techs) | for (let techName of techs) | ||||
{ | { | ||||
if (!techName.startsWith("phase")) | if (!techName.startsWith("phase")) | ||||
continue; | continue; | ||||
let techData = this.getTemplate(techName); | let techData = this.getTemplate(techName); | ||||
if (techData._definesPair) | if (techData._definesPair) | ||||
{ | { | ||||
// Randomly pick a non-disabled choice from the phase-pair. | // TODO: let ai decide at runtime which one wants | ||||
bb: `let the ai decide at runtime which one it wants`
Not sure if this is possible even, the ai… | |||||
SilierAuthorUnsubmitted Done Inline Actionsone possible solution could be to do random pick for next phase pair once last phase is researched, and only last choice would be serialized instead every pick what would be necessary if done here. Silier: one possible solution could be to do random pick for next phase pair once last phase is… | |||||
techName = pickRandom([techData._template.top, techData._template.bottom].filter(tech => !this.playerData.disabledTechnologies[tech])) || techData._template.top; | // Cannot call pickrandom because this function is called on rejoin and that causes oos (reverting rP20750) | ||||
techName = this.playerData.disabledTechnologies[techData._template.bottom] ? techData._template.top : techData._template.bottom; | |||||
bbUnsubmitted Not Done Inline ActionsWould also bug in the old system: what if all techs are disabled? bb: Would also bug in the old system: what if all techs are disabled? | |||||
SilierAuthorUnsubmitted Done Inline Actionsthen whole function has a problem Silier: then whole function has a problem | |||||
SilierAuthorUnsubmitted Done Inline Actionsalso L28 Silier: also L28
`// we assume all of them are researchable from the civil center` | |||||
let supersedes = techData._template.supersedes; | let supersedes = techData._template.supersedes; | ||||
techData = clone(this.getTemplate(techName)); | techData = clone(this.getTemplate(techName)); | ||||
if (supersedes) | if (supersedes) | ||||
techData._template.supersedes = supersedes; | techData._template.supersedes = supersedes; | ||||
} | } | ||||
phaseData[techName] = GetTechnologyBasicDataHelper(techData._template, civ); | phaseData[techName] = GetTechnologyBasicDataHelper(techData._template, civ); | ||||
▲ Show 20 Lines • Show All 882 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
let the ai decide at runtime which one it wants
Not sure if this is possible even, the ai might make plans and stuff. Any way we can know here whether we will be serializing after?