Have port destination likelihood scale with level (#1473)

## Description:

Having a high level port would increase the number of outgoing
tradeships, but not the number of incoming tradeships. Now the the
chances of a tradeship landing on a port is scaled with the port's level

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [x] I have read and accepted the CLA aggreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
This commit is contained in:
evanpelle
2025-07-17 19:21:27 -07:00
committed by GitHub
parent ad642bc0ab
commit a221fee921
2 changed files with 34 additions and 17 deletions
+22 -1
View File
@@ -9,6 +9,7 @@ import { setup } from "./util/Setup";
let game: Game;
let player: Player;
let other: Player;
describe("PlayerImpl", () => {
beforeEach(async () => {
@@ -17,7 +18,10 @@ describe("PlayerImpl", () => {
{
instantBuild: true,
},
[new PlayerInfo("player", PlayerType.Human, null, "player_id")],
[
new PlayerInfo("player", PlayerType.Human, null, "player_id"),
new PlayerInfo("other", PlayerType.Human, null, "other_id"),
],
);
while (game.inSpawnPhase()) {
@@ -26,6 +30,7 @@ describe("PlayerImpl", () => {
player = game.player("player_id");
player.addGold(BigInt(1000000));
other = game.player("other_id");
game.config().structureMinDist = () => 10;
});
@@ -77,4 +82,20 @@ describe("PlayerImpl", () => {
);
expect(cityToUpgrade).toBe(false);
});
test("Destination ports chances scale with level", () => {
game.config().proximityBonusPortsNb = () => 0;
player.conquer(game.ref(10, 10));
const playerPort = player.buildUnit(UnitType.Port, game.ref(10, 10), {});
other.conquer(game.ref(0, 0));
const otherPort = other.buildUnit(UnitType.Port, game.ref(0, 0), {});
otherPort.increaseLevel();
otherPort.increaseLevel();
const ports = player.tradingPorts(playerPort);
expect(ports.length).toBe(3);
});
});