Show plant power capacity on the city track during building
This commit is contained in:
parent
55581e0f6d
commit
3e7abbbebc
19 changed files with 109 additions and 25 deletions
|
|
@ -105,6 +105,7 @@
|
|||
:playerColors="playerColors"
|
||||
:paymentTable="G.paymentTable"
|
||||
:poweredCities="poweringCount"
|
||||
:powerCapacity="buildingPowerCapacity"
|
||||
:ownedCities="poweringPlayer ? poweringPlayer.cities.length : undefined"
|
||||
:poweringIncome="poweringIncome"
|
||||
:compact="stacked"
|
||||
|
|
@ -1176,6 +1177,11 @@ export default class Game extends Vue {
|
|||
disablePass: boolean = false;
|
||||
private automaticPoweringRound = '';
|
||||
|
||||
get buildingPowerCapacity() {
|
||||
if (this.G?.phase !== Phase.Building || this.player === undefined) return undefined;
|
||||
return this.G.players[this.player]?.powerPlants.reduce((total, plant) => total + plant.citiesPowered, 0);
|
||||
}
|
||||
|
||||
get poweringPlayer() {
|
||||
return this.G?.phase === Phase.Bureaucracy &&
|
||||
this.player !== undefined &&
|
||||
|
|
|
|||
|
|
@ -10,18 +10,27 @@
|
|||
:transform="`translate(${cellX(count)}, ${cellY(count)})`"
|
||||
>
|
||||
<rect
|
||||
v-if="count === poweredCities"
|
||||
class="powered-city-marker"
|
||||
v-if="count === markerCount"
|
||||
:class="powerCapacity !== undefined ? 'power-capacity-marker' : 'powered-city-marker'"
|
||||
x="11"
|
||||
y="12"
|
||||
width="32"
|
||||
height="64"
|
||||
rx="3"
|
||||
fill="none"
|
||||
stroke="#183b32"
|
||||
:stroke="powerCapacity !== undefined ? '#2e6d96' : '#183b32'"
|
||||
:stroke-opacity="powerCapacity !== undefined ? 0.8 : 1"
|
||||
stroke-width="3"
|
||||
/>
|
||||
<rect v-if="count === poweredCities" x="13" y="57" width="28" height="17" rx="2" fill="#d6ed87" />
|
||||
<rect
|
||||
v-if="count === markerCount"
|
||||
x="13"
|
||||
y="57"
|
||||
width="28"
|
||||
height="17"
|
||||
rx="2"
|
||||
:fill="powerCapacity !== undefined ? '#c8e4f3' : '#d6ed87'"
|
||||
/>
|
||||
<title>
|
||||
{{
|
||||
`Cities supplied: ${count}. Income: $${income} before map penalties. Houses show connected cities.`
|
||||
|
|
@ -54,8 +63,8 @@
|
|||
y="66"
|
||||
text-anchor="middle"
|
||||
style="font-size: 15px; dominant-baseline: central"
|
||||
:fill="count === poweredCities ? '#183b32' : '#fff3cf'"
|
||||
:font-weight="count === poweredCities ? 'bold' : 'normal'"
|
||||
:fill="count === markerCount ? (powerCapacity !== undefined ? '#183b4f' : '#183b32') : '#fff3cf'"
|
||||
:font-weight="count === markerCount ? 'bold' : 'normal'"
|
||||
>
|
||||
{{ income }}
|
||||
</text>
|
||||
|
|
@ -78,10 +87,11 @@
|
|||
<g class="city-income-legend" :transform="`translate(0, ${compact ? 157 : 87})`">
|
||||
<circle cx="21" cy="0" r="7" fill="#365343" />
|
||||
<text x="21" text-anchor="middle" font-size="11" fill="#fff3cf">{{
|
||||
poweredCities !== undefined ? 'ϟ' : '$'
|
||||
poweredCities !== undefined || powerCapacity !== undefined ? 'ϟ' : '$'
|
||||
}}</text>
|
||||
<text x="33" y="0" style="font-size: 13px; dominant-baseline: central" fill="#29432e">
|
||||
<template v-if="poweredCities !== undefined"
|
||||
<template v-if="powerCapacity !== undefined">Power capacity: {{ powerCapacity }} cities</template>
|
||||
<template v-else-if="poweredCities !== undefined"
|
||||
>{{ poweredCities }} / {{ ownedCities }} cities powered · ${{ poweringIncome }}</template
|
||||
>
|
||||
<template v-else>Total income for powered cities</template>
|
||||
|
|
@ -107,7 +117,7 @@ const CELL_BOTTOM = 52;
|
|||
|
||||
@Component({
|
||||
components: {
|
||||
House
|
||||
House,
|
||||
},
|
||||
})
|
||||
export default class CityCount extends Vue {
|
||||
|
|
@ -117,11 +127,18 @@ export default class CityCount extends Vue {
|
|||
@Prop({ required: true }) paymentTable!: number[];
|
||||
@Prop({ default: false }) compact!: boolean;
|
||||
@Prop() poweredCities?: number;
|
||||
@Prop() powerCapacity?: number;
|
||||
@Prop() ownedCities?: number;
|
||||
@Prop() poweringIncome?: number;
|
||||
|
||||
houses: (Piece & { cityCount: number })[] = [];
|
||||
|
||||
get markerCount() {
|
||||
return this.powerCapacity !== undefined
|
||||
? Math.min(this.powerCapacity, this.paymentTable.length - 1)
|
||||
: this.poweredCities;
|
||||
}
|
||||
|
||||
cellX(count: number) {
|
||||
return 33 * (this.compact ? count % 11 : count);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Spring auktion over",
|
||||
"Finish building": "Afslut byggeri",
|
||||
"Finish powering": "Afslut strømproduktion",
|
||||
"Cancel bid edit": "Annuller budændring"
|
||||
"Cancel bid edit": "Annuller budændring",
|
||||
"Power capacity: {count} cities": "Forsyningskapacitet: {count} byer"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Auktion überspringen",
|
||||
"Finish building": "Bauen abschließen",
|
||||
"Finish powering": "Stromerzeugung abschließen",
|
||||
"Cancel bid edit": "Gebotsänderung abbrechen"
|
||||
"Cancel bid edit": "Gebotsänderung abbrechen",
|
||||
"Power capacity: {count} cities": "Versorgungskapazität: {count} Städte"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Παράλειψη δημοπρασίας",
|
||||
"Finish building": "Ολοκλήρωση κατασκευής",
|
||||
"Finish powering": "Ολοκλήρωση ηλεκτροδότησης",
|
||||
"Cancel bid edit": "Ακύρωση αλλαγής προσφοράς"
|
||||
"Cancel bid edit": "Ακύρωση αλλαγής προσφοράς",
|
||||
"Power capacity: {count} cities": "Δυναμικότητα τροφοδοσίας: {count} πόλεις"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Skip auction",
|
||||
"Finish building": "Finish building",
|
||||
"Finish powering": "Finish powering",
|
||||
"Cancel bid edit": "Cancel bid edit"
|
||||
"Cancel bid edit": "Cancel bid edit",
|
||||
"Power capacity: {count} cities": "Power capacity: {count} cities"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "رد کردن مزایده",
|
||||
"Finish building": "پایان ساختوساز",
|
||||
"Finish powering": "پایان تولید برق",
|
||||
"Cancel bid edit": "لغو ویرایش پیشنهاد"
|
||||
"Cancel bid edit": "لغو ویرایش پیشنهاد",
|
||||
"Power capacity: {count} cities": "ظرفیت تأمین برق: {count} شهر"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Passer les enchères",
|
||||
"Finish building": "Terminer la construction",
|
||||
"Finish powering": "Terminer la production",
|
||||
"Cancel bid edit": "Annuler la modification"
|
||||
"Cancel bid edit": "Annuler la modification",
|
||||
"Power capacity: {count} cities": "Capacité électrique : {count} villes"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "नीलामी छोड़ें",
|
||||
"Finish building": "निर्माण पूरा करें",
|
||||
"Finish powering": "बिजली उत्पादन पूरा करें",
|
||||
"Cancel bid edit": "बोली का बदलाव रद्द करें"
|
||||
"Cancel bid edit": "बोली का बदलाव रद्द करें",
|
||||
"Power capacity: {count} cities": "बिजली क्षमता: {count} शहर"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Salta asta",
|
||||
"Finish building": "Termina costruzione",
|
||||
"Finish powering": "Termina produzione",
|
||||
"Cancel bid edit": "Annulla modifica offerta"
|
||||
"Cancel bid edit": "Annulla modifica offerta",
|
||||
"Power capacity: {count} cities": "Capacità di alimentazione: {count} città"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "경매 건너뛰기",
|
||||
"Finish building": "건설 완료",
|
||||
"Finish powering": "발전 완료",
|
||||
"Cancel bid edit": "입찰 수정 취소"
|
||||
"Cancel bid edit": "입찰 수정 취소",
|
||||
"Power capacity: {count} cities": "전력 공급 용량: 도시 {count}개"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Veiling overslaan",
|
||||
"Finish building": "Bouwen afronden",
|
||||
"Finish powering": "Stroomproductie afronden",
|
||||
"Cancel bid edit": "Bodwijziging annuleren"
|
||||
"Cancel bid edit": "Bodwijziging annuleren",
|
||||
"Power capacity: {count} cities": "Stroomcapaciteit: {count} steden"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Pomiń aukcję",
|
||||
"Finish building": "Zakończ budowę",
|
||||
"Finish powering": "Zakończ produkcję energii",
|
||||
"Cancel bid edit": "Anuluj zmianę oferty"
|
||||
"Cancel bid edit": "Anuluj zmianę oferty",
|
||||
"Power capacity: {count} cities": "Moc elektrowni: {count} miast"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Pular leilão",
|
||||
"Finish building": "Concluir construção",
|
||||
"Finish powering": "Concluir geração",
|
||||
"Cancel bid edit": "Cancelar edição do lance"
|
||||
"Cancel bid edit": "Cancelar edição do lance",
|
||||
"Power capacity: {count} cities": "Capacidade de energia: {count} cidades"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Sari peste licitație",
|
||||
"Finish building": "Încheie construcția",
|
||||
"Finish powering": "Încheie producția",
|
||||
"Cancel bid edit": "Anulează modificarea ofertei"
|
||||
"Cancel bid edit": "Anulează modificarea ofertei",
|
||||
"Power capacity: {count} cities": "Capacitate de alimentare: {count} orașe"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Пропустить аукцион",
|
||||
"Finish building": "Завершить строительство",
|
||||
"Finish powering": "Завершить выработку",
|
||||
"Cancel bid edit": "Отменить изменение ставки"
|
||||
"Cancel bid edit": "Отменить изменение ставки",
|
||||
"Power capacity: {count} cities": "Мощность: {count} городов"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "Bỏ qua đấu giá",
|
||||
"Finish building": "Hoàn tất xây dựng",
|
||||
"Finish powering": "Hoàn tất phát điện",
|
||||
"Cancel bid edit": "Hủy sửa giá đấu"
|
||||
"Cancel bid edit": "Hủy sửa giá đấu",
|
||||
"Power capacity: {count} cities": "Công suất cấp điện: {count} thành phố"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2005,5 +2005,6 @@
|
|||
"Skip auction": "跳過拍賣",
|
||||
"Finish building": "完成建設",
|
||||
"Finish powering": "完成發電",
|
||||
"Cancel bid edit": "取消修改出價"
|
||||
"Cancel bid edit": "取消修改出價",
|
||||
"Power capacity: {count} cities": "供電容量:{count} 座城市"
|
||||
}
|
||||
|
|
|
|||
45
viewer/tests/unit/building-capacity.spec.ts
Normal file
45
viewer/tests/unit/building-capacity.spec.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import { expect } from 'chai';
|
||||
import { Phase } from 'powergrid-engine';
|
||||
import Game from '@/components/Game.vue';
|
||||
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', () => {
|
||||
const G = {
|
||||
phase: Phase.Building,
|
||||
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: undefined })).to.equal(undefined);
|
||||
expect(capacity({ G, player: -1 })).to.equal(undefined);
|
||||
expect(capacity({ G: { ...G, phase: Phase.Bureaucracy }, player: 0 })).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('marks capacity, caps the track position, and restores the powering marker', async () => {
|
||||
const wrapper = mount(CityCount, {
|
||||
propsData: { paymentTable: Array.from({ length: 22 }, (_, i) => i * 10), powerCapacity: 12 },
|
||||
stubs: ['House'],
|
||||
});
|
||||
expect(wrapper.find('.city-income-legend').text()).to.contain('Power capacity: 12 cities');
|
||||
expect(wrapper.find('.power-capacity-marker').element.parentElement!.getAttribute('transform')).to.equal(
|
||||
'translate(396, 0)'
|
||||
);
|
||||
await wrapper.setProps({ powerCapacity: 30, compact: true });
|
||||
expect(wrapper.find('.power-capacity-marker').element.parentElement!.getAttribute('transform')).to.equal(
|
||||
'translate(330, 70)'
|
||||
);
|
||||
expect(wrapper.find('.city-income-legend').text()).to.contain('Power capacity: 30 cities');
|
||||
await wrapper.setProps({ powerCapacity: undefined, poweredCities: 8, ownedCities: 10, poweringIncome: 90 });
|
||||
expect(wrapper.find('.power-capacity-marker').exists()).to.equal(false);
|
||||
expect(wrapper.find('.powered-city-marker').exists()).to.equal(true);
|
||||
expect(wrapper.find('.city-income-legend').text()).to.contain('8 / 10 cities powered');
|
||||
wrapper.destroy();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue