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
+12 -16
View File
@@ -1165,23 +1165,19 @@ export class PlayerImpl implements Player {
);
});
// Make close ports twice more likely by putting them again
for (
let i = 0;
i < this.mg.config().proximityBonusPortsNb(ports.length);
i++
) {
ports.push(ports[i]);
const weightedPorts: Unit[] = [];
for (const [i, otherPort] of ports.entries()) {
const expanded = new Array(otherPort.level()).fill(otherPort);
weightedPorts.push(...expanded);
if (i < this.mg.config().proximityBonusPortsNb(ports.length)) {
weightedPorts.push(...expanded);
}
if (port.owner().isFriendly(otherPort.owner())) {
weightedPorts.push(...expanded);
}
}
// Make ally ports twice more likely by putting them again
this.mg
.players()
.filter((p) => p !== port.owner() && p.canTrade(port.owner()))
.filter((p) => p.isAlliedWith(port.owner()))
.flatMap((p) => p.units(UnitType.Port))
.forEach((p) => ports.push(p));
return ports;
return weightedPorts;
}
}