Skip to content

Commit

Permalink
[#6] feat: Modify Game to write strike, ball count into pitchHistory
Browse files Browse the repository at this point in the history
pitchHistory 기록할 때, 당시의 투구상황을 기록하도록 수정했습니다.
  • Loading branch information
isaac56 committed May 7, 2021
1 parent 4d1b8c4 commit f5a8bf4
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,29 @@ private void initializeBattingHistory(Team team) {
}

public void proceedStrike(Team awayTeam, Team homeTeam) {
//카운트 증가
this.strikeCount++;

//기록할 pitch history 생성
PitchHistory pitchHistory = new PitchHistory(acquireDefenseTeamId(), pitcherUniformNumber,
acquireAttackTeamId(), batterUniformNumber, PitchResult.STRIKE);
acquireAttackTeamId(), batterUniformNumber, PitchResult.STRIKE, this.strikeCount, this.ballCount);
//현재 이닝에 pitch history 기록
acquireCurrentInning().pitchHistoryList.add(pitchHistory);

//카운트 증가
this.strikeCount++;
//삼진 아웃 처리
if (strikeCount == 3) {
proceedOut(awayTeam, homeTeam);
}
}

public void proceedBall(Team awayTeam, Team homeTeam) {
//카운트 증가
this.ballCount++;

//기록할 pitch history 생성
PitchHistory pitchHistory = new PitchHistory(acquireDefenseTeamId(), pitcherUniformNumber,
acquireAttackTeamId(), batterUniformNumber, PitchResult.BALL);
acquireAttackTeamId(), batterUniformNumber, PitchResult.BALL, this.strikeCount, this.ballCount);
//현재 이닝에 pitch history 기록
acquireCurrentInning().pitchHistoryList.add(pitchHistory);

//카운트 증가
this.ballCount++;
//볼넷일 경우 출루하고 다음 타자 등판
if (ballCount == 4) {
sendBatterOnBase();
Expand All @@ -110,11 +108,15 @@ public void proceedBall(Team awayTeam, Team homeTeam) {
}

public void proceedHit(Team awayTeam, Team homeTeam) {
Team attackTeam = acquireAttackTeam(awayTeam, homeTeam);
//기록할 pitch history 생성
PitchHistory pitchHistory = new PitchHistory(acquireDefenseTeamId(), pitcherUniformNumber,
acquireAttackTeamId(), batterUniformNumber, PitchResult.BALL, this.strikeCount, this.ballCount);
//현재 이닝에 pitch history 기록
acquireCurrentInning().pitchHistoryList.add(pitchHistory);

//타자의 battingHistory 에 타수 카운트 추가
String battingHistoryKey = BattingHistory.acquireKeyInGame(attackTeam.getId(), batterUniformNumber);
BattingHistory battingHistory = battingHistoryMap.get(battingHistoryKey);
Team attackTeam = acquireAttackTeam(awayTeam, homeTeam);
BattingHistory battingHistory = acquireBattingHistory(attackTeam.getId(), batterUniformNumber);
battingHistory.plusHits();

//타자 출루
Expand Down

0 comments on commit f5a8bf4

Please sign in to comment.