fix(complement-race): train now moves in sprint mode
**THE BUG**: Validator was only updating momentum in Sprint mode, but NEVER updating position! This caused trainPosition to stay at 0. **THE FIX**: Added position calculation based on momentum: - moveDistance = momentum / 20 - Starting momentum (50) → 2.5 units per answer - Max momentum (100) → 5 units per answer - Creates progression: higher momentum = faster train movement Position updates per answer now work: - Correct answer: momentum +15, then position +=(momentum/20) - Wrong answer: momentum -10, then position +=(momentum/20) - Position capped at 100 (end of route) This matches the original single-player behavior where the train speed was tied to momentum. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -94,7 +94,9 @@ export function SteamTrainJourney({
|
||||
currentInput,
|
||||
}: SteamTrainJourneyProps) {
|
||||
const { state } = useComplementRace()
|
||||
console.log(`🚂 Train: mom=${momentum} pos=${trainPosition} stations=${state.stations.length} passengers=${state.passengers.length}`)
|
||||
console.log(
|
||||
`🚂 Train: mom=${momentum} pos=${trainPosition} stations=${state.stations.length} passengers=${state.passengers.length}`
|
||||
)
|
||||
|
||||
const { getSkyGradient, getTimeOfDayPeriod } = useSteamJourney()
|
||||
const _skyGradient = getSkyGradient()
|
||||
|
||||
@@ -330,7 +330,9 @@ export function ComplementRaceProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
}, [multiplayerState, localPlayerId, localUIState])
|
||||
|
||||
console.log(`🚂 Sprint: momentum=${compatibleState.momentum} pos=${compatibleState.trainPosition} pressure=${compatibleState.pressure}`)
|
||||
console.log(
|
||||
`🚂 Sprint: momentum=${compatibleState.momentum} pos=${compatibleState.trainPosition} pressure=${compatibleState.pressure}`
|
||||
)
|
||||
|
||||
// Action creators
|
||||
const startGame = useCallback(() => {
|
||||
|
||||
@@ -317,12 +317,17 @@ export class ComplementRaceValidator
|
||||
updatedPlayer.position = Math.min(100, player.position + 100 / state.config.raceGoal)
|
||||
}
|
||||
} else if (state.config.style === 'sprint') {
|
||||
// Sprint: Update momentum
|
||||
// Sprint: Update momentum AND position
|
||||
if (correct) {
|
||||
updatedPlayer.momentum = Math.min(100, player.momentum + 15)
|
||||
} else {
|
||||
updatedPlayer.momentum = Math.max(0, player.momentum - 10)
|
||||
}
|
||||
|
||||
// Move train based on momentum (momentum/20 = position change per answer)
|
||||
// Higher momentum = faster movement
|
||||
const moveDistance = updatedPlayer.momentum / 20
|
||||
updatedPlayer.position = Math.min(100, player.position + moveDistance)
|
||||
} else if (state.config.style === 'survival') {
|
||||
// Survival: Always move forward, speed based on accuracy
|
||||
const moveDistance = correct ? 5 : 2
|
||||
|
||||
Reference in New Issue
Block a user