diff --git a/TODO.txt b/TODO.txt index 4e96dbb8c..f3f087398 100644 --- a/TODO.txt +++ b/TODO.txt @@ -166,11 +166,11 @@ * single player mode DONE 10/12/2024 * single player select map DONE 10/12/2024 * implement private game DONE 10/15/2024 +* private game can select map DONE 10/16/2024 +* Test on android DONE 10/17/2024 +* NPC has relations * private game shows how many players joined -* private game can select map -* BUG: memory leak: game not deleted when leaving game * optimize sendBoat function -* Test on android * NPC more likely to accept alliance fewer alliance player has * better NPC relation logic * surface NPC relations diff --git a/resources/maps/WorldMap.json b/resources/maps/WorldMap.json index 58aa2cb92..517cf09f2 100644 --- a/resources/maps/WorldMap.json +++ b/resources/maps/WorldMap.json @@ -97,7 +97,7 @@ 186 ], "name": "England", - "strength": 1 + "strength": 3 }, { "coordinates": [ @@ -129,7 +129,7 @@ 220 ], "name": "France", - "strength": 1 + "strength": 2 }, { "coordinates": [ diff --git a/src/client/graphics/layers/Leaderboard.ts b/src/client/graphics/layers/Leaderboard.ts index 4115e8ea5..238fb5baf 100644 --- a/src/client/graphics/layers/Leaderboard.ts +++ b/src/client/graphics/layers/Leaderboard.ts @@ -7,7 +7,7 @@ import {ClientID} from '../../../core/Schemas'; interface Entry { name: string position: number - score: number + score: string isMyPlayer: boolean } @@ -49,7 +49,7 @@ export class Leaderboard extends LitElement implements Layer { .map((player, index) => ({ name: player.name(), position: index + 1, - score: player.numTilesOwned(), + score: formatPercentage(player.numTilesOwned() / this.game.numLandTiles()), isMyPlayer: player == myPlayer })); @@ -66,7 +66,7 @@ export class Leaderboard extends LitElement implements Layer { this.players.push({ name: myPlayer.name(), position: place, - score: myPlayer.numTilesOwned(), + score: formatPercentage(myPlayer.numTilesOwned() / this.game.numLandTiles()), isMyPlayer: true, }) } @@ -91,7 +91,7 @@ export class Leaderboard extends LitElement implements Layer { left: 10px; z-index: 9999; background-color: rgba(30, 30, 30, 0.7); /* Added transparency */ - padding: 15px; + padding: 10px; box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); border-radius: 10px; max-width: 300px; @@ -116,10 +116,10 @@ export class Leaderboard extends LitElement implements Layer { } .myPlayer { font-weight: bold; - font-size: 1.4em; + font-size: 1.5em; } .otherPlayer { - font-size: 1.2em; + font-size: 1.3em; } tr:nth-child(even) { background-color: rgba(44, 44, 44, 0.5); /* Made alternating rows slightly transparent */ @@ -150,7 +150,7 @@ export class Leaderboard extends LitElement implements Layer { Rank Player - Score + Owned @@ -181,4 +181,15 @@ export class Leaderboard extends LitElement implements Layer { get isVisible() { return !this._hidden; } +} + +function formatPercentage(value: number): string { + const perc = value * 100 + if (perc < .01) { + return "0%" + } + if (perc < .1) { + return (perc).toPrecision(1) + '%' + } + return perc.toPrecision(2) + '%'; } \ No newline at end of file diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index c7b4b16e0..553be1d89 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -77,14 +77,6 @@ export class DefaultConfig implements Config { // speed = mag if (attacker.isPlayer() && defender.isPlayer()) { - if (attacker.type() == PlayerType.Bot && defender.type() == PlayerType.Human) { - mag *= 1.2 - } - if (attacker.type() == PlayerType.Bot && defender.type() == PlayerType.FakeHuman) { - mag *= 1.5 - } - - if (attacker.type() == PlayerType.Human && defender.type() == PlayerType.Bot) { mag *= .8 } @@ -101,7 +93,7 @@ export class DefaultConfig implements Config { } } else { return { - attackerTroopLoss: mag / 2, + attackerTroopLoss: attacker.type() == PlayerType.Bot ? mag / 10 : mag / 5, defenderTroopLoss: 0, tilesPerTickUsed: within(this.startTroops(attacker.info()) / (attackTroops * 5), .2, 3) * Math.max(10, speed / 1.5) } @@ -133,14 +125,18 @@ export class DefaultConfig implements Config { return 10000 } if (playerInfo.playerType == PlayerType.FakeHuman) { - return 10000 + return 25000 } - return 10000 + return 25000 } maxTroops(player: Player): number { let max = Math.sqrt(player.numTilesOwned()) * 3000 + 50000 - return Math.min(max, 2_000_000) + const troops = Math.min(max, 2_000_000) + if (player.type() == PlayerType.Bot) { + return troops + } + return troops * 2 } troopAdditionRate(player: Player): number { @@ -150,6 +146,7 @@ export class DefaultConfig implements Config { const ratio = 1 - (player.troops() / max) toAdd *= ratio + toAdd *= .5 // console.log(`to add ${toAdd}`) if (player.type() == PlayerType.FakeHuman) { diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 5b5af3de4..3a6cdf8c6 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -19,7 +19,7 @@ export class FakeHumanExecution implements Execution { private rejected: Set = new Set private isTraitor = false - + private relations = new Map() constructor(private playerInfo: PlayerInfo, private cell: Cell, private strength: number) { this.random = new PseudoRandom(simpleHash(playerInfo.id)) @@ -131,10 +131,8 @@ export class FakeHumanExecution implements Execution { handleAllianceRequests() { for (const req of this.player.incomingAllianceRequests()) { - if (this.rejected.has(req.requestor())) { - continue - } - if (req.requestor().numTilesOwned() > this.player.numTilesOwned() * 2) { + + if (req.requestor().numTilesOwned() > this.player.numTilesOwned() * 2) { req.accept() continue }