Skip to content

Commit 36e4759

Browse files
author
JM
committed
river tiles ...
1 parent e07c240 commit 36e4759

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

resources/js/source.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ function getDefaultSettings() {
147147
hexSize: 16,
148148
hexOrientation: 'flat',
149149
//hexColums: colums, // x
150-
hexColums: 20, // x
150+
hexColums: 10, // x
151151
//hexRows: rows, // y
152-
hexRows: 20, // y
152+
hexRows: 10, // y
153153
lineThickness: 1,
154154
lineColor: 0x999999,
155155
hideCoords: true,
@@ -416,7 +416,7 @@ function loadGrid(app, viewport, settings) {
416416
counter++;
417417
}
418418
}
419-
if (terrainSorrounded && counter < 2 ) {
419+
if (terrainSorrounded && counter < 1 ) {
420420
if (counter === 0) hex.tile = lookup() <= 50 ? "lake2": "lake1";
421421
else if (counter === 1) hex.tile = lookup() <= 50 ? "lake4": "lake3";
422422
}
@@ -491,7 +491,7 @@ function loadGrid(app, viewport, settings) {
491491
let riverSources = [];
492492
gr.forEach(hex => {
493493
if (hex.biome === "Water" || hex.tile === "Volcano" || hex.archetype === "Flat") return;
494-
if (hex.moisture < 0.70 && hex.archetype !== "Mountain impassable" && hex.biome !== 'Alpine forest') return;
494+
if (hex.moisture < 0.60 && hex.archetype !== "Mountain impassable" && hex.biome !== 'Alpine forest') return;
495495

496496
hex.source = false;
497497
if (hex.archetype === "Hill" && lookup() <= 6) {
@@ -557,7 +557,13 @@ function loadGrid(app, viewport, settings) {
557557
for (let i = 0; i < hexesInRange.length; i++) {
558558
let hexToCheck = hexesInRange[i];
559559

560-
if (typeof hexToCheck === 'undefined') {
560+
if (typeof hexToCheck !== 'undefined' && (hexToCheck.tile === "ShallowWater" || hexToCheck.tile === "DeepWater" || hexToCheck.tile.includes('lake'))) {
561+
hex.sideRiverExit = i;
562+
hex.riverEnd = true;
563+
hexDestination = null;
564+
hex.river = null;
565+
break;
566+
} else if (typeof hexToCheck === 'undefined') {
561567
hex.sideRiverExit = i;
562568
hex.riverEnd = true;
563569
hexDestination = null;
@@ -573,8 +579,8 @@ function loadGrid(app, viewport, settings) {
573579
//No go north or south impassable
574580
if (i === 4 && biomeTileset[hex.tile].z === 5) continue;
575581
if (i === 1 && biomeTileset[hexToCheck.tile].z === 5 && biomeTileset[hex.tile].z === 5) continue;
576-
if (hexToCheck.x === settings.hexColums ) continue;
577-
if (hexToCheck.y === settings.hexRows ) continue;
582+
if (hexToCheck.x === settings.hexColums - 1 && hex.source === true) continue;
583+
if (hexToCheck.y === settings.hexRows - 1 && hex.source === true) continue;
578584

579585
if (!hexDestination) {
580586
hexDestination = hexToCheck;
@@ -583,7 +589,7 @@ function loadGrid(app, viewport, settings) {
583589
else if (biomeTileset[hexToCheck.tile].z < biomeTileset[hexDestination.tile].z) {
584590
hexDestination = hexToCheck;
585591
}
586-
// For the same archetype choose more moisture
592+
// The source runs to the most moisture hex.
587593
else if (hex.source === true && biomeTileset[hexToCheck.tile].z === biomeTileset[hexDestination.tile].z && hexToCheck.moisture > hexDestination.moisture) {
588594
hexDestination = hexToCheck;
589595
} else if (hex.source !== true && biomeTileset[hexToCheck.tile].z === biomeTileset[hexDestination.tile].z && hexToCheck.elevation < hexDestination.elevation) {
@@ -597,6 +603,7 @@ function loadGrid(app, viewport, settings) {
597603
hexDestination.sourceSon = true;
598604
}
599605

606+
/*
600607
if (biomeTileset[hex.tile].z < biomeTileset[hexDestination.tile].z) {
601608
// Dibujamos lago
602609
hex.redrawAsLake = true;
@@ -617,16 +624,33 @@ function loadGrid(app, viewport, settings) {
617624
} else {
618625
hexDestination.riverId = hex.riverId;
619626
}
627+
}*/
628+
629+
let indexHex = hexesInRange.indexOf(hexDestination);
630+
hex.sideRiverExit = indexHex;
631+
hexDestination.sideRiverEnter = indexHex > 2 ? indexHex - 3 : indexHex + 3;
632+
if (hexDestination.tile === "ShallowWater" || hexDestination.tile === "DeepWater" || hexDestination.tile.includes('lake') && hexDestination.archetype !== 'flat') {
633+
hexDestination.riverEnd = true;
634+
} else if (hexDestination.tile.includes('lake') && hexDestination.archetype === 'flat') {
635+
//nada
636+
} else if (hexDestination.riverId && hex.riverId !== hexDestination.riverId) {
637+
// Si es un source, hay que dibujar tambien el hexagono del source --> hexDestination.
638+
hex.riverEnd = true;
639+
hex.riverJoin = true;
640+
// Hay que dibujar una conexión entre ríos
641+
} else {
642+
hexDestination.riverId = hex.riverId;
620643
}
644+
621645
}
622646

623647
if (hex.riverJoin === true) {
624-
console.log('dibujarmos conexion')
648+
console.log('dibujamos conexion')
625649
console.log(hex);
626650
drawRiverTile(hex);
627651
return;
628652
} else if (hex.redrawAsLake && !hex.sourceSon) {
629-
console.log('dibujarmos lago')
653+
console.log('dibujamos lago')
630654
console.log(hex);
631655
drawLakeTile(hex);
632656
return;

0 commit comments

Comments
 (0)