Skip to content

Blown engines and repairs

An engine that blows in a race the race server judged (career events, boss and tournament rounds, quick races and online heats) stays blown. That car cannot race again until it is repaired in the Garage. Test runs never count, so tuning experiments stay free. The player can switch to another car they own and race that one meanwhile.

player/repair.ts holds them, with no Phaser, so the server runs the same code:

  • markBlown(state, modelId) sets blown on that OwnedCar. Cars are unique per model, so the model id names the car.
  • repairPrice(car) is 5% of the car’s value: its model price plus the parts bought for it (carValue in player/shopRules.ts, the same base as the sell price).
  • repairCharge is what the repair takes: the price, or all the player’s cash when they have less. A player at $0 repairs for free, so nobody is ever stuck. Repairs are rare, so this costs the economy little.
  • The repair garage action (player/garageActions.ts) repairs the current car and refuses one that is fine.

tests/repair.test.ts covers price, the short-of-cash case and the refusal.

  • Career and quick races: each judge reports blown from its replay, and finish in party/src/api/raceApi.ts marks the car from the race ticket. start refuses a ticket while the current car is blown.
  • Online: markOnlineBlown (party/src/race/onlineBlown.ts) marks each blown runner after a heat, and ownedEntry refuses a blown car at join.

The game cannot clear the flag: blown is not one of the fields its sync sends (player/garageSync.ts).

  • Race guard (ui/raceGuard.ts): whenCarCanRace runs before every way into a race (career event, boss, next boss round, quick race, Results retry). For a blown car it opens a dialog that sends the player to the Garage. Online, joinRoomAction (net/joinRoom.ts) refuses without connecting.
  • Car picker (hub/pickEligibleCar.ts): a class-restricted event does not offer blown cars.
  • Garage (garage/view/repairButton.ts): a red Repair engine button with the charge, shown only while the current car is blown.