mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +12:00
Add highscores and best times.
This commit is contained in:
parent
0c99624f63
commit
de9dfaf362
9 changed files with 291 additions and 37 deletions
|
@ -163,6 +163,17 @@ namespace HISP.Game
|
|||
public static string SellButton;
|
||||
public static string SellAllButton;
|
||||
|
||||
// Highscore List
|
||||
public static string HighscoreHeaderMeta;
|
||||
public static string HighscoreFormat;
|
||||
public static string BestTimeFormat;
|
||||
|
||||
public static string GameBestTimeFormat;
|
||||
public static string GameBestTimeHeaderFormat;
|
||||
public static string GameHighScoreHeaderFormat;
|
||||
public static string GameHighScoreFormat;
|
||||
|
||||
|
||||
// Shop
|
||||
public static string ThingsIAmSelling;
|
||||
public static string ThingsYouSellMe;
|
||||
|
@ -229,6 +240,30 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatBestTimeHeader(string gameName)
|
||||
{
|
||||
return GameBestTimeHeaderFormat.Replace("%GAMETITLE%", gameName);
|
||||
}
|
||||
public static string FormatBestTimeListEntry(int ranking, int score, string username, int totalplays)
|
||||
{
|
||||
return GameBestTimeFormat.Replace("%RANKING%", ranking.ToString("N0")).Replace("%SCORE%", score.ToString().Insert(score.ToString().Length - 2, ".")).Replace("%USERNAME%", username).Replace("%TOTALPLAYS%", totalplays.ToString("N0"));
|
||||
}
|
||||
public static string FormatHighscoreHeader(string gameName)
|
||||
{
|
||||
return GameHighScoreHeaderFormat.Replace("%GAMETITLE%", gameName);
|
||||
}
|
||||
public static string FormatHighscoreListEntry(int ranking, int score, string username, int totalplays)
|
||||
{
|
||||
return GameHighScoreFormat.Replace("%RANKING%", ranking.ToString("N0")).Replace("%SCORE%", score.ToString("N0")).Replace("%USERNAME%", username).Replace("%TOTALPLAYS%", totalplays.ToString("N0"));
|
||||
}
|
||||
public static string FormatHighscoreStat(string gameTitle, int ranking, int score, int totalplays)
|
||||
{
|
||||
return HighscoreFormat.Replace("%GAMETITLE%", gameTitle).Replace("%RANKING%", ranking.ToString("N0")).Replace("%SCORE%", score.ToString("N0")).Replace("%TOTALPLAYS%", totalplays.ToString("N0"));
|
||||
}
|
||||
public static string FormatBestTimeStat(string gameTitle, int ranking, int score, int totalplays)
|
||||
{
|
||||
return BestTimeFormat.Replace("%GAMETITLE%", gameTitle).Replace("%RANKING%", ranking.ToString("N0")).Replace("%SCORE%", score.ToString()).Replace("%TOTALPLAYS%", totalplays.ToString("N0"));
|
||||
}
|
||||
public static string FormatMoneyEarnedMessage(int money)
|
||||
{
|
||||
return YouEarnedMoneyFormat.Replace("%MONEY%", money.ToString("N0"));
|
||||
|
|
|
@ -225,7 +225,6 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
|
||||
public static string SelectPlayerStatFormat(int statValue)
|
||||
{
|
||||
int curValue = 1000;
|
||||
|
@ -240,7 +239,55 @@ namespace HISP.Game
|
|||
}
|
||||
throw new Exception("A mathematically impossible error occured. please check wether the laws of physics still apply.");
|
||||
}
|
||||
|
||||
|
||||
public static string BuildTopHighscores(string gameName)
|
||||
{
|
||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
||||
if (scores.Length <= 0)
|
||||
return "No scores recorded.";
|
||||
string message = "";
|
||||
|
||||
message += Messages.FormatHighscoreHeader(gameName);
|
||||
|
||||
for (int i = 0; i < scores.Length; i++)
|
||||
{
|
||||
message += Messages.FormatHighscoreListEntry(i+1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildTopTimes(string gameName)
|
||||
{
|
||||
Highscore.HighscoreTableEntry[] scores = Database.GetTopScores(gameName, 20);
|
||||
if (scores.Length <= 0)
|
||||
return "No times recorded.";
|
||||
string message = "";
|
||||
|
||||
message += Messages.FormatBestTimeHeader(gameName);
|
||||
|
||||
for (int i = 0; i < scores.Length; i++)
|
||||
{
|
||||
message += Messages.FormatBestTimeListEntry(i+1, scores[i].Score, Database.GetUsername(scores[i].UserId), scores[i].TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildMinigameRankingsForUser(User user)
|
||||
{
|
||||
string message = Messages.HighscoreHeaderMeta;
|
||||
foreach(Highscore.HighscoreTableEntry highscore in user.Highscores.HighscoreList)
|
||||
{
|
||||
if (highscore.Type == "SCORE")
|
||||
message += Messages.FormatHighscoreStat(highscore.GameName, Database.GetRanking(highscore.Score, highscore.GameName), highscore.Score, highscore.TimesPlayed);
|
||||
else if(highscore.Type == "TIME")
|
||||
message += Messages.FormatBestTimeStat(highscore.GameName, Database.GetRanking(highscore.Score, highscore.GameName), highscore.Score, highscore.TimesPlayed);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildPrivateNotes(User user)
|
||||
{
|
||||
string message = "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue