From a3156bd50c04ac13e1b3e83a93c52b8b8ee0a77a Mon Sep 17 00:00:00 2001 From: evanpelle Date: Fri, 30 Aug 2024 11:27:10 -0700 Subject: [PATCH] max number of boats --- TODO.txt | 6 +++++- src/core/configuration/Config.ts | 1 + src/core/configuration/DefaultConfig.ts | 3 +++ src/core/execution/BoatAttackExecution.ts | 9 ++++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index bbcbb01d7..c6fe27c79 100644 --- a/TODO.txt +++ b/TODO.txt @@ -58,13 +58,17 @@ * REFACTOR: remove player config DONE 8/29/2024 * give boats limit for how far they can go DONE 8/29/2024 * boats can go around the world DONE 8/29/2024 +* max boats (3)? * PERF: more efficient spawns * PERF: load terrain map async * PERF: enable CDN * enable load balancing metrics * end game when no players left (or after 1 hour or so?) -* Add terrain elevation to map +* if completely surrended, lose piece of land * use better favicon +* BUG: tiles get left behind during conquer +* Add terrain elevation to map * REFACTOR: give terranullius an ID, game.player() returns terranullius * REFACTOR: ocean is considered TerraNullius ? +* Create exit to menu button * Make fake humans diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index f3579bc78..fad0d8a0b 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -33,6 +33,7 @@ export interface Config { attackAmount(attacker: Player, defender: Player | TerraNullius): number boatAttackAmount(attacker: Player, defender: Player | TerraNullius): number boatMaxDistance(): number + boatMaxNumber(): number } export interface Theme { diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 585258e12..8c76aa96a 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -6,6 +6,9 @@ import {pastelTheme} from "./PastelTheme"; export class DefaultConfig implements Config { + boatMaxNumber(): number { + return 3 + } boatMaxDistance(): number { return 500 } diff --git a/src/core/execution/BoatAttackExecution.ts b/src/core/execution/BoatAttackExecution.ts index 75cfe50f6..c75cdaf92 100644 --- a/src/core/execution/BoatAttackExecution.ts +++ b/src/core/execution/BoatAttackExecution.ts @@ -44,9 +44,16 @@ export class BoatAttackExecution implements Execution { init(mg: MutableGame, ticks: number) { this.lastMove = ticks - this.mg = mg + this.attacker = mg.player(this.attackerID) + + if (this.attacker.boats().length >= mg.config().boatMaxNumber()) { + console.log('too many boats') + this.active = false + return + } + if (this.targetID == null) { this.target = mg.terraNullius() } else {