Skip to content

Commit

Permalink
[#6] fix: Use sendBatterOnPlate method always when change batter
Browse files Browse the repository at this point in the history
1. sendBatterOnPlate 메소드로 타석에 타자를 올리면 타자의 타석 수도 올려줍니다.
2. 게임 첫시작이나 다음이닝 변경 시, sendBatterOnPlate 없이 this.batterUniformNumber만 바꿔주고 있어서 타석 수가 올라가지 않고 있었습니다.
  • Loading branch information
isaac56 committed May 7, 2021
1 parent a817497 commit 65cd76b
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public class Game {
public Game(Team awayTeam, Team homeTeam) {
this.awayTeamId = awayTeam.getId();
this.homeTeamId = homeTeam.getId();
this.pitcherUniformNumber = awayTeam.getFirstPlayerUniformNumber();
this.batterUniformNumber = homeTeam.getFirstPlayerUniformNumber();

initializeBattingHistory(awayTeam);
initializeBattingHistory(homeTeam);

this.pitcherUniformNumber = homeTeam.getFirstPlayerUniformNumber();
sendBatterOnPlate(awayTeamId, awayTeam.getFirstPlayerUniformNumber());

this.currentInning = 1;
this.currentHalves = Halves.TOP;
this.inningMap.put(Inning.acquireKeyInGame(currentInning, currentHalves), new Inning(currentInning, currentHalves));
Expand Down Expand Up @@ -102,7 +102,7 @@ public void proceedBall(Team awayTeam, Team homeTeam) {
sendBatterOnBase();

Team attackTeam = acquireAttackTeam(awayTeam, homeTeam);
sendBatterOnPlate(attackTeam);
sendBatterOnPlate(attackTeam.getId(), attackTeam.getNextPlayerUniformNumber(batterUniformNumber));
}
}

Expand All @@ -122,7 +122,7 @@ public void proceedHit(Team awayTeam, Team homeTeam) {
sendBatterOnBase();

//타석에 다음 타자 등판
sendBatterOnPlate(attackTeam);
sendBatterOnPlate(attackTeam.getId(), attackTeam.getNextPlayerUniformNumber(batterUniformNumber));
}

public int getTotalScore(Halves halves) {
Expand Down Expand Up @@ -174,7 +174,7 @@ private void proceedOut(Team awayTeam, Team homeTeam) {

//타석에 다음 타자 등판
Team attackTeam = acquireAttackTeam(awayTeam, homeTeam);
sendBatterOnPlate(attackTeam);
sendBatterOnPlate(attackTeam.getId(), attackTeam.getNextPlayerUniformNumber(batterUniformNumber));
}

private void sendBatterOnBase() {
Expand All @@ -189,7 +189,7 @@ private void sendBatterOnBase() {
this.base1UniformNumber = this.batterUniformNumber;
}

private void goToNextInning(Team homeTeam, Team awayTeam) {
private void goToNextInning(Team awayTeam, Team homeTeam) {
//카운트 초기화
this.strikeCount = 0;
this.ballCount = 0;
Expand All @@ -204,7 +204,7 @@ private void goToNextInning(Team homeTeam, Team awayTeam) {
}
this.inningMap.put(Inning.acquireKeyInGame(currentInning, currentHalves), new Inning(currentInning, currentHalves));

//현재 이닝의 공격팀 수비팀 설정
//현재 이닝의 공격팀 수비팀 확인
Team attackTeam = acquireAttackTeam(awayTeam, homeTeam);
Team defenseTeam = acquireDefenseTeam(awayTeam, homeTeam);

Expand All @@ -213,17 +213,15 @@ private void goToNextInning(Team homeTeam, Team awayTeam) {
//공격팀 타자 설정 (직전 투수의 다음 등번호가 타자가 됨)
int nextBatterUniformNumber = attackTeam.getNextPlayerUniformNumber(pitcherUniformNumber);
this.pitcherUniformNumber = nextPitcherUniformNumber;
this.batterUniformNumber = nextBatterUniformNumber;
sendBatterOnPlate(attackTeam.getId(), nextBatterUniformNumber);
}

private void sendBatterOnPlate(Team attackTeam) {
private void sendBatterOnPlate(int batterTeamId, int nextBatterUniformNumber) {
//카운트 초기화
this.strikeCount = 0;
this.ballCount = 0;

//타석에 다음 선수 등판
int batterTeamId = attackTeam.getId();
int nextBatterUniformNumber = attackTeam.getNextPlayerUniformNumber(batterUniformNumber);
this.batterUniformNumber = nextBatterUniformNumber;

//선수의 BatterHistory 에 타석 카운트 추가
Expand Down

0 comments on commit 65cd76b

Please sign in to comment.