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
7 changes: 5 additions & 2 deletions src/client/grid/building_dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export function BuildingDialog({
tile={build.tile}
onClick={() => build.reason == null && onSelect(build.action)}
/>
<div style={{ textAlign: "center" }}>${build.cost}</div>
{build.reason}
</div>
))}
Expand Down Expand Up @@ -288,6 +289,7 @@ export function ModifiedSpace({
interface EligibleBuild {
action: BuildData;
tile: TileData;
cost: number;
reason?: string;
}

Expand Down Expand Up @@ -351,11 +353,12 @@ function* getAllEligibleBuilds(
for (const orientation of directions) {
const action = { orientation, tileType, coordinates };
const tile = { orientation, tileType, owners: [] };
const cost = actionProcessor.totalCostOf(action);
try {
actionProcessor.validate(action);
yield { action, tile };
yield { action, tile, cost };
} catch (e: unknown) {
yield { action, tile, reason: (e as Error).message };
yield { action, tile, cost, reason: (e as Error).message };
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/engine/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ export class BuildAction implements ActionProcessor<BuildData> {

process(data: BuildData): boolean {
const coordinates = data.coordinates;
this.moneyManager.addMoneyForCurrentPlayer(-this.totalCostOf(data));
const totalCost = this.totalCostOf(data);
this.moneyManager.addMoneyForCurrentPlayer(-totalCost);
this.discountManager.applyDiscount(data, this.originalCostOf(data));
const newTile = this.newTile(data);
this.log.currentPlayer(`builds a ${getTileTypeString(data.tileType)} at ${this.grid().displayName(data.coordinates)}`);
this.log.currentPlayer(`builds a ${getTileTypeString(data.tileType)} at ${this.grid().displayName(data.coordinates)} for $${totalCost}`);
this.gridHelper.update(coordinates, (hex) => {
assert(hex.type !== SpaceType.CITY);
hex.tile = newTile;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/build/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ClaimAction implements ActionProcessor<ClaimData> {

const route = this.grid().getRoute(track);

this.log.currentPlayer(`claimes the route at ${this.grid().displayName(data.coordinates)}`);
this.log.currentPlayer(`claims the route at ${this.grid().displayName(data.coordinates)} for $${this.totalCost(data, track)}`);

for (const t of route) {
this.gridHelper.update(t.coordinates, (space) => {
Expand Down
Loading