Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/queueManager.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
// This takes the input queues and picks which items to fund with resources until no more resources are left to distribute. | // This takes the input queues and picks which items to fund with resources until no more resources are left to distribute. | ||||
// | // | ||||
// Currently this manager keeps accounts for each queue, split between the 4 main resources | // Currently this manager keeps accounts for each queue, split between the 4 main resources | ||||
// | // | ||||
// Each time resources are available (ie not in any account), it is split between the different queues | // Each time resources are available (ie not in any account), it is split between the different queues | ||||
// Mostly based on priority of the queue, and existing needs. | // Mostly based on priority of the queue, and existing needs. | ||||
▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | for (let q in data.queues) | ||||
this.queues[q].Deserialize(gameState, data.queues[q]); | this.queues[q].Deserialize(gameState, data.queues[q]); | ||||
this.accounts[q] = new API3.Resources(); | this.accounts[q] = new API3.Resources(); | ||||
this.accounts[q].Deserialize(data.accounts[q]); | this.accounts[q].Deserialize(data.accounts[q]); | ||||
this.queueArrays.push([q, this.queues[q]]); | this.queueArrays.push([q, this.queues[q]]); | ||||
} | } | ||||
this.queueArrays.sort((a, b) => data.priorities[b[0]] - data.priorities[a[0]]); | this.queueArrays.sort((a, b) => data.priorities[b[0]] - data.priorities[a[0]]); | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator