Skip to content

Commit

Permalink
MP: Add match result text for ties.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycast committed Dec 16, 2024
1 parent e9ee62a commit d297d9b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
40 changes: 27 additions & 13 deletions src/classes/mp/mode/ffr/MPMatchResultsFFR.as
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package classes.mp.mode.ffr
{
import classes.Language;
import classes.Playlist;
import classes.SongInfo;
import classes.mp.MPSong;
Expand All @@ -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;
Expand All @@ -19,6 +22,7 @@ package classes.mp.mode.ffr
public var users:Vector.<MPMatchResultsUser> = new <MPMatchResultsUser>[];

private var _winnerText:String;
private var _wasTie:Boolean = false;

public function MPMatchResultsFFR(room:MPRoomFFR, index:int):void
{
Expand Down Expand Up @@ -158,38 +162,48 @@ 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))
{
return "Missingno????";
}

var winnerText:String = "";

// Teams
if (teamMode)
{
const teamList:Vector.<MPMatchResultsTeam> = teams.filter(function(item:MPMatchResultsTeam, index:int, vec:Vector.<MPMatchResultsTeam>):Boolean
{
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.<MPMatchResultsUser> = users.filter(function(item:MPMatchResultsUser, index:int, vec:Vector.<MPMatchResultsUser>):Boolean
{
var userWinner:String = "";
const userList:Vector.<MPMatchResultsUser> = users.filter(function(item:MPMatchResultsUser, index:int, vec:Vector.<MPMatchResultsUser>):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(", ");
}
}
}
5 changes: 5 additions & 0 deletions src/classes/mp/mode/ffr/MPMatchResultsTeam.as
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ package classes.mp.mode.ffr
if (data.position != undefined)
this.position = data.position;
}

public function toString():String
{
return name;
}
}
}
5 changes: 5 additions & 0 deletions src/classes/mp/mode/ffr/MPMatchResultsUser.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
5 changes: 4 additions & 1 deletion src/game/results/GameResultFFRView.as
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d297d9b

Please sign in to comment.