fix(viewer): mark Lantids shared mines without hiding income
This commit is contained in:
parent
296a8a0a38
commit
75590a4af8
24 changed files with 269 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/old-ui",
|
||||
"version": "1.2.23",
|
||||
"version": "1.2.24",
|
||||
"scripts": {
|
||||
"serve": "vite --port 5193",
|
||||
"build": "vite build",
|
||||
|
|
|
|||
4
old-ui/src/components/PlayerBoard/BuildingGroup.spec.ts
Normal file
4
old-ui/src/components/PlayerBoard/BuildingGroup.spec.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import { sharedMineBuildingGroupTests } from "../../../../viewer/src/testing/shared-mine-building-group";
|
||||
import BuildingGroup from "./BuildingGroup.vue";
|
||||
|
||||
sharedMineBuildingGroupTests(BuildingGroup, "g.old-building.old-building-in-group");
|
||||
|
|
@ -50,6 +50,10 @@
|
|||
:count="resource.count"
|
||||
:transform="`translate(${index * 1.5 + isPI * 0.5}, 0) scale(0.08)`"
|
||||
/>
|
||||
<g v-if="isSharedMine(i)" class="shared-mine-mark">
|
||||
<title>Shared mine (cannot be upgraded)</title>
|
||||
<UsedActionMark transform="scale(0.05)" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@gaia-project/viewer",
|
||||
"version": "5.22.23",
|
||||
"version": "5.22.24",
|
||||
"description": "Functions to visualize the map and boards for gaia project inside html canvas",
|
||||
"contributors": [
|
||||
"coyotte508",
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@ import Engine from "@gaia-project/engine";
|
|||
import { render } from "@testing-library/vue";
|
||||
import { expect } from "chai";
|
||||
import { makeStore } from "../../store";
|
||||
import { sharedMineBuildingGroupTests } from "../../testing/shared-mine-building-group";
|
||||
import BuildingGroup from "./BuildingGroup.vue";
|
||||
|
||||
sharedMineBuildingGroupTests(BuildingGroup, "g.building.building-in-group");
|
||||
|
||||
describe("BuildingGroup", () => {
|
||||
it("does not render an available Gaiaformer token for one permanently consumed to colonize an Asteroid (Lost Fleet §E2)", () => {
|
||||
const engine = new Engine(["init 2 building-group-gf-asteroid", "p1 faction terrans", "p2 faction hadsch-hallas"], {
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@
|
|||
gone for good), unlike one placed on Gaia/a transdim/Protoplanet - so mark its board slot
|
||||
with the same "used" X as a power/special action, scaled down to fit this circle. -->
|
||||
<UsedActionMark v-if="isAsteroidConsumed(i)" class="asteroid-consumed-mark" transform="scale(0.05)" />
|
||||
<!-- Shared mines cannot return through an upgrade. Their income is included in the left-hand total. -->
|
||||
<g v-if="isSharedMine(i)" class="shared-mine-mark">
|
||||
<title>Shared mine (cannot be upgraded)</title>
|
||||
<UsedActionMark transform="scale(0.05)" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</template>
|
||||
|
|
@ -73,6 +78,7 @@
|
|||
<script lang="ts">
|
||||
import Engine, {
|
||||
Building as BuildingEnum,
|
||||
Faction,
|
||||
factionBoard,
|
||||
factionVariantBoard,
|
||||
Operator,
|
||||
|
|
@ -174,7 +180,9 @@ export default class BuildingGroup extends Vue {
|
|||
const isolatedCost = b.isolatedCost ? " Isolated cost: " + (b.isolatedCost.join(", ") || "~") : "";
|
||||
const income = building === BuildingEnum.GaiaFormer ? null : this.resources(i, true).join(", ") || "~";
|
||||
const rows = [
|
||||
buildingName(building, this.faction) + (this.isAsteroidConsumed(i) ? " (crashed on an Asteroid)" : ""),
|
||||
this.isSharedMine(i)
|
||||
? "Shared mine (cannot be upgraded)"
|
||||
: buildingName(building, this.faction) + (this.isAsteroidConsumed(i) ? " (crashed on an Asteroid)" : ""),
|
||||
`Cost: ${cost}${isolatedCost}`,
|
||||
income,
|
||||
`Power Value: ${this.player.buildingValue(null, { building })}`,
|
||||
|
|
@ -214,10 +222,21 @@ export default class BuildingGroup extends Vue {
|
|||
|
||||
get factionIncome(): Reward[] {
|
||||
if (this.player.isAutoma) return [];
|
||||
const income: Reward[] = [].concat(
|
||||
let income: Reward[] = [].concat(
|
||||
...this.board.income.filter((ev) => ev.operator === Operator.Income).map((ev) => ev.rewards)
|
||||
);
|
||||
|
||||
if (this.sharedMines > 0) {
|
||||
// Move only the income under the fixed Xs into the left-hand icon. Read the actual track:
|
||||
// the third mine slot is blank, so adding one ore per shared mine would overstate income.
|
||||
for (const i of this.buildingList.filter((slot) => this.isSharedMine(slot))) {
|
||||
for (const event of this.board.buildings[BuildingEnum.Mine].income[i]) {
|
||||
if (event.operator === Operator.Income) income.push(...event.rewards);
|
||||
}
|
||||
}
|
||||
income = Reward.merge(income);
|
||||
}
|
||||
|
||||
return income.filter((rew) => this.resource.includes(rew.type));
|
||||
}
|
||||
|
||||
|
|
@ -235,6 +254,19 @@ export default class BuildingGroup extends Vue {
|
|||
return i >= this.placed + this.gaia + this.asteroidConsumed;
|
||||
}
|
||||
|
||||
get sharedMines(): number {
|
||||
if (this.revealIncome || this.building !== BuildingEnum.Mine || this.faction !== Faction.Lantids) {
|
||||
return 0;
|
||||
}
|
||||
return this.player.data.occupied.filter((hex) => hex.data.additionalMine === this.player.player).length;
|
||||
}
|
||||
|
||||
isSharedMine(i: number): boolean {
|
||||
// Shared mines never return to supply. Anchor them on the left so ordinary builds/upgrades
|
||||
// cannot move their markers. `placed` already includes them: do not consume any extra pieces.
|
||||
return i >= 0 && i < this.sharedMines && i < this.placed;
|
||||
}
|
||||
|
||||
isAsteroidConsumed(i: number): boolean {
|
||||
if (this.building !== BuildingEnum.GaiaFormer) {
|
||||
return false;
|
||||
|
|
@ -297,7 +329,7 @@ export default class BuildingGroup extends Vue {
|
|||
|
||||
resources(i: number, tooltip = false): Array<string | Reward> {
|
||||
if (this.player.isAutoma) return [];
|
||||
if (this.showBuilding(i) && !tooltip) {
|
||||
if (!tooltip && (this.showBuilding(i) || this.isSharedMine(i))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Flere billige, forbundne miner kan være den korrekte åbning, når bredde forbedrer indkomst, scoring, adgang og fremtidige føderationer.",
|
||||
"Share URL": "Del URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Delte handlinger, boostere, skibe, techs, avancerede techs og føderationsbrikker får timingværdi, når en modstander kan tage dem først.",
|
||||
"Shared mine (cannot be upgraded)": "Delt mine (kan ikke opgraderes)",
|
||||
"Ship Action": "Skibshandling",
|
||||
"Ship access and colour differences": "Skibsadgang og farveforskelle",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Skibshandlinger skaber nye måder at ekspandere på. Tjek deres ressourceomkostninger, midlertidige bonusser og eventuelle én-gang-pr-runde-grænser, før du bruger dem.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Mehrere günstige, verbundene Minen können die richtige Eröffnung sein, wenn Breite Einkommen, Wertung, Zugang und zukünftige Föderationen verbessert.",
|
||||
"Share URL": "URL teilen",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Geteilte Aktionen, Booster, Schiffe, Techs, Fortschrittstechs und Föderationsplättchen gewinnen an Timing-Wert, wenn ein Gegner sie zuerst nehmen kann.",
|
||||
"Shared mine (cannot be upgraded)": "Geteilte Mine (kann nicht aufgewertet werden)",
|
||||
"Ship Action": "Schiffsaktion",
|
||||
"Ship access and colour differences": "Schiffszugang und Farbunterschiede",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Schiffsaktionen schaffen neue Wege zur Expansion. Prüfe ihre Ressourcenkosten, temporären Boni und etwaige Einmal-pro-Runde-Limits, bevor du sie nutzt.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Πολλά φθηνά, συνδεδεμένα Ορυχεία μπορεί να είναι το σωστό άνοιγμα όταν το εύρος βελτιώνει το εισόδημα, τη βαθμολόγηση, την πρόσβαση και τις μελλοντικές Ομοσπονδίες.",
|
||||
"Share URL": "Κοινοποίηση URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Οι κοινές ενέργειες, ενισχυτές, διαστημόπλοια, τεχνολογίες, προηγμένες τεχνολογίες και πλακίδια Ομοσπονδίας αποκτούν αξία χρονισμού όταν ένας αντίπαλος μπορεί να τα πάρει πρώτος.",
|
||||
"Shared mine (cannot be upgraded)": "Κοινό ορυχείο (δεν μπορεί να αναβαθμιστεί)",
|
||||
"Ship Action": "Ενέργεια Διαστημόπλοιου",
|
||||
"Ship access and colour differences": "Πρόσβαση διαστημόπλοιου και διαφορές χρώματος",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Οι ενέργειες διαστημόπλοιων δημιουργούν νέους τρόπους επέκτασης. Έλεγξε το κόστος πόρων τους, τα προσωρινά μπόνους και τυχόν όρια μία φορά ανά γύρο πριν τις χρησιμοποιήσεις.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.",
|
||||
"Share URL": "Share URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.",
|
||||
"Shared mine (cannot be upgraded)": "Shared mine (cannot be upgraded)",
|
||||
"Ship Action": "Ship Action",
|
||||
"Ship access and colour differences": "Ship access and colour differences",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "چند معدن کمهزینه و متصل میتوانند شروع درستی باشند، اگر گستردگی درآمد، امتیاز، دسترسی و فدراسیونهای آینده را بهتر کند.",
|
||||
"Share URL": "اشتراکگذاری پیوند",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "عملهای مشترک، تقویتکنندهها، سفینهها، فناوریها و نشانهای فدراسیون وقتی حریف میتواند زودتر بگیردشان، ارزش زمانی پیدا میکنند.",
|
||||
"Shared mine (cannot be upgraded)": "معدن مشترک (قابل ارتقا نیست)",
|
||||
"Ship Action": "عمل سفینه",
|
||||
"Ship access and colour differences": "دسترسی سفینه و تفاوت رنگها",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "عملهای سفینه راههای تازهای برای گسترش میدهند. پیش از استفاده، هزینهٔ منابع، پاداشهای موقت و محدودیت یکبار در هر دور را بررسی کنید.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Plusieurs mines proches et peu coûteuses peuvent constituer une bonne ouverture si elles améliorent vos revenus, vos points, votre accès à la carte et vos futures alliances.",
|
||||
"Share URL": "Partager l'URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "L’ordre de vos actions devient important lorsqu’un adversaire peut prendre avant vous une action commune, un booster, un emplacement de vaisseau, une technologie ou un pion Alliance.",
|
||||
"Shared mine (cannot be upgraded)": "Mine partagée (ne peut pas être améliorée)",
|
||||
"Ship Action": "Action de vaisseau",
|
||||
"Ship access and colour differences": "Accès des vaisseaux et différences de couleur",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Les actions des vaisseaux ouvrent de nouvelles possibilités d’expansion. Vérifiez leur coût, leurs bonus temporaires et leurs limites d’utilisation par manche.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "कई सस्ती, जुड़ी हुई खदानें सही शुरुआत हो सकती हैं जब विस्तार से आय, स्कोरिंग, पहुँच और भविष्य के महासंघ में सुधार होता है।",
|
||||
"Share URL": "URL साझा करें",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "साझा क्रियाएँ, बूस्टर, जहाज, तकनीकें, उन्नत तकनीकें और महासंघ टोकन समय मूल्य प्राप्त करते हैं जब कोई प्रतिद्वंद्वी उन्हें पहले ले सकता है।",
|
||||
"Shared mine (cannot be upgraded)": "साझा खदान (उन्नत नहीं की जा सकती)",
|
||||
"Ship Action": "जहाज क्रिया",
|
||||
"Ship access and colour differences": "जहाज पहुँच और रंग अंतर",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "जहाज क्रियाएँ विस्तार के नए तरीके बनाती हैं। उपयोग से पहले उनकी संसाधन लागत, अस्थायी बोनस और प्रति-राउंड सीमाएँ जाँचें।",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Diverse miniere economiche e collegate possono essere l'apertura corretta quando l'ampiezza migliora reddito, punteggio, accesso e future Federazioni.",
|
||||
"Share URL": "Condividi URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Azioni condivise, booster, navi, tecnologie, tecnologie avanzate e gettoni Federazione acquisiscono valore temporale quando un avversario può prenderli per primo.",
|
||||
"Shared mine (cannot be upgraded)": "Miniera condivisa (non può essere potenziata)",
|
||||
"Ship Action": "Azione Nave",
|
||||
"Ship access and colour differences": "Accesso alle navi e differenze di colore",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Le azioni nave creano nuovi modi di espandersi. Controlla i costi in risorse, i bonus temporanei e gli eventuali limiti una volta per round prima di usarle.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "폭이 수입, 점수, 접근성, 미래 연방을 개선할 때 여러 개의 저렴하고 연결된 광산이 올바른 시작이 될 수 있습니다.",
|
||||
"Share URL": "URL 공유",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "공유 행동, 부스터, 함선, 기술, 고급 기술, 연방 토큰은 상대가 먼저 가져갈 수 있을 때 타이밍 가치를 얻습니다.",
|
||||
"Shared mine (cannot be upgraded)": "공유 광산 (업그레이드 불가)",
|
||||
"Ship Action": "함선 행동",
|
||||
"Ship access and colour differences": "함선 접근성과 색상 차이",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "함선 행동은 새로운 확장 방법을 만듭니다. 사용하기 전에 자원 비용, 일시적 보너스, 라운드당 1회 제한을 확인하세요.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Meerdere goedkope, verbonden mijnen kunnen de juiste opening zijn wanneer breedte inkomen, scoring, toegang en toekomstige federaties verbetert.",
|
||||
"Share URL": "Deel URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Gedeelde acties, boosters, schepen, techs, geavanceerde techs en federatietokens krijgen timingwaarde wanneer een tegenstander ze als eerste kan nemen.",
|
||||
"Shared mine (cannot be upgraded)": "Gedeelde mijn (kan niet worden geüpgraded)",
|
||||
"Ship Action": "Scheepsactie",
|
||||
"Ship access and colour differences": "Scheepstoegang en kleurverschillen",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Scheepsacties creëren nieuwe manieren om uit te breiden. Controleer hun grondstofkosten, tijdelijke bonussen en eventuele eenmaal-per-ronde-limieten voordat je ze gebruikt.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Kilka tanich, połączonych kopalni może być właściwym otwarciem, gdy szerokość poprawia dochód, punktację, dostęp i przyszłe federacje.",
|
||||
"Share URL": "Udostępnij URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Wspólne akcje, wzmacniacze, statki, technologie, zaawansowane technologie i żetony federacji zyskują na wartości czasowej, gdy przeciwnik może je zabrać pierwszy.",
|
||||
"Shared mine (cannot be upgraded)": "Wspólna kopalnia (nie można jej ulepszyć)",
|
||||
"Ship Action": "Akcja statku",
|
||||
"Ship access and colour differences": "Dostęp statków i różnice kolorów",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Akcje statków tworzą nowe sposoby ekspansji. Sprawdź ich koszty zasobów, tymczasowe premie i ewentualne limity raz na rundę przed ich użyciem.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Várias Minas baratas e conectadas podem ser a abertura correta quando a amplitude melhora renda, pontuação, acesso e futuras Federações.",
|
||||
"Share URL": "Compartilhar URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Ações compartilhadas, boosters, naves, tecnologias, tecnologias avançadas e fichas de Federação ganham valor de tempo quando um oponente pode pegá-los primeiro.",
|
||||
"Shared mine (cannot be upgraded)": "Mina compartilhada (não pode ser melhorada)",
|
||||
"Ship Action": "Ação de Nave",
|
||||
"Ship access and colour differences": "Acesso de nave e diferenças de cor",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Ações de nave criam novas formas de expandir. Verifique seus custos de recursos, bônus temporários e limites de uma vez por rodada antes de usá-las.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Câteva mine ieftine, conectate, pot fi deschiderea corectă când lărgimea îmbunătățește venitul, punctajul, accesul și viitoarele Federații.",
|
||||
"Share URL": "Distribuie URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Acțiunile partajate, boosterele, navele, tehnologiile, tehnologiile avansate și jetoanele de Federație câștigă valoare de sincronizare când un adversar le poate lua primul.",
|
||||
"Shared mine (cannot be upgraded)": "Mină partajată (nu poate fi îmbunătățită)",
|
||||
"Ship Action": "Acțiune de Navă",
|
||||
"Ship access and colour differences": "Accesul navei și diferențele de culoare",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Acțiunile de navă creează noi moduri de expansiune. Verifică costurile de resurse, bonusurile temporare și orice limite o dată pe rundă înainte de a le folosi.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Несколько дешёвых соединённых шахт могут быть правильным началом, когда широта улучшает доход, очки, доступ и будущие федерации.",
|
||||
"Share URL": "Поделиться URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Общие действия, бустеры, корабли, технологии, продвинутые технологии и жетоны федераций приобретают ценность тайминга, когда соперник может взять их первым.",
|
||||
"Shared mine (cannot be upgraded)": "Общая шахта (нельзя улучшить)",
|
||||
"Ship Action": "Действие корабля",
|
||||
"Ship access and colour differences": "Доступ кораблей и различия цветов",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Действия кораблей создают новые способы расширения. Проверьте их стоимость в ресурсах, временные бонусы и любые лимиты раз в раунд перед использованием.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "Vài Mỏ rẻ, kết nối với nhau có thể là khai cuộc đúng khi độ rộng cải thiện thu nhập, điểm số, khả năng tiếp cận và các Liên bang tương lai.",
|
||||
"Share URL": "Chia sẻ URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "Các hành động dùng chung, tăng cường, tàu, công nghệ, công nghệ cao cấp và token Liên bang có giá trị thời điểm khi đối thủ có thể lấy trước.",
|
||||
"Shared mine (cannot be upgraded)": "Mỏ dùng chung (không thể nâng cấp)",
|
||||
"Ship Action": "Hành động Tàu",
|
||||
"Ship access and colour differences": "Khác biệt về khả năng tiếp cận tàu và màu sắc",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "Hành động Tàu tạo ra cách mở rộng mới. Kiểm tra chi phí tài nguyên, thưởng tạm thời và mọi giới hạn mỗi vòng trước khi dùng.",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "如果广泛扩张有助于收入、计分、行动机会和未来联邦,那么几个低成本且相连的矿场就可能是正确的开局。",
|
||||
"Share URL": "分享链接",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "当对手可能抢先拿走时,共享行动、助推板块、飞船、科技、高级科技和联邦标记就有时机上的价值。",
|
||||
"Shared mine (cannot be upgraded)": "共享矿场(无法升级)",
|
||||
"Ship Action": "飞船行动",
|
||||
"Ship access and colour differences": "飞船访问与颜色差异",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "飞船行动带来新的扩张方式。使用前先查看其资源费用、临时加成,以及是否每轮限用一次。",
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@
|
|||
"Several cheap, connected Mines can be the correct opening when breadth improves income, scoring, access, and future Federations.": "當廣度能改善收入、計分、可及性和未來聯邦時,數個廉價且相連的礦井可能是正確的開局。",
|
||||
"Share URL": "分享URL",
|
||||
"Shared actions, boosters, ships, techs, advanced techs, and Federation tokens gain timing value when an opponent can take them first.": "共享行動、強化板塊、飛船、科技、進階科技和聯邦標記在對手能先取得時獲得時機價值。",
|
||||
"Shared mine (cannot be upgraded)": "共享礦場(無法升級)",
|
||||
"Ship Action": "飛船行動",
|
||||
"Ship access and colour differences": "飛船使用權與顏色差異",
|
||||
"Ship actions create new ways to expand. Check their resource costs, temporary bonuses and any once-per-round limits before using them.": "飛船行動創造新的擴張方式。使用前先確認其資源花費、暫時性加成,以及任何每輪一次的限制。",
|
||||
|
|
|
|||
204
viewer/src/testing/shared-mine-building-group.ts
Normal file
204
viewer/src/testing/shared-mine-building-group.ts
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
import type { Player } from "@gaia-project/engine";
|
||||
import Engine, { Building, Faction, Planet, PlayerEnum, Resource } from "@gaia-project/engine";
|
||||
import { render } from "@testing-library/vue";
|
||||
import { createLocalVue } from "@vue/test-utils";
|
||||
import { expect } from "chai";
|
||||
import type { VueConstructor } from "vue";
|
||||
import { makeStore } from "../store";
|
||||
|
||||
function position(seat = PlayerEnum.Player1, shared = 2) {
|
||||
const factions = [Faction.HadschHallas, Faction.HadschHallas];
|
||||
factions[seat] = Faction.Lantids;
|
||||
const engine = new Engine([
|
||||
"init 2 shared-mine-slots",
|
||||
...factions.map((faction, i) => `p${i + 1} faction ${faction}`),
|
||||
]);
|
||||
const player = engine.players[seat];
|
||||
const host = engine.players[1 - seat];
|
||||
const hexes = [...engine.map.grid.values()];
|
||||
const normal = hexes.filter((hex) => hex.data.planet === Planet.Terra).slice(0, 2);
|
||||
const targets = hexes.filter((hex) => hex.data.planet === Planet.Oxide).slice(0, shared);
|
||||
// Use the engine's build bookkeeping, not hand-written occupied/buildings counters.
|
||||
normal.forEach((hex) => player.build(Building.Mine, hex, [], engine.map));
|
||||
targets.forEach((hex) => {
|
||||
host.build(Building.Mine, hex, [], engine.map);
|
||||
player.build(Building.Mine, hex, [], engine.map);
|
||||
});
|
||||
return { engine, player, host, normal, targets };
|
||||
}
|
||||
|
||||
/** Run against each UI's actual SFC: the legacy subclass has its own template and building tokens. */
|
||||
export function sharedMineBuildingGroupTests(Component: VueConstructor, tokenSelector: string) {
|
||||
const localVue = createLocalVue();
|
||||
// Leave tooltip titles in the DOM without Bootstrap's portal/hover behaviour.
|
||||
localVue.directive("b-tooltip", {});
|
||||
|
||||
function mount(engine: Engine, player: Player, building = Building.Mine, revealIncome = false) {
|
||||
const store = makeStore();
|
||||
store.commit("receiveData", engine);
|
||||
return render(Component, {
|
||||
store,
|
||||
localVue,
|
||||
props: {
|
||||
player,
|
||||
building,
|
||||
nBuildings: player.board.buildings[building].income.length,
|
||||
placed: player.data.buildings[building],
|
||||
resource: building === Building.Mine ? [Resource.Ore] : [],
|
||||
revealIncome,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const slots = (container: HTMLElement) => [...container.querySelectorAll(".building-group > g:not(.resource)")];
|
||||
const marked = (container: HTMLElement) =>
|
||||
slots(container).flatMap((slot, i) => (slot.querySelector(".shared-mine-mark") ? [i] : []));
|
||||
|
||||
function expectMineTrack(container: HTMLElement, placed: number, shared: number) {
|
||||
const track = slots(container);
|
||||
expect(track).to.have.length(8);
|
||||
expect(container.querySelectorAll(tokenSelector), "shared mines are already included in placed").to.have.length(
|
||||
8 - placed
|
||||
);
|
||||
expect(marked(container)).to.deep.equal(Array.from({ length: shared }, (_, i) => i));
|
||||
track.forEach((slot, i) => {
|
||||
const isShared = i < shared && i < placed;
|
||||
expect(!!slot.querySelector(tokenSelector), `slot ${i + 1} token`).to.equal(i >= placed);
|
||||
expect(!!slot.querySelector(".resource .ore"), `slot ${i + 1} ore (third slot is blank)`).to.equal(
|
||||
i < placed && !isShared && i !== 2
|
||||
);
|
||||
expect(slot.getAttribute("title")).to.equal(
|
||||
[
|
||||
isShared ? "Shared mine (cannot be upgraded)" : "Mine",
|
||||
"Cost: 2c, o",
|
||||
i === 2 ? "~" : "Income: o",
|
||||
"Power Value: 1",
|
||||
].join("<br/>")
|
||||
);
|
||||
const mark = slot.querySelector(".shared-mine-mark");
|
||||
if (mark) {
|
||||
expect(mark.getAttribute("transform"), "X is centered, not a corner badge").to.equal(null);
|
||||
expect(mark.querySelector("circle"), "no opaque white badge over the income").to.equal(null);
|
||||
expect(mark.querySelectorAll('g[transform="scale(0.05)"] > line')).to.have.length(2);
|
||||
expect(mark.querySelector("title")?.textContent).to.equal("Shared mine (cannot be upgraded)");
|
||||
expect(slot.querySelector(".resource"), "crossed-slot income moves to the left icon").to.equal(null);
|
||||
}
|
||||
});
|
||||
// Only income printed under crossed slots is folded into the basic income: slot 3 adds nothing.
|
||||
const leftIncome = container.querySelector(".building-group > .resource .resource-count");
|
||||
expect(leftIncome?.textContent?.trim()).to.equal(String(1 + shared - (shared > 2 ? 1 : 0)));
|
||||
const renderedOre = [...container.querySelectorAll(".resource")]
|
||||
.filter((resource) => resource.querySelector(".ore"))
|
||||
.reduce((total, resource) => total + Number(resource.querySelector(".resource-count")?.textContent), 0);
|
||||
expect(renderedOre, "left icon plus remaining slots must not lose or double-count income").to.equal(
|
||||
1 + placed - (placed > 2 ? 1 : 0)
|
||||
);
|
||||
}
|
||||
|
||||
describe("Lantids shared-mine markers", () => {
|
||||
for (const seat of [PlayerEnum.Player1, PlayerEnum.Player2]) {
|
||||
for (const shared of [0, 1, 2, 3]) {
|
||||
it(`marks the first ${shared} slots for seat ${seat}, preserving supply and total ore income`, () => {
|
||||
const { engine, player, targets, normal } = position(seat, shared);
|
||||
expect(player.player).to.equal(seat);
|
||||
expect(normal.map((hex) => hex.data.additionalMine)).to.deep.equal([undefined, undefined]);
|
||||
expect(targets.map((hex) => hex.data.additionalMine)).to.deep.equal(Array(shared).fill(seat));
|
||||
expect(player.data.buildings[Building.Mine]).to.equal(2 + shared);
|
||||
const oreIncome = player.resourceIncome(Resource.Ore);
|
||||
const boardIncome = JSON.stringify(player.board.income);
|
||||
expect(oreIncome).to.equal(shared < 2 ? 3 : shared + 2);
|
||||
const { container } = mount(engine, player);
|
||||
expectMineTrack(container, 2 + shared, shared);
|
||||
expect(JSON.stringify(player.board.income), "display aggregation must not mutate board rewards").to.equal(
|
||||
boardIncome
|
||||
);
|
||||
expect(player.resourceIncome(Resource.Ore)).to.equal(oreIncome);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it("returns an upgraded normal mine and builds another without moving either shared-mine X", async () => {
|
||||
const { engine, player, normal } = position();
|
||||
const view = mount(engine, player);
|
||||
expectMineTrack(view.container, 4, 2);
|
||||
const markedBeforeUpgrade = marked(view.container);
|
||||
player.build(Building.TradingStation, normal[0], [], engine.map);
|
||||
expect(player.data.buildings[Building.Mine]).to.equal(3);
|
||||
expect(player.resourceIncome(Resource.Ore)).to.equal(3);
|
||||
await view.updateProps({ placed: player.data.buildings[Building.Mine] });
|
||||
expectMineTrack(view.container, 3, 2);
|
||||
expect(marked(view.container)).to.deep.equal(markedBeforeUpgrade);
|
||||
|
||||
const next = [...engine.map.grid.values()].find((hex) => hex.data.planet === Planet.Terra && !hex.occupied());
|
||||
player.build(Building.Mine, next, [], engine.map);
|
||||
await view.updateProps({ placed: player.data.buildings[Building.Mine] });
|
||||
expectMineTrack(view.container, 4, 2);
|
||||
expect(marked(view.container)).to.deep.equal(markedBeforeUpgrade);
|
||||
});
|
||||
|
||||
it("keeps shared mines when their host upgrades, including after serialization", () => {
|
||||
const { engine, player, host, targets } = position();
|
||||
host.build(Building.TradingStation, targets[0], [], engine.map);
|
||||
expect(targets[0].data.building).to.equal(Building.TradingStation);
|
||||
expect(targets[0].data.additionalMine).to.equal(player.player);
|
||||
const restored = Engine.fromData(JSON.parse(JSON.stringify(engine)));
|
||||
const { container } = mount(restored, restored.players[player.player]);
|
||||
expectMineTrack(container, 4, 2);
|
||||
});
|
||||
|
||||
it("reveals all printed income but no Xs or tokens in faction previews", () => {
|
||||
const { engine, player } = position();
|
||||
const { container } = mount(engine, player, Building.Mine, true);
|
||||
expect(slots(container)).to.have.length(8);
|
||||
expect(marked(container)).to.deep.equal([]);
|
||||
expect(container.querySelector(tokenSelector)).to.equal(null);
|
||||
expect(container.querySelectorAll(".resource .ore")).to.have.length(8);
|
||||
container.querySelectorAll(".resource-count").forEach((count) => expect(count.textContent.trim()).to.equal("1"));
|
||||
expect(slots(container)[2].querySelector(".resource")).to.equal(null);
|
||||
slots(container).forEach((slot) => expect(slot.getAttribute("title")).to.match(/^Mine<br\/>/));
|
||||
});
|
||||
|
||||
it("does not mark ordinary Lantids mines or the other faction hosting shared mines", () => {
|
||||
const ordinary = position(PlayerEnum.Player1, 0);
|
||||
expectMineTrack(mount(ordinary.engine, ordinary.player).container, 2, 0);
|
||||
// Seat 1's occupied list includes additionalMine === 0, which is not its own mine.
|
||||
const { engine, host } = position();
|
||||
expectMineTrack(mount(engine, host).container, 2, 0);
|
||||
});
|
||||
|
||||
for (const building of [Building.TradingStation, Building.PlanetaryInstitute, Building.GaiaFormer]) {
|
||||
it(`does not mark a placed ${building} even when the player has shared mines`, () => {
|
||||
const { engine, player, normal } = position();
|
||||
if (building === Building.GaiaFormer) {
|
||||
const transdim = [...engine.map.grid.values()].find((hex) => hex.data.planet === Planet.Transdim);
|
||||
player.build(building, transdim, [], engine.map);
|
||||
} else {
|
||||
player.build(Building.TradingStation, normal[0], [], engine.map);
|
||||
if (building === Building.PlanetaryInstitute) {
|
||||
player.build(building, normal[0], [], engine.map);
|
||||
}
|
||||
}
|
||||
expect(player.data.buildings[building]).to.equal(1);
|
||||
const { container } = mount(engine, player, building);
|
||||
expect(container.querySelector(".shared-mine-mark")).to.equal(null);
|
||||
expect(container.textContent).to.not.contain("Shared mine");
|
||||
});
|
||||
}
|
||||
|
||||
for (const sharedLostPlanet of [false, true]) {
|
||||
it(`${sharedLostPlanet ? "uses supply and marks a shared opponent" : "uses no supply and adds no X for an own"} Lost Planet`, () => {
|
||||
const { engine, player, host } = position(PlayerEnum.Player1, 1);
|
||||
const lost = [...engine.map.grid.values()].find((hex) => hex.data.planet === Planet.Empty);
|
||||
lost.data.planet = Planet.Lost;
|
||||
if (sharedLostPlanet) host.build(Building.Mine, lost, [], engine.map);
|
||||
player.build(Building.Mine, lost, [], engine.map);
|
||||
expect(player.data.lostPlanet).to.equal(sharedLostPlanet ? 0 : 1);
|
||||
expect(lost.data.additionalMine).to.equal(sharedLostPlanet ? player.player : undefined);
|
||||
expect(player.data.buildings[Building.Mine]).to.equal(sharedLostPlanet ? 4 : 3);
|
||||
expect(player.resourceIncome(Resource.Ore)).to.equal(sharedLostPlanet ? 4 : 3);
|
||||
const { container } = mount(engine, player);
|
||||
expectMineTrack(container, sharedLostPlanet ? 4 : 3, sharedLostPlanet ? 2 : 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue