Skip to content

Commit

Permalink
# This is a combination of 12 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Move playCorporationCard to Player, where it belongs. Merge with merger code.

# This is the commit message #2:

Provide Card2, bespokeCanPlay, & bespokePlay.

This is going to be cleaner and easier to manage than the current
approach. This removes most uses of `migrated`. The rest will come
shortly.

# This is the commit message #3:

Fix sqlite3 async purgeUnfinishedGames.

1. purgeUnfinishedGames wasn't finished for SQLite, so this finishes it.

# This is the commit message #4:

Rename "money production" to "M€ production"

# This is the commit message #5:

Remove translations.json. It shouldn't be generated again.

# This is the commit message #6:

Present user with ability to go to the map when selecting a space.

Fixes terraforming-mars#2584

# This is the commit message #7:

Update src/client/components/waitingFor/GoToMap.vue

Co-authored-by: Brian Folts <[email protected]>
# This is the commit message #8:

CEO's Fav. Proj. may not be used on robot cards.

# This is the commit message #9:

Game end / Game log features

1. Add "Download game log".
2. Clean up some translations.
3. Make spectator able to see the game log.

# This is the commit message #10:

When fetching game-end logs too soon, return bad request instead of internal error.

# This is the commit message #11:

Log Venus increase from Ambient corp.

Meanwhile, for other cards that increase Venus, make sure it logs the
amount actually raised.

# This is the commit message #12:

Remove unnecessary type declarations
  • Loading branch information
kberg committed Sep 2, 2022
1 parent c7187bd commit 09c59f3
Show file tree
Hide file tree
Showing 187 changed files with 673 additions and 617 deletions.
4 changes: 2 additions & 2 deletions src/client/components/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const mainAppSettings = {
return (this as unknown as typeof mainAppSettings.data).componentsVisibility[targetVar] ? true : false;
},
update(path: '/player' | '/spectator'): void {
const currentPathname: string = window.location.pathname;
const currentPathname = window.location.pathname;
const xhr = new XMLHttpRequest();
const app = this as unknown as typeof mainAppSettings.data;

Expand Down Expand Up @@ -183,7 +183,7 @@ export const mainAppSettings = {
mounted() {
document.title = constants.APP_NAME;
if (!windowHasHTMLDialogElement()) dialogPolyfill.default.registerDialog(document.getElementById('alert-dialog'));
const currentPathname: string = window.location.pathname;
const currentPathname = window.location.pathname;
const app = this as unknown as (typeof mainAppSettings.data) & (typeof mainAppSettings.methods);
if (currentPathname === '/player') {
app.updatePlayer();
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default Vue.extend({
throw new Error('Wrong parameter to get values from: ' + targetParameter);
}
for (let value: number = endValue; value >= startValue; value -= step) {
for (let value = endValue; value >= startValue; value -= step) {
strValue = (targetParameter === 'temperature' && value > 0) ? '+'+value : value.toString();
values.push(
new GlobalParamLevel(value, value === curValue, strValue),
Expand Down
314 changes: 161 additions & 153 deletions src/client/components/GameEnd.vue

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/client/components/card/CardRenderItemComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default Vue.extend({
},
// Oooh this is begging to be a template or something.
itemHtmlContent(): string {
let result: string = '';
let result = '';
// in case of symbols inside
if (isICardRenderItem(this.item) && this.item.amountInside) {
if (this.item.amount !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/moon/MoonBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default Vue.extend({
}
const values: Array<MoonParamLevel> = [];
for (let value: number = 8; value >= 0; value -= 1) {
for (let value = 8; value >= 0; value -= 1) {
const strValue = value.toString();
values.push(
new MoonParamLevel(value, value === curValue, strValue),
Expand Down
6 changes: 3 additions & 3 deletions src/client/components/overview/PlayersOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export default Vue.extend({
}
let result: Array<PublicPlayerModel> = [];
let currentPlayerOffset: number = 0;
const currentPlayerIndex: number = playerIndex(
let currentPlayerOffset = 0;
const currentPlayerIndex = playerIndex(
this.thisPlayer.color,
this.players,
);
Expand Down Expand Up @@ -95,7 +95,7 @@ export default Vue.extend({
(p: PublicPlayerModel) => !this.playerView.game.passedPlayers.includes(p.color),
);
const currentPlayerIndex: number = playerIndex(
const currentPlayerIndex = playerIndex(
player.color,
notPassedPlayers,
);
Expand Down
4 changes: 2 additions & 2 deletions src/locales/br/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Next time you will get more luck!": "Mais sorte da próxima vez!",
"Also, take into account these small hints to win:": "Além disso, leve em conta estas pequenas dicas para ganhar:",
"Concentrate more on Global parameters, not on Victory Points": "Concentre-se mais nos parâmetros globais, não em pontos de vitória",
"Don't be greedy on cards selection": "Não seja tão ganancioso ao selecionar cartas",
"Don't be greedy with card selection": "Não seja tão ganancioso ao selecionar cartas",
"Try to increase Heat production, not Megacredits": "Tente aumentar a produção de calor, não a de Megacréditos",
"Try to start with Beginner corporation": "Tente começar com a corporação para iniciantes",

"You win!": "Você ganhou!",
"But it isn't the reason to stop making Mars better.": "Mas esta não é a razão de parar de fazer Marte melhor.",
"Try to win with expansions enabled": "Tente ganhar com as expansões.",
Expand Down
8 changes: 4 additions & 4 deletions src/locales/cn/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Claimed Generalist milestone": "获得'泛用人才'里程碑",
"Claimed Hoverlord milestone": "获得'天空霸主'里程碑",
"Claimed Legend milestone": "获得'传奇人物'里程碑",
"Claimed Mayor milestone": "获得'市长'里程碑",
"Claimed Mayor milestone": "获得'市长'里程碑",
"Claimed Planner milestone": "获得'运筹帷幄'里程碑",
"Claimed Polar Explorer milestone": "获得'极地探险家'里程碑",
"Claimed Rim Settler milestone": "获得'木星定居者'里程碑",
Expand All @@ -38,17 +38,17 @@
"Next time you will get more luck!": "下一次你将更幸运!",
"Also, take into account these small hints to win:": "另外,请考虑以下小技巧以取胜:",
"Concentrate more on Global parameters, not on Victory Points": "更多地关注全局参数,而不是得分",
"Don't be greedy on cards selection": "不要贪图卡牌选择",
"Don't be greedy with card selection": "不要贪图卡牌选择",
"Try to increase Heat production, not Megacredits": "尝试增加热量产量,而不是M€”",
"Try to start with Beginner corporation": "尝试用新手公司开始游戏",

"You win!": "你赢了!",
"But it isn't the reason to stop making Mars better.": "但这不是停止让火星变得更好的理由。",
"Try to win with expansions enabled": "尝试加入更多扩展包获得胜利",
"Try to win before the last generation comes": "尝试在最后一个时代之前获得胜利",
"Can you get": "你能获得",
"+ Victory Points?": "+ 的分数吗?",

"Terraforming Mars - Game finished!": "殖民火星 - 游戏结束!",
"Go to main page": "回到主页",
"Timer": "计时器",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/de/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"Next time you will get more luck!": "Beim nächsten Mal hast du bestimmt mehr Glück!",
"Also, take into account these small hints to win:": "Berücksichtige vielleicht auch diese Tips, um zu gewinnen:",
"Concentrate more on Global parameters, not on Victory Points": "Konzentriere dich auf Globale Parameter, nicht Siegpunkte",
"Don't be greedy on cards selection": "Sei nicht gierig bei der Kartenwahl",
"Don't be greedy with card selection": "Sei nicht gierig bei der Kartenwahl",
"Try to increase Heat production, not Megacredits": "Versuche die Wärme-Produktion zu steigern, nicht die M€-Produktion",
"Try to start with Beginner corporation": "Versuche es zu Beginn mit dem Anfänger-Konzern",

"You win!": "Du hast gewonnen!",
"But it isn't the reason to stop making Mars better.": "Aber das ist kein Grund den Mars nicht noch besser zu machen.",
"Try to win with expansions enabled": "Versuche mit aktivierten Erweiterungen zu gewinnen.",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/es/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Next time you will get more luck!": "¡La próxima vez tendrás más suerte!",
"Also, take into account these small hints to win:": "También ten en cuenta estos pequeños consejos para ganar:",
"Concentrate more on Global parameters, not on Victory Points": "Concéntrate más en los parámetros globales, no en los puntos de victoria",
"Don't be greedy on cards selection": "No seas codicioso al seleccionar las cartas",
"Don't be greedy with card selection": "No seas codicioso al seleccionar las cartas",
"Try to increase Heat production, not Megacredits": "Intenta aumentar la producción de calor, no la de Megacréditos",
"Try to start with Beginner corporation": "Intenta empezar con la corporación novel",

"You win!": "¡Has ganado!",
"But it isn't the reason to stop making Mars better.": "Pero no es una razón para no poder mejorar.",
"Try to win with expansions enabled": "Intenta ganar con más expansiones activadas.",
Expand Down
6 changes: 3 additions & 3 deletions src/locales/it/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"Next time you will get more luck!": "La prossima volta sarai più fortunato!",
"Also, take into account these small hints to win:": "Ecco alcuni consigli per vincere:",
"Concentrate more on Global parameters, not on Victory Points": "Concentrati di più sui parametri Globali, non sui Punti Vittoria",
"Don't be greedy on cards selection": "Non essere avido nella scelta delle carte",
"Don't be greedy with card selection": "Non essere avido nella scelta delle carte",
"Try to increase Heat production, not Megacredits": "Cerca di aumentare la produzione di Calore, non i M€”",
"Try to start with Beginner corporation": "Prova ad iniziare con la Beginner Corporation",

"You win!": "Hai vinto!",
"But it isn't the reason to stop making Mars better.": "Ma non è un buon motivo per smettere di migliorare Marte.",
"Try to win with expansions enabled": "Prova a vincere includendo le espansioni",
"Try to win before the last generation comes": "Prova a vincere prima dell'ultima generazione",
"Can you get": "Riesci a ottenere",
"+ Victory Points?": " o più Punti Vittoria?",

"Terraforming Mars - Game finished!": "Terraforming Mars - Partita terminata!",
"Go to main page": "Torna alla pagina principale",
"Timer": "Durata",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/ko/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Next time you will get more luck!": "다음 번엔 조금 더 운이 좋을 겁니다!",
"Also, take into account these small hints to win": "또한 이 작은 힌트를 고려하여 승리하세요.",
"Concentrate more on Global parameters, not on Victory Points": "승점이 아니라 행성 지표에 더 집중하세요.",
"Don't be greedy on cards selection": "카드 선택에 욕심내지 마세요.",
"Don't be greedy with card selection": "카드 선택에 욕심내지 마세요.",
"Try to increase Heat production, not Megacredits": "메가크레딧 보다 열 생산량을 늘리세요.",
"Try to start with Beginner corporation": "초심자 기업으로 시작해 보세요.",

"You win!": "당신은 승리하였습니다!",
"But it isn't the reason to stop making Mars better.": "그러나 그것이 화성을 더 좋게 만드는 것을 중단할 이유는 아닙니다.",
"Try to win with expansions enabled": "확장이 활성화된 상태로 승리해 보세요.",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/pl/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Next time you will get more luck!": "Kolejnym razem na pewno pójdzie lepiej!",
"Also, take into account these small hints to win:": "Weź pod uwagę te drobne wskazówki:",
"Concentrate more on Global parameters, not on Victory Points": "Skup się bardziej na Wskaźnikach Globalnych zamiast Punktów Zwycięstwa",
"Don't be greedy on cards selection": "Nie przesadzaj z dobieraniem kart",
"Don't be greedy with card selection": "Nie przesadzaj z dobieraniem kart",
"Try to increase Heat production, not Megacredits": "Postaraj się zwiększać produkcję ciepła, nie Megakredytów",
"Try to start with Beginner corporation": "Spróbuj zacząć z korporacją dla początkujących",

"You win!": "Wygrałeś/aś!",
"But it isn't the reason to stop making Mars better.": "Nie jest to jednak powód do zaprzestania dalszego doskonalenia Marsa",
"Try to win with expansions enabled": "Spróbuj wygrać korzystając z dodatków",
Expand Down
6 changes: 3 additions & 3 deletions src/locales/ru/game_end.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Next time you will get more luck!": "Но в следующий раз вам повезет больше!",
"Also, take into account these small hints to win:": "Может помочь следующее:",
"Concentrate more on Global parameters, not on Victory Points": "Концентрируйтесь на увеличении глобальных параметров, а не победных очков",
"Don't be greedy on cards selection": "Не старайтесь купить больше карт",
"Don't be greedy with card selection": "Не старайтесь купить больше карт",
"Try to increase Heat production, not Megacredits": "Попробуйте больше увеличивать производство тепла, чем производство денег",
"Try to start with Beginner corporation": "Сыграйте корпорацией для новичков",

"You win!": "Победа!",
"But it isn't the reason to stop making Mars better.": "Но это не повод останавливаться на достигнутом.",
"Try to win with expansions enabled": "Попробуйте победить с дополнениями",
Expand All @@ -24,4 +24,4 @@
"Victory points details for": "Подробно о наборе очков игроком:",
"Final situation on the board": "Итоговая ситуация на Марсе",
"Final game log": "Последние действия игроков"
}
}
18 changes: 10 additions & 8 deletions src/server/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class Game {
players: Array<Player>,
firstPlayer: Player,
gameOptions: GameOptions = {...DEFAULT_GAME_OPTIONS},
seed: number = 0,
seed = 0,
spectatorId: SpectatorId | undefined = undefined): Game {
if (gameOptions.clonedGamedId !== undefined) {
throw new Error('Cloning should not come through this execution path.');
Expand Down Expand Up @@ -589,7 +589,7 @@ export class Game {

// Public for testing.
public incrementFirstPlayer(): void {
let firstIndex: number = this.players.map((x) => x.id).indexOf(this.first.id);
let firstIndex = this.players.map((x) => x.id).indexOf(this.first.id);
if (firstIndex === -1) {
throw new Error('Didn\'t even find player');
}
Expand Down Expand Up @@ -927,7 +927,7 @@ export class Game {
}

private getPlayerBefore(player: Player): Player | undefined {
const playerIndex: number = this.players.indexOf(player);
const playerIndex = this.players.indexOf(player);

// The player was not found
if (playerIndex === -1) {
Expand All @@ -939,7 +939,7 @@ export class Game {
}

private getPlayerAfter(player: Player): Player | undefined {
const playerIndex: number = this.players.indexOf(player);
const playerIndex = this.players.indexOf(player);

// The player was not found
if (playerIndex === -1) {
Expand Down Expand Up @@ -1086,15 +1086,15 @@ export class Game {
return this.oxygenLevel;
}

public increaseVenusScaleLevel(player: Player, increments: -1 | 1 | 2 | 3): void {
public increaseVenusScaleLevel(player: Player, increments: -1 | 1 | 2 | 3): number {
if (this.venusScaleLevel >= constants.MAX_VENUS_SCALE) {
return;
return 0;
}

// PoliticalAgendas Reds P3 hook
if (increments === -1) {
this.venusScaleLevel = Math.max(constants.MIN_VENUS_SCALE, this.venusScaleLevel + increments * 2);
return;
return -1;
}

// Literal typing makes |increments| a const
Expand Down Expand Up @@ -1130,6 +1130,8 @@ export class Game {
}

this.venusScaleLevel += steps * 2;

return steps;
}

public getVenusScaleLevel(): number {
Expand Down Expand Up @@ -1456,7 +1458,7 @@ export class Game {
// Players returned in play order starting with first player this generation.
public getPlayersInGenerationOrder(): Array<Player> {
const ret: Array<Player> = [];
let insertIdx: number = 0;
let insertIdx = 0;
for (const p of this.players) {
if (p.id === this.first.id || insertIdx > 0) {
ret.splice(insertIdx, 0, p);
Expand Down
8 changes: 4 additions & 4 deletions src/server/LogHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export class LogHelper {
// Skip solo play random tiles
if (player.name === 'neutral') return;

const offset: number = Math.abs(space.y - 4);
const row: number = space.y + 1;
const position: number = space.x - offset + 1;
const offset = Math.abs(space.y - 4);
const row = space.y + 1;
const position = space.x - offset + 1;

player.game.log('${0} ${1} ${2} on row ${3} position ${4}', (b) =>
b.player(player).string(action).string(description).number(row).number(position));
Expand All @@ -58,7 +58,7 @@ export class LogHelper {
}

static logVenusIncrease(player: Player, steps: number) {
player.game.log('${0} increased Venus scale ${1} step(s)', (b) => b.player(player).number(steps));
player.game.log('${0} raised the Venus scale ${1} step(s)', (b) => b.player(player).number(steps));
}

static logDiscardedCards(game: Game, cards: Array<ICard> | Array<CardName>) {
Expand Down
4 changes: 2 additions & 2 deletions src/server/MilestoneAwardSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ export namespace MilestoneAwardSelector {
milestones: Array<string> = [];
awards: Array<string> = [];

private accumulatedHighCount: number = 0;
private accumulatedTotalSynergy: number = 0;
private accumulatedHighCount = 0;
private accumulatedTotalSynergy = 0;

constructor(private constraints: Constraints) {
}
Expand Down
22 changes: 11 additions & 11 deletions src/server/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export class Player {
});

// Turmoil Victory Points
const includeTurmoilVP : boolean = this.game.gameIsOver() || this.game.phase === Phase.END;
const includeTurmoilVP = this.game.gameIsOver() || this.game.phase === Phase.END;

Turmoil.ifTurmoil(this.game, (turmoil) => {
if (includeTurmoilVP) {
Expand Down Expand Up @@ -574,7 +574,7 @@ export class Player {
// Return the number of cards in the player's hand without tags.
// Wild tags are ignored in this computation. (why?)
public getNoTagsCount() {
let noTagsCount: number = 0;
let noTagsCount = 0;

noTagsCount += this.corporations.filter((card) => card.cardType !== CardType.EVENT && card.tags.every((tag) => tag === Tag.WILD)).length;
noTagsCount += this.playedCards.filter((card) => card.cardType !== CardType.EVENT && card.tags.every((tag) => tag === Tag.WILD)).length;
Expand All @@ -585,7 +585,7 @@ export class Player {
public getColoniesCount() {
if (!this.game.gameOptions.coloniesExtension) return 0;

let coloniesCount: number = 0;
let coloniesCount = 0;

this.game.colonies.forEach((colony) => {
coloniesCount += colony.colonies.filter((owner) => owner === this.id).length;
Expand All @@ -607,7 +607,7 @@ export class Player {
}

public getRequirementsBonus(parameter: GlobalParameter): number {
let requirementsBonus: number = 0;
let requirementsBonus = 0;
for (const playedCard of this.tableau) {
if (playedCard.getRequirementBonus !== undefined) requirementsBonus += playedCard.getRequirementBonus(this, parameter);
}
Expand Down Expand Up @@ -687,7 +687,7 @@ export class Player {
}

public getResourceCount(resource: CardResource): number {
let count: number = 0;
let count = 0;
this.getCardsWithResources(resource).forEach((card) => {
count += card.resourceCount;
});
Expand Down Expand Up @@ -751,7 +751,7 @@ export class Player {
}

public worldGovernmentTerraforming(): void {
const action: OrOptions = new OrOptions();
const action = new OrOptions();
action.title = 'Select action for World Government Terraforming';
action.buttonLabel = 'Confirm';
const game = this.game;
Expand Down Expand Up @@ -939,7 +939,7 @@ export class Player {
}

public getCardCost(card: IProjectCard): number {
let cost: number = card.cost;
let cost = card.cost;
cost -= this.colonies.cardDiscount;

this.tableau.forEach((playedCard) => {
Expand Down Expand Up @@ -990,7 +990,7 @@ export class Player {
}

public checkPaymentAndPlayCard(selectedCard: IProjectCard, payment: Payment, cardAction: CardAction = 'add') {
const cardCost: number = this.getCardCost(selectedCard);
const cardCost = this.getCardCost(selectedCard);

const reserved = MoonExpansion.adjustedReserveCosts(this, selectedCard);

Expand Down Expand Up @@ -1376,7 +1376,7 @@ export class Player {
}

if (this.game.canPlaceGreenery(this)) {
const action: OrOptions = new OrOptions();
const action = new OrOptions();
action.title = 'Place any final greenery from plants';
action.buttonLabel = 'Confirm';
action.options.push(
Expand Down Expand Up @@ -1700,9 +1700,9 @@ export class Player {
this.actionsTakenThisGame++;
}

// Return possible mid-game actions like play a card and fund an award, but no play prelude card.
// Return possible mid-game actions like play a card and fund an award, but not play prelude card.
public getActions() {
const action: OrOptions = new OrOptions();
const action = new OrOptions();
action.title = this.actionsTakenThisRound === 0 ?
'Take your first action' : 'Take your next action';
action.buttonLabel = 'Take action';
Expand Down
Loading

0 comments on commit 09c59f3

Please sign in to comment.