28 lines
950 B
TypeScript
28 lines
950 B
TypeScript
import type { GameState } from "../types/GameState";
|
|
import atBatSimulator from "../game/atBatSimulator";
|
|
import { randomTeam } from "./generateFixtures";
|
|
|
|
const batting = randomTeam();
|
|
const fielding = randomTeam();
|
|
|
|
const initialState: GameState = {
|
|
inning: 1,
|
|
top: true,
|
|
outs: 0,
|
|
count: { balls: 0, strikes: 0 },
|
|
score: { home: 0, away: 0 },
|
|
};
|
|
|
|
const batter = batting.battingLineup[batting.batterIndex]!;
|
|
const pitcher = fielding.fieldingLineup.pitcher;
|
|
const catcher = fielding.fieldingLineup.c;
|
|
|
|
console.log(`Batter: ${batter.firstname} ${batter.lastname} (batting: ${batter.skillset.batting.toFixed(2)})`);
|
|
console.log(`Pitcher: ${pitcher.firstname} ${pitcher.lastname} (armStrength: ${pitcher.skillset.pitching.armStrength.toFixed(2)})`);
|
|
console.log(`Catcher: ${catcher.firstname} ${catcher.lastname}`);
|
|
console.log("---");
|
|
|
|
const result = atBatSimulator(batter, catcher, pitcher, initialState);
|
|
|
|
console.log("Result state:", result);
|