Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/tradeManager.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** | /** | ||||
* Manage the trade | * Manage the trade | ||||
*/ | */ | ||||
m.TradeManager = function(Config) | m.TradeManager = function(Config) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | m.TradeManager.prototype.checkRoutes = function(gameState, accessIndex) | ||||
} | } | ||||
let onlyOurs = !market2.hasEntities(); | let onlyOurs = !market2.hasEntities(); | ||||
if (onlyOurs) | if (onlyOurs) | ||||
market2 = market1; | market2 = market1; | ||||
let candidate = { "gain": 0 }; | let candidate = { "gain": 0 }; | ||||
let potential = { "gain": 0 }; | let potential = { "gain": 0 }; | ||||
let bestIndex = { "gain": 0 }; | let bestIndex = { "gain": 0 }; | ||||
let bestLand = { "gain": 0 }; | let bestLand = { "gain": 0 }; | ||||
let mapSize = gameState.sharedScript.mapSize; | let mapSize = gameState.sharedScript.mapSize; | ||||
let traderTemplatesGains = gameState.getTraderTemplatesGains(); | let traderTemplatesGains = gameState.getTraderTemplatesGains(); | ||||
for (let m1 of market1.values()) | for (let m1 of market1.values()) | ||||
{ | { | ||||
if (!m1.position()) | if (!m1.position()) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | m.TradeManager.prototype.Deserialize = function(gameState, data) | ||||
{ | { | ||||
if (key == "tradeRoute" || key == "potentialTradeRoute") | if (key == "tradeRoute" || key == "potentialTradeRoute") | ||||
this[key] = this.routeIdToEnt(gameState, data[key]); | this[key] = this.routeIdToEnt(gameState, data[key]); | ||||
else | else | ||||
this[key] = data[key]; | this[key] = data[key]; | ||||
} | } | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator