Implement Win/Loose highscore tables

This commit is contained in:
SilicaAndPina 2021-03-18 12:08:10 +13:00
parent 7686680c09
commit e58835467a
4 changed files with 26 additions and 4 deletions

View file

@ -233,8 +233,10 @@
"starting_game":"Starting up two player game with %PLAYERNAME%!", "starting_game":"Starting up two player game with %PLAYERNAME%!",
"game_closed":"Game Closed.", "game_closed":"Game Closed.",
"game_closed_other":"Game Closed by Other Player." "game_closed_other":"Game Closed by Other Player.",
"recorded_win":"Recorded a WIN at %GAMETITLE%.",
"recorded_loss":"Recorded a LOSS at %GAMETITLE%."
}, },
"player_interaction":{ "player_interaction":{
"players_here":"<B>Players Here:</B>", "players_here":"<B>Players Here:</B>",

View file

@ -51,6 +51,9 @@ namespace HISP.Game
public static string TwoPlayerGameClosed; public static string TwoPlayerGameClosed;
public static string TwoPlayerGameClosedOther; public static string TwoPlayerGameClosedOther;
public static string TwoPlayerRecordedWinFormat;
public static string TwoPlayerRecordedLossFormat;
// Trading // Trading
public static string TradeWithPlayerFormat; public static string TradeWithPlayerFormat;
@ -1054,7 +1057,14 @@ namespace HISP.Game
// Click // Click
public static string NothingInterestingHere; public static string NothingInterestingHere;
public static string Format2PlayerRecordLose(string gameTitle)
{
return TwoPlayerRecordedLossFormat.Replace("%GAMETITLE%", gameTitle);
}
public static string Format2PlayerRecordWin(string gameTitle)
{
return TwoPlayerRecordedWinFormat.Replace("%GAMETITLE%", gameTitle);
}
public static string Format2PlayerStartingGame(string playerName) public static string Format2PlayerStartingGame(string playerName)
{ {
return TwoPlayerStartingUpGameFormat.Replace("%PLAYERNAME%", playerName); return TwoPlayerStartingUpGameFormat.Replace("%PLAYERNAME%", playerName);
@ -2178,7 +2188,7 @@ namespace HISP.Game
} }
public static string FormatWinlooseListEntry(int ranking, int wins, int loose, string username, int totalplays) public static string FormatWinlooseListEntry(int ranking, int wins, int loose, string username, int totalplays)
{ {
return GameWinLooseHeaderFormat.Replace("%RANKING%", ranking.ToString("N0", CultureInfo.InvariantCulture)).Replace("%WINS%", wins.ToString("N0", CultureInfo.InvariantCulture)).Replace("%LOSES%", loose.ToString("N0", CultureInfo.InvariantCulture)).Replace("%USERNAME%", username).Replace("%TOTALPLAYS%", totalplays.ToString("N0", CultureInfo.InvariantCulture)); return GameWinLooseFormat.Replace("%RANKING%", ranking.ToString("N0", CultureInfo.InvariantCulture)).Replace("%WINS%", wins.ToString("N0", CultureInfo.InvariantCulture)).Replace("%LOSES%", loose.ToString("N0", CultureInfo.InvariantCulture)).Replace("%USERNAME%", username).Replace("%TOTALPLAYS%", totalplays.ToString("N0", CultureInfo.InvariantCulture));
} }
public static string FormatHighscoreHeader(string gameName) public static string FormatHighscoreHeader(string gameName)
{ {

View file

@ -891,6 +891,9 @@ namespace HISP.Server
Messages.TwoPlayerGameClosed = gameData.messages.meta.two_player.game_closed; Messages.TwoPlayerGameClosed = gameData.messages.meta.two_player.game_closed;
Messages.TwoPlayerGameClosedOther = gameData.messages.meta.two_player.game_closed_other; Messages.TwoPlayerGameClosedOther = gameData.messages.meta.two_player.game_closed_other;
Messages.TwoPlayerRecordedWinFormat = gameData.messages.meta.two_player.recorded_win;
Messages.TwoPlayerRecordedLossFormat = gameData.messages.meta.two_player.recorded_loss;
// Trade // Trade
Messages.TradeWithPlayerFormat = gameData.messages.meta.player_interaction.trade.trading_with; Messages.TradeWithPlayerFormat = gameData.messages.meta.player_interaction.trade.trading_with;
@ -1794,6 +1797,9 @@ namespace HISP.Server
Messages.GameHighScoreHeaderFormat = gameData.messages.meta.highscores.game_highscore_header; Messages.GameHighScoreHeaderFormat = gameData.messages.meta.highscores.game_highscore_header;
Messages.GameHighScoreFormat = gameData.messages.meta.highscores.game_highscore_format; Messages.GameHighScoreFormat = gameData.messages.meta.highscores.game_highscore_format;
Messages.GameWinLooseHeaderFormat = gameData.messages.meta.highscores.game_winloose_header;
Messages.GameWinLooseFormat = gameData.messages.meta.highscores.game_winloose_format;
Messages.GameBestTimeHeaderFormat = gameData.messages.meta.highscores.game_besttime_header; Messages.GameBestTimeHeaderFormat = gameData.messages.meta.highscores.game_besttime_header;
Messages.GameBestTimeFormat = gameData.messages.meta.highscores.game_besttime_format; Messages.GameBestTimeFormat = gameData.messages.meta.highscores.game_besttime_format;

View file

@ -4047,10 +4047,14 @@ namespace HISP.Server
if(pmethod == PacketBuilder.WINLOOSE_WIN) if(pmethod == PacketBuilder.WINLOOSE_WIN)
{ {
sender.LoggedinUser.Highscores.Win(gameTitle); sender.LoggedinUser.Highscores.Win(gameTitle);
byte[] winMsg = PacketBuilder.CreateChat(Messages.Format2PlayerRecordWin(gameTitle), PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(winMsg);
} }
else if(pmethod == PacketBuilder.WINLOOSE_LOOSE) else if(pmethod == PacketBuilder.WINLOOSE_LOOSE)
{ {
sender.LoggedinUser.Highscores.Loose(gameTitle); sender.LoggedinUser.Highscores.Loose(gameTitle);
byte[] looseMsg = PacketBuilder.CreateChat(Messages.Format2PlayerRecordLose(gameTitle), PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(looseMsg);
} }
if (sender.LoggedinUser.Highscores.HighscoreList.Length >= 30) if (sender.LoggedinUser.Highscores.HighscoreList.Length >= 30)