Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/maps/double_base_usa/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Phase } from "../../engine/state/phase";
import { Log } from "../../engine/game/log";
import { GoodsGrowthPhase } from "../../engine/goods_growth/phase";
import { PlayerColor } from "../../engine/state/player";
import { ActionBundle } from "../../engine/game/phase_module";

const ProductionState = z.object({
goods: GoodZod.array(),
Expand All @@ -27,6 +28,7 @@ export const PRODUCTION_STATE = new Key("dbuProductionState", {

export class DoubleBaseUsaSelectActionPhase extends SelectActionPhase {
private readonly productionState = injectState(PRODUCTION_STATE);
private readonly currentPlayer = injectCurrentPlayer();

configureActions(): void {
super.configureActions();
Expand All @@ -40,6 +42,13 @@ export class DoubleBaseUsaSelectActionPhase extends SelectActionPhase {
this.productionState.delete();
super.onEnd();
}
forcedAction(): ActionBundle<object> | undefined {
// If the current player has already selected an action (i.e. production) do not force an action
if (this.currentPlayer().selectedAction !== undefined) {
return undefined;
}
return super.forcedAction();
}
}

export const ProductionData = z.object({
Expand Down
9 changes: 9 additions & 0 deletions src/maps/eastern_us_and_canada/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Phase } from "../../engine/state/phase";
import { Log } from "../../engine/game/log";
import { GoodsGrowthPhase } from "../../engine/goods_growth/phase";
import { PlayerColor } from "../../engine/state/player";
import { ActionBundle } from "../../engine/game/phase_module";

const ProductionState = z.object({
goods: GoodZod.array(),
Expand All @@ -30,6 +31,7 @@ export const PRODUCTION_STATE = new Key("eucProductionState", {

export class EasternUsAndCanadaSelectActionPhase extends SelectActionPhase {
private readonly productionState = injectState(PRODUCTION_STATE);
private readonly currentPlayer = injectCurrentPlayer();

configureActions(): void {
super.configureActions();
Expand All @@ -43,6 +45,13 @@ export class EasternUsAndCanadaSelectActionPhase extends SelectActionPhase {
this.productionState.delete();
super.onEnd();
}
forcedAction(): ActionBundle<object> | undefined {
// If the current player has already selected an action (i.e. production) do not force an action
if (this.currentPlayer().selectedAction !== undefined) {
return undefined;
}
return super.forcedAction();
}
}

export class EasternUsAndCanadaSelectAction extends SelectAction {
Expand Down
Loading