Refactor game logic and improve state management, add some tests
- Added `handleHit` function to handle hit types (single, double, triple, home run). - Enhanced `handleBall` and `handlePitch` to track `scoredRunners` and update scores dynamically. - Updated history to include both `gameState` and `lineupState`. - Refactored UI components (`GameStateDisplay`) to use unified score structure and display detailed base states. - Styled active lineup tab with visual emphasis. - Introduced utility functions `encodeInning` and `decodeInning` for inning state management.
This commit is contained in:
@@ -13,7 +13,7 @@ function Inning({inning, isTopHalf}){
|
||||
)
|
||||
}
|
||||
|
||||
function GameStateDisplay({inning, bases, isTopHalf, outs, balls, strikes, awayScore, homeScore, isFinal }){
|
||||
function GameStateDisplay({inning, bases, isTopHalf, outs, count, awayScore, homeScore, isFinal }){
|
||||
return (
|
||||
<div className="gameState">
|
||||
<header>Scoreboard</header>
|
||||
@@ -21,7 +21,7 @@ function GameStateDisplay({inning, bases, isTopHalf, outs, balls, strikes, away
|
||||
<div>
|
||||
<Row>
|
||||
<Col><Inning inning={inning} isTopHalf={isTopHalf}></Inning></Col>
|
||||
<Col>{balls}-{strikes}</Col>
|
||||
<Col>{count.balls}-{count.strikes}</Col>
|
||||
<Col>{outs} outs</Col>
|
||||
<Col>
|
||||
<FontAwesomeIcon icon={fa1} className={`base ${bases[0] ? "occupied" : ""}`}></FontAwesomeIcon>
|
||||
|
||||
Reference in New Issue
Block a user