Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/alpine_valley.js
Engine.LoadLibrary("rmgen"); | Engine.LoadLibrary("rmgen"); | ||||
Engine.LoadLibrary("rmgen-common"); | Engine.LoadLibrary("rmgen-common"); | ||||
TILE_CENTERED_HEIGHT_MAP = true; | |||||
/** | /** | ||||
* This class creates random mountainranges without enclosing any area completely. | * This class creates random mountainranges without enclosing any area completely. | ||||
* | * | ||||
* To determine their location, a graph is created where each vertex is a possible starting or | * To determine their location, a graph is created where each vertex is a possible starting or | ||||
* ending location of a mountainrange and each edge a possible mountainrange. | * ending location of a mountainrange and each edge a possible mountainrange. | ||||
* | * | ||||
* That graph starts nearly complete (i.e almost every vertex is connected to most other vertices). | * That graph starts nearly complete (i.e almost every vertex is connected to most other vertices). | ||||
* After a random edge was chosen and placed as a mountainrange, | * After a random edge was chosen and placed as a mountainrange, | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | function MountainRangeBuilder(args) | ||||
this.currentEdge = undefined; | this.currentEdge = undefined; | ||||
this.currentEdgeStart = undefined; | this.currentEdgeStart = undefined; | ||||
this.currentEdgeEnd = undefined; | this.currentEdgeEnd = undefined; | ||||
} | } | ||||
MountainRangeBuilder.prototype.InitPossibleEdges = function() | MountainRangeBuilder.prototype.InitPossibleEdges = function() | ||||
{ | { | ||||
for (let i = 0; i < this.vertices.length; ++i) | for (let i = 0; i < this.vertices.length; ++i) | ||||
for (let j = numPlayers; j < this.vertices.length; ++j) | for (let j = numPlayers; j < this.vertices.length; ++j) | ||||
Lint: no-use-before-define: 'numPlayers' was used before it was defined. | |||||
if (j > i) | if (j > i) | ||||
this.possibleEdges.push([i, j]); | this.possibleEdges.push([i, j]); | ||||
}; | }; | ||||
MountainRangeBuilder.prototype.InitConnectable = function() | MountainRangeBuilder.prototype.InitConnectable = function() | ||||
{ | { | ||||
for (let i = 0; i < this.vertices.length; ++i) | for (let i = 0; i < this.vertices.length; ++i) | ||||
{ | { | ||||
this.verticesConnectable[i] = []; | this.verticesConnectable[i] = []; | ||||
for (let j = 0; j < this.vertices.length; ++j) | for (let j = 0; j < this.vertices.length; ++j) | ||||
this.verticesConnectable[i][j] = i >= numPlayers || j >= numPlayers || i == j || i != j - 1 && i != j + 1; | this.verticesConnectable[i][j] = i >= numPlayers || j >= numPlayers || i == j || i != j - 1 && i != j + 1; | ||||
Lint: no-use-before-define 'numPlayers' was used before it was defined. Lint: no-use-before-define: 'numPlayers' was used before it was defined. | |||||
Lint: no-use-before-define 'numPlayers' was used before it was defined. Lint: no-use-before-define: 'numPlayers' was used before it was defined. | |||||
} | } | ||||
}; | }; | ||||
MountainRangeBuilder.prototype.SetConnectable = function(isConnectable) | MountainRangeBuilder.prototype.SetConnectable = function(isConnectable) | ||||
{ | { | ||||
this.verticesConnectable[this.currentEdge[0]][this.currentEdge[1]] = isConnectable; | this.verticesConnectable[this.currentEdge[0]][this.currentEdge[1]] = isConnectable; | ||||
this.verticesConnectable[this.currentEdge[1]][this.currentEdge[0]] = isConnectable; | this.verticesConnectable[this.currentEdge[1]][this.currentEdge[0]] = isConnectable; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | MountainRangeBuilder.prototype.PaintCurrentEdge = function() | ||||
return true; | return true; | ||||
}; | }; | ||||
/** | /** | ||||
* This is the only function meant to be publicly accessible. | * This is the only function meant to be publicly accessible. | ||||
*/ | */ | ||||
MountainRangeBuilder.prototype.CreateMountainRanges = function() | MountainRangeBuilder.prototype.CreateMountainRanges = function() | ||||
{ | { | ||||
g_Map.log("Creating mountainrange with " + this.possibleEdges.length + " possible edges"); | g_Map.log("Creating mountainrange with " + this.possibleEdges.length + " possible edges"); | ||||
Lint: no-use-before-define 'g_Map' was used before it was defined. Lint: no-use-before-define: 'g_Map' was used before it was defined. | |||||
let max = this.possibleEdges.length; | let max = this.possibleEdges.length; | ||||
while (this.possibleEdges.length) | while (this.possibleEdges.length) | ||||
{ | { | ||||
Engine.SetProgress(35 - 15 * this.possibleEdges.length / max); | Engine.SetProgress(35 - 15 * this.possibleEdges.length / max); | ||||
this.index = randIntExclusive(0, this.possibleEdges.length); | this.index = randIntExclusive(0, this.possibleEdges.length); | ||||
▲ Show 20 Lines • Show All 335 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
'numPlayers' was used before it was defined.