initial commit
This commit is contained in:
27
test/testAtBat.ts
Normal file
27
test/testAtBat.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
Reference in New Issue
Block a user