Show building capacity only on the viewing player turn

This commit is contained in:
coyotte508 2026-10-06 16:20:47 +02:00
commit ca9882a5c9
2 changed files with 8 additions and 3 deletions

View file

@ -1178,7 +1178,8 @@ export default class Game extends Vue {
private automaticPoweringRound = '';
get buildingPowerCapacity() {
if (this.G?.phase !== Phase.Building || this.player === undefined) return undefined;
if (this.G?.phase !== Phase.Building || this.player === undefined || !this.G.currentPlayers.includes(this.player))
return undefined;
return this.G.players[this.player]?.powerPlants.reduce((total, plant) => total + plant.citiesPowered, 0);
}

View file

@ -7,16 +7,20 @@ import CityCount from '@/components/boards/CityCount.vue';
const capacity = (context: any) => (Game as any).options.computed.buildingPowerCapacity.get.call(context);
describe('building power capacity', () => {
it('shows the viewing player’s total plant output only during building', () => {
it('shows the viewing player’s total plant output only on their building turn', () => {
const G = {
phase: Phase.Building,
currentPlayers: [0],
players: [
{ powerPlants: [{ citiesPowered: 2 }, { citiesPowered: 4 }, { citiesPowered: 6 }] },
{ powerPlants: [{ citiesPowered: 3 }] },
],
};
expect(capacity({ G, player: 0 })).to.equal(12);
expect(capacity({ G, player: 1 })).to.equal(3);
expect(capacity({ G, player: 1 })).to.equal(undefined);
expect(capacity({ G: { ...G, currentPlayers: [1] }, player: 1 })).to.equal(3);
expect(capacity({ G: { ...G, currentPlayers: [1] }, player: 0 })).to.equal(undefined);
expect(capacity({ G: { ...G, currentPlayers: [] }, player: 0 })).to.equal(undefined);
expect(capacity({ G, player: undefined })).to.equal(undefined);
expect(capacity({ G, player: -1 })).to.equal(undefined);
expect(capacity({ G: { ...G, phase: Phase.Bureaucracy }, player: 0 })).to.equal(undefined);