|
6 | 6 | import com.modnmetl.modnvote.config.MessageService; |
7 | 7 | import com.modnmetl.modnvote.domain.Poll; |
8 | 8 | import com.modnmetl.modnvote.domain.PollOption; |
| 9 | +import com.modnmetl.modnvote.presentation.ResultDisplayFormatter; |
9 | 10 | import com.modnmetl.modnvote.publication.WitnessPublicationService; |
10 | 11 | import com.modnmetl.modnvote.service.BallotService; |
11 | 12 | import com.modnmetl.modnvote.service.IntegrityVerificationService; |
@@ -1019,48 +1020,9 @@ private void handleResultDisplay(CommandSender sender, |
1019 | 1020 | long pollId) throws PollServiceException { |
1020 | 1021 | ResultService.PollResult result = resultService.getPollResult(pollId); |
1021 | 1022 |
|
1022 | | - sender.sendMessage(messages.formatRaw("result.header", Map.of( |
1023 | | - "poll_id", String.valueOf(result.pollId()), |
1024 | | - "title", result.pollTitle() |
1025 | | - ))); |
1026 | | - sender.sendMessage(messages.formatRaw("result.total_votes", Map.of( |
1027 | | - "total_votes", String.valueOf(result.totalVotes()) |
1028 | | - ))); |
1029 | | - |
1030 | | - if (result.pollType() == PollType.YES_NO) { |
1031 | | - Map<String, Integer> countsByKey = new HashMap<>(); |
1032 | | - for (ResultService.OptionTally tally : result.tallies()) { |
1033 | | - countsByKey.put(tally.optionKey().toLowerCase(Locale.ROOT), tally.votes()); |
1034 | | - } |
1035 | | - |
1036 | | - int yesVotes = countsByKey.getOrDefault("yes", 0); |
1037 | | - int noVotes = countsByKey.getOrDefault("no", 0); |
1038 | | - |
1039 | | - sender.sendMessage(messages.formatRaw("result.yes_votes", Map.of( |
1040 | | - "yes_votes", String.valueOf(yesVotes) |
1041 | | - ))); |
1042 | | - sender.sendMessage(messages.formatRaw("result.no_votes", Map.of( |
1043 | | - "no_votes", String.valueOf(noVotes) |
1044 | | - ))); |
1045 | | - return; |
| 1023 | + for (String line : ResultDisplayFormatter.formatInGame(result)) { |
| 1024 | + sender.sendMessage(line); |
1046 | 1025 | } |
1047 | | - |
1048 | | - if (result.pollType() == PollType.RANKED_SINGLE_WINNER) { |
1049 | | - sender.sendMessage(messages.formatRaw("result.ranked_winner", Map.of( |
1050 | | - "winner", result.winnerName() == null ? "No winner determined" : result.winnerName() |
1051 | | - ))); |
1052 | | - sender.sendMessage(messages.getRaw("result.first_preference_header")); |
1053 | | - |
1054 | | - for (ResultService.OptionTally tally : result.tallies()) { |
1055 | | - sender.sendMessage(messages.formatRaw("result.tally_entry", Map.of( |
1056 | | - "option_name", tally.optionName(), |
1057 | | - "votes", String.valueOf(tally.votes()) |
1058 | | - ))); |
1059 | | - } |
1060 | | - return; |
1061 | | - } |
1062 | | - |
1063 | | - sender.sendMessage(messages.get("result.unsupported_type")); |
1064 | 1026 | } |
1065 | 1027 |
|
1066 | 1028 | private List<PollOption> findOptions(long pollId) throws PollServiceException { |
|
0 commit comments