use europe map

This commit is contained in:
evanpelle
2024-10-09 10:51:56 -07:00
parent 149d38c907
commit bb8827c8ad
7 changed files with 222 additions and 8 deletions
+11 -3
View File
@@ -36,9 +36,14 @@ export class FakeHumanExecution implements Execution {
if (this.mg.inSpawnPhase()) {
if (ticks % this.random.nextInt(5, 30) == 0) {
const rl = this.randomLand()
if (rl == null) {
console.warn(`cannot spawn ${this.playerInfo.name}`)
return
}
this.mg.addExecution(new SpawnExecution(
this.playerInfo,
this.randomLand().cell()
rl.cell()
))
}
return
@@ -195,9 +200,11 @@ export class FakeHumanExecution implements Execution {
this.sendBoat(tries + 1, oceanShore)
}
randomLand(): Tile {
randomLand(): Tile | null {
const delta = 25
while (true) {
let tries = 0
while (tries < 50) {
tries++
const cell = new Cell(
this.random.nextInt(this.cell.x - delta, this.cell.x + delta),
this.random.nextInt(this.cell.y - delta, this.cell.y + delta)
@@ -213,6 +220,7 @@ export class FakeHumanExecution implements Execution {
return tile
}
}
return null
}
sendAttack(toAttack: Player | TerraNullius) {
+2 -2
View File
@@ -1,6 +1,6 @@
import {Cell, TerrainType} from './Game';
import binAsString from "!!binary-loader!../../../resources/maps/WorldMap.bin";
import worldMapInfo from "../../../resources/maps/WorldMap.json"
import binAsString from "!!binary-loader!../../../resources/maps/Europe.bin";
import worldMapInfo from "../../../resources/maps/Europe.json"
export interface NationMap {
name: string;
+3 -3
View File
@@ -8,7 +8,7 @@ import {fileURLToPath} from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const mapName = "Europe"
interface Coord {
x: number;
@@ -44,7 +44,7 @@ export class Terrain {
}
export async function loadTerrainMap(): Promise<void> {
const imagePath = path.resolve(__dirname, '..', '..', 'resources', 'maps', 'WorldMap.png');
const imagePath = path.resolve(__dirname, '..', '..', 'resources', 'maps', mapName + '.png');
const readStream = createReadStream(imagePath);
const img = await PImage.decodePNGFromStream(readStream);
@@ -92,7 +92,7 @@ export async function loadTerrainMap(): Promise<void> {
processDistToLand(shorelineWaters, terrain)
processOcean(terrain)
const packed = packTerrain(terrain)
const outputPath = path.join(__dirname, '..', '..', 'resources', 'maps', 'WorldMap.bin');
const outputPath = path.join(__dirname, '..', '..', 'resources', 'maps', mapName + '.bin');
fs.writeFile(outputPath, packed);
}