From d297d9ba0e8733cd7498092a760656c028d79dd1 Mon Sep 17 00:00:00 2001 From: Psycast Date: Mon, 16 Dec 2024 16:43:32 -0330 Subject: [PATCH] MP: Add match result text for ties. --- .../chatlog/MPChatLogEntryMatchResults.as | 6 ++- src/classes/mp/mode/ffr/MPMatchResultsFFR.as | 40 +++++++++++++------ src/classes/mp/mode/ffr/MPMatchResultsTeam.as | 5 +++ src/classes/mp/mode/ffr/MPMatchResultsUser.as | 5 +++ src/game/results/GameResultFFRView.as | 5 ++- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/classes/mp/components/chatlog/MPChatLogEntryMatchResults.as b/src/classes/mp/components/chatlog/MPChatLogEntryMatchResults.as index 5f2012a4..e4652a1d 100644 --- a/src/classes/mp/components/chatlog/MPChatLogEntryMatchResults.as +++ b/src/classes/mp/components/chatlog/MPChatLogEntryMatchResults.as @@ -37,7 +37,11 @@ package classes.mp.components.chatlog this.graphics.endFill(); new Text(this, 10, 7, _lang.string("mp_room_ffr_match_end"), 10, "#c3c3c3").setAreaParams(width - 120, 22); - new Text(this, 9, 25, sprintf(_lang.string("mp_room_ffr_match_end_results"), {"winner": results.winnerText}), 12).setAreaParams(width - 110, 22); + + if (results.wasTie) + new Text(this, 9, 25, sprintf(results.winnerText), 12).setAreaParams(width - 110, 22); + else + new Text(this, 9, 25, sprintf(_lang.string("mp_room_ffr_match_end_results"), {"winner": results.winnerText}), 12).setAreaParams(width - 110, 22); btn = new BoxButton(this, width - 96, 14, 85, 26, _lang.string("mp_room_ffr_match_end_view"), 11, e_viewResults); diff --git a/src/classes/mp/mode/ffr/MPMatchResultsFFR.as b/src/classes/mp/mode/ffr/MPMatchResultsFFR.as index a90c8376..9738650f 100644 --- a/src/classes/mp/mode/ffr/MPMatchResultsFFR.as +++ b/src/classes/mp/mode/ffr/MPMatchResultsFFR.as @@ -1,5 +1,6 @@ package classes.mp.mode.ffr { + import classes.Language; import classes.Playlist; import classes.SongInfo; import classes.mp.MPSong; @@ -9,6 +10,8 @@ package classes.mp.mode.ffr public class MPMatchResultsFFR { + private static const _lang:Language = Language.instance; + public var room:MPRoomFFR; public var index:int; @@ -19,6 +22,7 @@ package classes.mp.mode.ffr public var users:Vector. = new []; private var _winnerText:String; + private var _wasTie:Boolean = false; public function MPMatchResultsFFR(room:MPRoomFFR, index:int):void { @@ -158,6 +162,11 @@ package classes.mp.mode.ffr return _winnerText } + public function get wasTie():Boolean + { + return _wasTie; + } + private function _generateWinnerText():String { if ((teamMode && teams.length == 0) || (!teamMode && users.length == 0)) @@ -165,8 +174,7 @@ package classes.mp.mode.ffr return "Missingno????"; } - var winnerText:String = ""; - + // Teams if (teamMode) { const teamList:Vector. = teams.filter(function(item:MPMatchResultsTeam, index:int, vec:Vector.):Boolean @@ -174,22 +182,28 @@ package classes.mp.mode.ffr return item.position == 1; }); - for each (var team:MPMatchResultsTeam in teamList) - winnerText += team.name + ", "; + if (teamList.length == teams.length && teams.length > 1) + { + _wasTie = true; + return _lang.string("mp_match_result_tie_team"); + } + + return teamList.join(", "); } - else + + // Users + const userList:Vector. = users.filter(function(item:MPMatchResultsUser, index:int, vec:Vector.):Boolean { - var userWinner:String = ""; - const userList:Vector. = users.filter(function(item:MPMatchResultsUser, index:int, vec:Vector.):Boolean - { - return item.position == 1; - }); + return item.position == 1; + }); - for each (var user:MPMatchResultsUser in userList) - winnerText += user.name + ", "; + if (userList.length == users.length && users.length > 1) + { + _wasTie = true; + return _lang.string("mp_match_result_tie_user"); } - return winnerText.substr(0, winnerText.length - 2); + return userList.join(", "); } } } diff --git a/src/classes/mp/mode/ffr/MPMatchResultsTeam.as b/src/classes/mp/mode/ffr/MPMatchResultsTeam.as index ec927734..6d1e2aae 100644 --- a/src/classes/mp/mode/ffr/MPMatchResultsTeam.as +++ b/src/classes/mp/mode/ffr/MPMatchResultsTeam.as @@ -23,5 +23,10 @@ package classes.mp.mode.ffr if (data.position != undefined) this.position = data.position; } + + public function toString():String + { + return name; + } } } diff --git a/src/classes/mp/mode/ffr/MPMatchResultsUser.as b/src/classes/mp/mode/ffr/MPMatchResultsUser.as index 9514fb06..3f90c3f0 100644 --- a/src/classes/mp/mode/ffr/MPMatchResultsUser.as +++ b/src/classes/mp/mode/ffr/MPMatchResultsUser.as @@ -47,5 +47,10 @@ package classes.mp.mode.ffr score.options = new GameOptions(); score.options.settingsDecode(data.settings); } + + override public function toString():String + { + return name; + } } } diff --git a/src/game/results/GameResultFFRView.as b/src/game/results/GameResultFFRView.as index 22519556..ebb97fd8 100644 --- a/src/game/results/GameResultFFRView.as +++ b/src/game/results/GameResultFFRView.as @@ -53,7 +53,10 @@ package game.results addChild(resultsDisplay); // Text - header = new Text(this, 20, 10, sprintf(_lang.string("mp_room_ffr_match_end_results"), {"winner": matchDetails.winnerText}), 16, "#E2FEFF"); + if (matchDetails.wasTie) + header = new Text(this, 20, 10, matchDetails.winnerText, 16, "#E2FEFF"); + else + header = new Text(this, 20, 10, sprintf(_lang.string("mp_room_ffr_match_end_results"), {"winner": matchDetails.winnerText}), 16, "#E2FEFF"); header.setAreaParams(420, 26); time = new Text(this, 576, 10, resultsTime, 16, "#E2FEFF");