Skip to content

Commit 27ee47a

Browse files
committed
Add match commentary for rebound from goalkeeper save
Refactor: extract rebound commentary to its own method
1 parent 162d047 commit 27ee47a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main/java/org/openengine/mpn/Match.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,15 @@ private String getCommentary(ProcessUnit record) {
115115
commentary.append(". Attempt is blocked...");
116116
switch (statement.getGoalAttemptOutcome()) {
117117
case CORNER -> commentary.append("corner.");
118-
case ATTACK, POSSESSION -> {
119-
commentary.append(teamName);
120-
commentary.append(" on the rebound at pitch position ");
121-
commentary.append(outcomePitchPosition);
122-
attachPitchPositionDescription(outcomePitchPosition, commentary);
123-
}
118+
case ATTACK, POSSESSION -> appendReboundCommentary(commentary, teamName, outcomePitchPosition);
124119
case GOALKEEPER -> commentary.append("goalkeeper has the ball");
125120
}
126121
}
127122
case SAVE -> {
128-
commentary.append("...saved by the goalkeeper.");
123+
commentary.append("...saved by the goalkeeper. ");
129124
switch (statement.getGoalAttemptOutcome()) {
130125
case CORNER -> commentary.append(" Corner.");
126+
case ATTACK -> appendReboundCommentary(commentary, teamName, outcomePitchPosition);
131127
}
132128
}
133129
}
@@ -231,6 +227,13 @@ private String getCommentary(ProcessUnit record) {
231227
return commentary.toString();
232228
}
233229

230+
private static void appendReboundCommentary(StringBuilder commentary, String teamName, PitchPosition outcomePitchPosition) {
231+
commentary.append(teamName);
232+
commentary.append(" on the rebound at pitch position ");
233+
commentary.append(outcomePitchPosition);
234+
attachPitchPositionDescription(outcomePitchPosition, commentary);
235+
}
236+
234237
private static void attachPitchPositionDescription(PitchPosition pitchPosition, StringBuilder commentary) {
235238
if (pitchPosition == null) return;
236239
commentary.append(" (");

0 commit comments

Comments
 (0)