Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/alpine_valley.js
Show First 20 Lines • Show All 70 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. | |||||
const max = this.possibleEdges.length; | const 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 All 11 Lines | while (this.possibleEdges.length) | ||||
} | } | ||||
else | else | ||||
this.SetConnectable(true); | this.SetConnectable(true); | ||||
this.possibleEdges.splice(this.index, 1); | this.possibleEdges.splice(this.index, 1); | ||||
} | } | ||||
}; | }; | ||||
const { tPrimary, tForestFloor, tCliff, tSecondary, tHalfSnow, tSnowLimited, tDirt, tRoad, tRoadWild, oPine, | |||||
oBerryBush, oDeer, oRabbit, oStoneLarge, oStoneSmall, oMetalLarge, aGrass, aGrassShort, aRockLarge, | |||||
aRockMedium, aBushMedium, aBushSmall} = (() => { | |||||
Lint: object-curly-spacing A space is required before '}'. Lint: object-curly-spacing: A space is required before '}'. | |||||
if (randBool()) | if (randBool()) | ||||
{ | { | ||||
RandomMapLogger.prototype.printDirectly("Setting late spring biome.\n"); | RandomMapLogger.prototype.printDirectly("Setting late spring biome.\n"); | ||||
var tPrimary = ["alpine_dirt_grass_50"]; | return { | ||||
var tForestFloor = "alpine_forrestfloor"; | "tPrimary": ["alpine_dirt_grass_50"], | ||||
var tCliff = ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"]; | "tForestFloor": "alpine_forrestfloor", | ||||
var tSecondary = "alpine_grass_rocky"; | "tCliff": ["alpine_cliff_a", "alpine_cliff_b", "alpine_cliff_c"], | ||||
var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; | "tSecondary": "alpine_grass_rocky", | ||||
var tSnowLimited = ["alpine_snow_rocky"]; | "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], | ||||
var tDirt = "alpine_dirt"; | "tSnowLimited": ["alpine_snow_rocky"], | ||||
var tRoad = "new_alpine_citytile"; | "tDirt": "alpine_dirt", | ||||
var tRoadWild = "new_alpine_citytile"; | "tRoad": "new_alpine_citytile", | ||||
"tRoadWild": "new_alpine_citytile", | |||||
var oPine = "gaia/tree/pine"; | |||||
var oBerryBush = "gaia/fruit/berry_01"; | "oPine": "gaia/tree/pine", | ||||
var oDeer = "gaia/fauna_deer"; | "oBerryBush": "gaia/fruit/berry_01", | ||||
var oRabbit = "gaia/fauna_rabbit"; | "oDeer": "gaia/fauna_deer", | ||||
var oStoneLarge = "gaia/rock/alpine_large"; | "oRabbit": "gaia/fauna_rabbit", | ||||
var oStoneSmall = "gaia/rock/alpine_small"; | "oStoneLarge": "gaia/rock/alpine_large", | ||||
var oMetalLarge = "gaia/ore/alpine_large"; | "oStoneSmall": "gaia/rock/alpine_small", | ||||
"oMetalLarge": "gaia/ore/alpine_large", | |||||
var aGrass = "actor|props/flora/grass_soft_small_tall.xml"; | |||||
var aGrassShort = "actor|props/flora/grass_soft_large.xml"; | "aGrass": "actor|props/flora/grass_soft_small_tall.xml", | ||||
var aRockLarge = "actor|geology/stone_granite_med.xml"; | "aGrassShort": "actor|props/flora/grass_soft_large.xml", | ||||
var aRockMedium = "actor|geology/stone_granite_med.xml"; | "aRockLarge": "actor|geology/stone_granite_med.xml", | ||||
var aBushMedium = "actor|props/flora/bush_medit_me.xml"; | "aRockMedium": "actor|geology/stone_granite_med.xml", | ||||
var aBushSmall = "actor|props/flora/bush_medit_sm.xml"; | "aBushMedium": "actor|props/flora/bush_medit_me.xml", | ||||
"aBushSmall": "actor|props/flora/bush_medit_sm.xml" | |||||
} | |||||
Lint: semi Missing semicolon. Lint: semi: Missing semicolon. | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
RandomMapLogger.prototype.printDirectly("Setting winter biome.\n"); | RandomMapLogger.prototype.printDirectly("Setting winter biome.\n"); | ||||
var tPrimary = ["alpine_snow_a", "alpine_snow_b"]; | return { | ||||
var tForestFloor = "alpine_forrestfloor_snow"; | "tPrimary": ["alpine_snow_a", "alpine_snow_b"], | ||||
var tCliff = ["alpine_cliff_snow"]; | "tForestFloor": "alpine_forrestfloor_snow", | ||||
var tSecondary = "alpine_grass_snow_50"; | "tCliff": ["alpine_cliff_snow"], | ||||
var tHalfSnow = ["alpine_grass_snow_50", "alpine_dirt_snow"]; | "tSecondary": "alpine_grass_snow_50", | ||||
var tSnowLimited = ["alpine_snow_a", "alpine_snow_b"]; | "tHalfSnow": ["alpine_grass_snow_50", "alpine_dirt_snow"], | ||||
var tDirt = "alpine_dirt"; | "tSnowLimited": ["alpine_snow_a", "alpine_snow_b"], | ||||
var tRoad = "new_alpine_citytile"; | "tDirt": "alpine_dirt", | ||||
var tRoadWild = "new_alpine_citytile"; | "tRoad": "new_alpine_citytile", | ||||
"tRoadWild": "new_alpine_citytile", | |||||
var oPine = "gaia/tree/pine_w"; | |||||
var oBerryBush = "gaia/fruit/berry_01"; | "oPine": "gaia/tree/pine_w", | ||||
var oDeer = "gaia/fauna_deer"; | "oBerryBush": "gaia/fruit/berry_01", | ||||
var oRabbit = "gaia/fauna_rabbit"; | "oDeer": "gaia/fauna_deer", | ||||
var oStoneLarge = "gaia/rock/alpine_large"; | "oRabbit": "gaia/fauna_rabbit", | ||||
var oStoneSmall = "gaia/rock/alpine_small"; | "oStoneLarge": "gaia/rock/alpine_large", | ||||
var oMetalLarge = "gaia/ore/alpine_large"; | "oStoneSmall": "gaia/rock/alpine_small", | ||||
"oMetalLarge": "gaia/ore/alpine_large", | |||||
var aGrass = "actor|props/flora/grass_soft_dry_small_tall.xml"; | |||||
var aGrassShort = "actor|props/flora/grass_soft_dry_large.xml"; | "aGrass": "actor|props/flora/grass_soft_dry_small_tall.xml", | ||||
var aRockLarge = "actor|geology/stone_granite_med.xml"; | "aGrassShort": "actor|props/flora/grass_soft_dry_large.xml", | ||||
var aRockMedium = "actor|geology/stone_granite_med.xml"; | "aRockLarge": "actor|geology/stone_granite_med.xml", | ||||
var aBushMedium = "actor|props/flora/bush_medit_me_dry.xml"; | "aRockMedium": "actor|geology/stone_granite_med.xml", | ||||
var aBushSmall = "actor|props/flora/bush_medit_sm_dry.xml"; | "aBushMedium": "actor|props/flora/bush_medit_me_dry.xml", | ||||
} | "aBushSmall": "actor|props/flora/bush_medit_sm_dry.xml" | ||||
} | |||||
Lint: semi Missing semicolon. Lint: semi: Missing semicolon. | |||||
var heightLand = 3; | } | ||||
var heightOffsetBump = 2; | })(); | ||||
var snowlineHeight = 29; | |||||
var heightMountain = 30; | const heightLand = 3; | ||||
const heightOffsetBump = 2; | |||||
const snowlineHeight = 29; | |||||
const heightMountain = 30; | |||||
const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; | const pForest = [tForestFloor + TERRAIN_SEPARATOR + oPine, tForestFloor]; | ||||
const g_Map = new RandomMap(heightLand, tPrimary); | const g_Map = new RandomMap(heightLand, tPrimary); | ||||
const numPlayers = getNumPlayers(); | const numPlayers = getNumPlayers(); | ||||
const mapCenter = g_Map.getCenter(); | const mapCenter = g_Map.getCenter(); | ||||
const clPlayer = g_Map.createTileClass(); | const clPlayer = g_Map.createTileClass(); | ||||
const clHill = g_Map.createTileClass(); | const clHill = g_Map.createTileClass(); | ||||
const clForest = g_Map.createTileClass(); | const clForest = g_Map.createTileClass(); | ||||
const clDirt = g_Map.createTileClass(); | const clDirt = g_Map.createTileClass(); | ||||
const clRock = g_Map.createTileClass(); | const clRock = g_Map.createTileClass(); | ||||
const clMetal = g_Map.createTileClass(); | const clMetal = g_Map.createTileClass(); | ||||
const clFood = g_Map.createTileClass(); | const clFood = g_Map.createTileClass(); | ||||
const clBaseResource = g_Map.createTileClass(); | const clBaseResource = g_Map.createTileClass(); | ||||
var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); | const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); | ||||
placePlayerBases({ | placePlayerBases({ | ||||
"PlayerPlacement": [playerIDs, playerPosition], | "PlayerPlacement": [playerIDs, playerPosition], | ||||
"PlayerTileClass": clPlayer, | "PlayerTileClass": clPlayer, | ||||
"BaseResourceClass": clBaseResource, | "BaseResourceClass": clBaseResource, | ||||
"CityPatch": { | "CityPatch": { | ||||
"outerTerrain": tRoadWild, | "outerTerrain": tRoadWild, | ||||
"innerTerrain": tRoad | "innerTerrain": tRoad | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
Engine.SetProgress(50); | Engine.SetProgress(50); | ||||
g_Map.log("Creating forests"); | g_Map.log("Creating forests"); | ||||
const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); | const [forestTrees, stragglerTrees] = getTreeCounts(500, 3000, 0.7); | ||||
const types = [ | const types = [ | ||||
[[tForestFloor, tPrimary, pForest], [tForestFloor, pForest]] | [[tForestFloor, tPrimary, pForest], [tForestFloor, pForest]] | ||||
]; | ]; | ||||
var size = forestTrees / (scaleByMapSize(2,8) * numPlayers); | const size = forestTrees / (scaleByMapSize(2,8) * numPlayers); | ||||
Lint: comma-spacing A space is required after ','. Lint: comma-spacing: A space is required after ','. | |||||
const num = Math.floor(size / types.length); | const num = Math.floor(size / types.length); | ||||
for (const type of types) | for (const type of types) | ||||
createAreas( | createAreas( | ||||
new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), | new ClumpPlacer(forestTrees / num, 0.1, 0.1, Infinity), | ||||
[ | [ | ||||
new LayeredPainter(type, [2]), | new LayeredPainter(type, [2]), | ||||
new TileClassPainter(clForest) | new TileClassPainter(clForest) | ||||
Show All 19 Lines | createAreas( | ||||
new ClumpPlacer(size, 0.3, 0.06, 0.5), | new ClumpPlacer(size, 0.3, 0.06, 0.5), | ||||
new TerrainPainter(tSecondary), | new TerrainPainter(tSecondary), | ||||
avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), | avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clPlayer, 12), | ||||
scaleByMapSize(15, 45)); | scaleByMapSize(15, 45)); | ||||
Engine.SetProgress(65); | Engine.SetProgress(65); | ||||
g_Map.log("Creating stone mines"); | g_Map.log("Creating stone mines"); | ||||
var group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock); | let group = new SimpleGroup([new SimpleObject(oStoneSmall, 0, 2, 0, 4, 0, 2 * Math.PI, 1), new SimpleObject(oStoneLarge, 1, 1, 0, 4, 0, 2 * Math.PI, 4)], true, clRock); | ||||
createObjectGroupsDeprecated(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), | avoidClasses(clForest, 1, clPlayer, 20, clRock, 10, clHill, 1), | ||||
scaleByMapSize(4,16), 100 | scaleByMapSize(4,16), 100 | ||||
); | ); | ||||
g_Map.log("Creating small stone mines"); | g_Map.log("Creating small stone mines"); | ||||
group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); | group = new SimpleGroup([new SimpleObject(oStoneSmall, 2,5, 1,3)], true, clRock); | ||||
createObjectGroupsDeprecated(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
createStragglerTrees( | createStragglerTrees( | ||||
[oPine], | [oPine], | ||||
avoidClasses(clForest, 1, clHill, 1, clPlayer, 12, clMetal, 6, clRock, 6), | avoidClasses(clForest, 1, clHill, 1, clPlayer, 12, clMetal, 6, clRock, 6), | ||||
clForest, | clForest, | ||||
stragglerTrees); | stragglerTrees); | ||||
g_Map.log("Creating small grass tufts"); | g_Map.log("Creating small grass tufts"); | ||||
var planetm = 1; | const planetm = 1; | ||||
group = new SimpleGroup( | group = new SimpleGroup( | ||||
[new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] | [new SimpleObject(aGrassShort, 1,2, 0,1, -Math.PI / 8, Math.PI / 8)] | ||||
); | ); | ||||
createObjectGroupsDeprecated(group, 0, | createObjectGroupsDeprecated(group, 0, | ||||
avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), | avoidClasses(clHill, 2, clPlayer, 2, clDirt, 0), | ||||
planetm * scaleByMapSize(13, 200) | planetm * scaleByMapSize(13, 200) | ||||
); | ); | ||||
Show All 28 Lines |
Wildfire Games · Phabricator
'numPlayers' was used before it was defined.