Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/queueplanBuilding.js
var PETRA = function(m) | (function(m) | ||||
{ | { | ||||
/** | /** | ||||
* Defines a construction plan, ie a building. | * Defines a construction plan, ie a building. | ||||
* We'll try to fing a good position if non has been provided | * We'll try to fing a good position if non has been provided | ||||
*/ | */ | ||||
m.ConstructionPlan = function(gameState, type, metadata, position) | m.ConstructionPlan = function(gameState, type, metadata, position) | ||||
▲ Show 20 Lines • Show All 729 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
/** | /** | ||||
* fast check if we can build a dock: returns false if nearest land is farther than the dock dimension | * fast check if we can build a dock: returns false if nearest land is farther than the dock dimension | ||||
* if the (object) wantedLand is given, this nearest land should have one of these accessibility | * if the (object) wantedLand is given, this nearest land should have one of these accessibility | ||||
* if wantedSea is given, this tile should be inside this sea | * if wantedSea is given, this tile should be inside this sea | ||||
*/ | */ | ||||
const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50], | const around = [[ 1.0, 0.0], [ 0.87, 0.50], [ 0.50, 0.87], [ 0.0, 1.0], [-0.50, 0.87], [-0.87, 0.50], | ||||
[-1.0, 0.0], [-0.87,-0.50], [-0.50,-0.87], [ 0.0,-1.0], [ 0.50,-0.87], [ 0.87,-0.50]]; | [-1.0, 0.0], [-0.87, -0.50], [-0.50, -0.87], [ 0.0, -1.0], [ 0.50, -0.87], [ 0.87, -0.50]]; | ||||
m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea) | m.ConstructionPlan.prototype.isDockLocation = function(gameState, j, dimension, wantedLand, wantedSea) | ||||
{ | { | ||||
let width = gameState.ai.HQ.territoryMap.width; | let width = gameState.ai.HQ.territoryMap.width; | ||||
let cellSize = gameState.ai.HQ.territoryMap.cellSize; | let cellSize = gameState.ai.HQ.territoryMap.cellSize; | ||||
let dimLand = dimension + 1.5 * cellSize; | let dimLand = dimension + 1.5 * cellSize; | ||||
let dimSea = dimension + 2 * cellSize; | let dimSea = dimension + 2 * cellSize; | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
for (let key in data) | for (let key in data) | ||||
this[key] = data[key]; | this[key] = data[key]; | ||||
this.cost = new API3.Resources(); | this.cost = new API3.Resources(); | ||||
this.cost.Deserialize(data.cost); | this.cost.Deserialize(data.cost); | ||||
}; | }; | ||||
return m; | }(PETRA)); | ||||
}(PETRA); |
Wildfire Games · Phabricator