Remove this.events from AIs

`this.events` is only valid during one turn. When it is used in the next
turnn it might be outdated. So it makes no sense to keep it alive untill
the next turn.
This commit is contained in:
phosit
2025-09-07 14:53:56 +02:00
parent cbce748b8c
commit babe9e5c18
2 changed files with 3 additions and 4 deletions
@@ -49,7 +49,6 @@ BaseAI.prototype.CustomInit = function()
BaseAI.prototype.HandleMessage = function(state, playerID, sharedAI)
{
PlayerID = playerID;
this.events = sharedAI.events;
this.territoryMap = sharedAI.territoryMap;
if (this.isDeserialized)
@@ -92,14 +92,14 @@ PetraBot.prototype.OnUpdate = function(sharedScript)
if (this.gameFinished || this.gameState.playerData.state == "defeated")
return;
for (const i in this.events)
for (const i in sharedScript.events)
{
if (i == "AIMetadata") // not used inside petra
continue;
if (this.savedEvents[i] !== undefined)
this.savedEvents[i] = this.savedEvents[i].concat(this.events[i]);
this.savedEvents[i] = this.savedEvents[i].concat(sharedScript.events[i]);
else
this.savedEvents[i] = this.events[i];
this.savedEvents[i] = sharedScript.events[i];
}
// Run the update every n turns, offset depending on player ID to balance the load