@@ -201,19 +201,30 @@ function loadGrid(app, viewport, settings) {
201
201
let moisture = moistureMap ( settings ) ;
202
202
203
203
let biomeTileset = {
204
- "DeepWater" : { x : 4 , y :5 } ,
205
- "ShallowWater" : { x : 0 , y :5 } ,
206
- "FlatDesert" :{ x : 1 , y :1 } ,
207
- "FlatGrass" :{ x : 2 , y :0 } ,
208
- "FlatForest" :{ x : 5 , y :0 } ,
209
- "HillDesert" :{ x : 8 , y :0 } ,
210
- "HillGrass" :{ x : 7 , y :0 } ,
211
- "HillForest" :{ x : 6 , y :0 } ,
212
- "HillForestNeedleleaf" :{ x : 10 , y :0 } ,
213
- "MountainDesert" :{ x : 10 , y :6 } ,
214
- "MountainShrubland" :{ x : 3 , y :3 } ,
215
- "MountainAlpine" :{ x : 10 , y :3 } ,
216
- "MountainImpassable" :{ x : 0 , y :6 } ,
204
+ "DeepWater" : { x :4 , y :5 } ,
205
+ "ShallowWater" : { x :0 , y :5 } ,
206
+ "FlatDesert1" : { x :1 , y :2 } ,
207
+ "FlatDesert2" : { x :1 , y :1 } ,
208
+ "FlatGrass" : { x :2 , y :0 } ,
209
+ "FlatSparseTrees1" : { x :3 , y :0 } ,
210
+ "FlatSparseTrees2" : { x :4 , y :0 } ,
211
+ "FlatForest" : { x :5 , y :0 } ,
212
+ "HillDesert" : { x :9 , y :2 } ,
213
+ "HillGrass" : { x :7 , y :0 } ,
214
+ "HillForest" : { x :6 , y :0 } ,
215
+ "HillForestNeedleleaf" : { x :10 , y :0 } ,
216
+ "MountainDesert" : { x :8 , y :2 } ,
217
+ "MountainShrubland1" : { x :8 , y :0 } ,
218
+ "MountainShrubland2" : { x :9 , y :0 } ,
219
+ "MountainAlpine1" : { x :10 , y :0 } ,
220
+ "MountainAlpine2" : { x :11 , y :0 } ,
221
+ "MountainImpassable1" : { x :10 , y :6 } ,
222
+ "MountainImpassable2" : { x :0 , y :6 } ,
223
+ "lake1" : { x :12 , y :0 } ,
224
+ "lake2" : { x :3 , y :1 } ,
225
+ "lake3" : { x :2 , y :1 } ,
226
+ "lake4" : { x :8 , y :1 } ,
227
+ "Volcano" : { x :3 , y :6 } ,
217
228
} ;
218
229
219
230
// render hex grid
@@ -234,56 +245,88 @@ function loadGrid(app, viewport, settings) {
234
245
}
235
246
else if ( hex . elevation < settings . contourInterval_2 ) {
236
247
hex . archetype = "Flat" ;
237
- if ( hex . moisture < 0.16 ) {
248
+ if ( hex . moisture < 0.10 ) {
238
249
hex . biome = "Desert" ;
239
- hex . tile = "FlatDesert" ;
240
- } else if ( hex . moisture < 0.6 ) {
250
+ hex . tile = "FlatDesert1" ;
251
+ } else if ( hex . moisture < 0.25 ) {
252
+ hex . biome = "Desert" ;
253
+ hex . tile = "FlatDesert2" ;
254
+ } else if ( hex . moisture < 0.40 ) {
241
255
hex . biome = "Grass" ;
242
256
hex . tile = "FlatGrass" ;
257
+ } else if ( hex . moisture < 0.65 ) {
258
+ hex . biome = "Grass" ;
259
+ hex . tile = ( Math . floor ( Math . random ( ) * 10 ) + 1 ) === 1 ? "FlatSparseTrees2" : "FlatSparseTrees1" ;
243
260
} else {
244
261
hex . biome = "Forest" ;
245
262
hex . tile = "FlatForest" ;
246
263
}
247
264
}
248
265
else if ( hex . elevation < settings . contourInterval_3 ) {
249
266
hex . archetype = "Hill" ;
250
- if ( hex . moisture < 0.16 ) {
267
+ if ( hex . moisture < 0.10 ) {
251
268
hex . biome = "Desert" ;
252
269
hex . tile = "HillDesert" ;
253
270
}
254
- else if ( hex . moisture < 0.50 ) {
271
+ else if ( hex . moisture < 0.45 ) {
255
272
hex . biome = "Grass" ;
256
273
hex . tile = "HillGrass" ;
257
274
}
258
- else if ( hex . moisture < 0.80 ) {
275
+ else {
259
276
hex . biome = "Mixed Forest" ;
260
277
hex . tile = "HillForest" ;
261
278
}
262
- else {
263
- hex . biome = "Needleleaf Forest" ;
264
- hex . tile = "HillForestNeedleleaf" ;
265
- }
266
279
}
267
280
else if ( hex . elevation < settings . contourInterval_4 ) {
268
281
hex . archetype = "Mountain" ;
269
- if ( hex . moisture < 0.33 ) {
282
+ if ( hex . moisture < 0.10 ) {
270
283
hex . biome = "Desert" ;
271
284
hex . tile = "MountainDesert" ;
272
285
}
273
- else if ( hex . moisture < 0.66 ) {
286
+ else if ( hex . moisture < 0.30 ) {
274
287
hex . biome = "Shrubland" ;
275
- hex . tile = "MountainShrubland ";
288
+ hex . tile = ( Math . floor ( Math . random ( ) * 2 ) + 1 ) === 2 ? "MountainShrubland2" : "MountainShrubland1 ";
276
289
}
277
- else {
290
+ else if ( hex . moisture < 0.80 ) {
278
291
hex . biome = "Alpine forest" ;
279
- hex . tile = "MountainAlpine" ;
292
+ hex . tile = ( Math . floor ( Math . random ( ) * 2 ) + 1 ) === 2 ? "MountainAlpine2" : "MountainAlpine1" ;
293
+ }
294
+ else {
295
+ hex . biome = "Shrubland" ;
296
+ hex . tile = ( Math . floor ( Math . random ( ) * 2 ) + 1 ) === 2 ? "MountainShrubland2" : "MountainShrubland1" ;
280
297
}
281
298
}
282
299
else {
283
300
hex . archetype = "Mountain impassable" ;
284
301
hex . biome = "Snow" ;
285
- hex . tile = "MountainImpassable" ;
302
+ if ( hex . moisture < 0.40 ) {
303
+ hex . tile = ( Math . floor ( Math . random ( ) * 50 ) + 1 ) === 10 ? "Volcano" : "MountainImpassable1" ;
304
+ } else {
305
+ hex . tile = "MountainImpassable2" ;
306
+ }
307
+ }
308
+ } ) ;
309
+
310
+ gr . forEach ( hex => {
311
+ if ( hex . tile === "ShallowWater" ) {
312
+ let hexesInRange = gr . neighborsOf ( hex ) ;
313
+ let terrainSorrounded = true ;
314
+ let counter = 0 ;
315
+ for ( let i = 0 ; i < hexesInRange . length ; i ++ ) {
316
+ let hexToCheck = hexesInRange [ i ] ;
317
+ if ( hexToCheck === undefined || hexToCheck . tile === 'DeepWater' ) {
318
+ terrainSorrounded = false ;
319
+ break ;
320
+ } else if ( hexToCheck !== undefined && hexToCheck . tile === 'ShallowWater' ) {
321
+ counter ++ ;
322
+ }
323
+ }
324
+ if ( terrainSorrounded && counter < 2 ) {
325
+ if ( counter === 0 ) hex . tile = ( Math . floor ( Math . random ( ) * 2 ) + 1 ) === 2 ? "lake2" : "lake1" ;
326
+ else if ( counter === 1 ) hex . tile = ( Math . floor ( Math . random ( ) * 2 ) + 1 ) === 2 ? "lake4" : "lake3" ;
327
+ }
286
328
}
329
+
287
330
} ) ;
288
331
289
332
for ( let y = 0 ; y < settings . hexRows ; y ++ ) {
0 commit comments