initial commit
This commit is contained in:
30
game/gameRuntime.ts
Normal file
30
game/gameRuntime.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import type { Player } from "../types/Player";
|
||||
import type { GameState } from "../types/GameState";
|
||||
import type { ThrownPitch } from "../types/ThrownPitch";
|
||||
|
||||
import pitchGenerator from "../systems/pitchGenerator";
|
||||
import type { Team } from "../types/Team";
|
||||
|
||||
function startGame(homeTeam: Team, awayTeam: Team) {
|
||||
// simulate
|
||||
}
|
||||
|
||||
function advanceOrEndGame(game: GameState): GameState {
|
||||
// home team always bats last
|
||||
// if it's the top of the 9th and the away team is behind, the game is over
|
||||
if (game.inning == 9 || game.top == true && game.score.home > game.score.away) console.log("game should be over now.");
|
||||
|
||||
// next inning
|
||||
if (game.top) {
|
||||
return { ...game, top: false };
|
||||
} else {
|
||||
return {
|
||||
...game, inning: game.inning + 1, top: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function endGame(game: GameState) {
|
||||
console.log("GAME SHOULD END NOW SO FIGURE OUT WHAT TO DO!")
|
||||
}
|
||||
Reference in New Issue
Block a user