initial commit
This commit is contained in:
40
game/atBatSimulator.ts
Normal file
40
game/atBatSimulator.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { ThrownPitch } from "../types/ThrownPitch";
|
||||
import type { Player } from "../types/Player";
|
||||
import type { BattedBall } from "../types/BattedBall";
|
||||
import type { GameState } from "../types/GameState";
|
||||
|
||||
import pitchGenerator from "../systems/pitchGenerator";
|
||||
|
||||
export default function atBatSimulator(batter: Player, catcher: Player, pitcher: Player, game: GameState): GameState {
|
||||
if (game.outs < 3) {
|
||||
// do stuff
|
||||
const pitch: ThrownPitch = pitchGenerator(pitcher);
|
||||
|
||||
// a pitch can either be:
|
||||
// - batted
|
||||
// - caught for a ball/strike
|
||||
// - thrown wild
|
||||
|
||||
} else {
|
||||
if (game.top) {
|
||||
game.top = false;
|
||||
} else {
|
||||
game.top = true;
|
||||
game.inning++ // games will keep going on forever
|
||||
}
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
function swingSimulator(batter: Player, pitch: ThrownPitch): BattedBall {
|
||||
// see the ball!
|
||||
// decide if you're gonna swing!
|
||||
// aim true! get that timing right!
|
||||
// return a battedball
|
||||
return {
|
||||
exitVelo: 0,
|
||||
launchAngle: 0,
|
||||
attackAngle: 0,
|
||||
spinRate: 0
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user