mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +12:00
Add report function and player list
This commit is contained in:
parent
29f5ad0ec2
commit
50db63729d
11 changed files with 402 additions and 62 deletions
47
Horse Isle Server/Horse Isle Server/Game/AbuseReport.cs
Normal file
47
Horse Isle Server/Horse Isle Server/Game/AbuseReport.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System.Collections.Generic;
|
||||
namespace HISP.Game
|
||||
{
|
||||
class AbuseReport
|
||||
{
|
||||
public struct ReportReason
|
||||
{
|
||||
public string Id;
|
||||
public string Name;
|
||||
public string Meta;
|
||||
}
|
||||
private static List<ReportReason> reportReasons = new List<ReportReason>();
|
||||
|
||||
public static ReportReason[] ReportReasons
|
||||
{
|
||||
get
|
||||
{
|
||||
return reportReasons.ToArray();
|
||||
}
|
||||
}
|
||||
public static bool DoesReasonExist(string id)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetReasonById(id);
|
||||
return true;
|
||||
}
|
||||
catch(KeyNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static ReportReason GetReasonById(string id)
|
||||
{
|
||||
foreach(ReportReason reason in ReportReasons)
|
||||
{
|
||||
if (reason.Id == id)
|
||||
return reason;
|
||||
}
|
||||
throw new KeyNotFoundException("No reason of: " + id + " Found.");
|
||||
}
|
||||
public static void AddReason(ReportReason reason)
|
||||
{
|
||||
reportReasons.Add(reason);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -221,7 +221,15 @@ namespace HISP.Game
|
|||
public static string BeatHighscoreFormat;
|
||||
public static string BeatBestTimeFormat;
|
||||
|
||||
// Abuse Report
|
||||
public static string AbuseReportMetaFormat;
|
||||
public static string AbuseReportReasonFormat;
|
||||
public static string AbuseReportPlayerNotFoundFormat;
|
||||
public static string AbuseReportFiled;
|
||||
public static string AbuseReportProvideValidReason;
|
||||
|
||||
// Player List
|
||||
public static string PlayerListAbuseReport;
|
||||
public static string PlayerListHeader;
|
||||
public static string PlayerListSelectFromFollowing;
|
||||
public static string PlayerListOfBuddiesFormat;
|
||||
|
@ -230,7 +238,6 @@ namespace HISP.Game
|
|||
public static string PlayerListOfPlayersAlphabetically;
|
||||
public static string PlayerListMapAllBuddiesForamt;
|
||||
public static string PlayerListMapAllPlayersFormat;
|
||||
public static string PlayerListAbuseReport;
|
||||
|
||||
public static int ThreeMonthSubscripitionIcon;
|
||||
public static int YearSubscriptionIcon;
|
||||
|
@ -244,6 +251,13 @@ namespace HISP.Game
|
|||
public static string BuddyListOfflineBuddys;
|
||||
public static string BuddyListOfflineBuddyEntryFormat;
|
||||
|
||||
public static string NearbyPlayersListHeader;
|
||||
public static string PlayerListEntryFormat;
|
||||
|
||||
public static string PlayerListAllHeader;
|
||||
public static string PlayerListAllAlphabeticalHeader;
|
||||
|
||||
public static string PlayerListIdle;
|
||||
public static string PlayerListIconFormat;
|
||||
public static string PlayerListIconInformation;
|
||||
|
||||
|
@ -281,10 +295,30 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
|
||||
public static string FormatAbuseReportPlayerNotFound(string username)
|
||||
{
|
||||
return AbuseReportPlayerNotFoundFormat.Replace("%USERNAME%", username);
|
||||
}
|
||||
public static string FormatAbuseReportMetaPage(string reasonsMeta)
|
||||
{
|
||||
return AbuseReportMetaFormat.Replace("%REASONS%", reasonsMeta);
|
||||
}
|
||||
|
||||
public static string FormatAbuseReportReason(string id, string name)
|
||||
{
|
||||
return AbuseReportReasonFormat.Replace("%ID%", id).Replace("%NAME%", name);
|
||||
}
|
||||
public static string FormatIconFormat(int iconId)
|
||||
{
|
||||
return PlayerListIconFormat.Replace("%ICON%", iconId.ToString());
|
||||
}
|
||||
|
||||
public static string FormatPlayerEntry(string iconFormat, string username, int userId, int time, int x, int y, bool idle)
|
||||
{
|
||||
string xy = FormatMapLocation(x, y);
|
||||
return PlayerListEntryFormat.Replace("%ICONFORMAT%", iconFormat).Replace("%USERNAME%", username).Replace("%PLAYERID%", userId.ToString()).Replace("%TIME%", time.ToString("N0")).Replace("%MAPXY%", xy).Replace("%IDLE%", idle ? PlayerListIdle : "");
|
||||
}
|
||||
public static string FormatOnlineBuddyEntry(string iconFormat, string username, int userId, int time, int x, int y)
|
||||
{
|
||||
string xy = FormatMapLocation(x, y);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -409,6 +410,98 @@ namespace HISP.Game
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static string BuildNearbyList(User user)
|
||||
{
|
||||
string message = Messages.NearbyPlayersListHeader;
|
||||
User[] nearbyUsers = GameServer.GetNearbyUsers(user.X, user.Y, false, true);
|
||||
foreach (User nearbyUser in nearbyUsers)
|
||||
{
|
||||
if (nearbyUser.Stealth)
|
||||
continue;
|
||||
|
||||
if (nearbyUser.Id == user.Id)
|
||||
continue;
|
||||
|
||||
|
||||
int icon = nearbyUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, nearbyUser.Username, nearbyUser.Id, (DateTime.UtcNow - nearbyUser.LoginTime).Minutes, nearbyUser.X, nearbyUser.Y, nearbyUser.Idle);
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildPlayerListAlphabetical()
|
||||
{
|
||||
string message = Messages.PlayerListAllAlphabeticalHeader;
|
||||
GameClient[] clients = GameServer.ConnectedClients;
|
||||
List<User> onlineUsers = new List<User>();
|
||||
|
||||
foreach (GameClient client in clients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Stealth)
|
||||
continue;
|
||||
onlineUsers.Add(client.LoggedinUser);
|
||||
}
|
||||
}
|
||||
|
||||
onlineUsers = onlineUsers.OrderBy(o => o.Username).ToList();
|
||||
|
||||
foreach (User onlineUser in onlineUsers)
|
||||
{
|
||||
|
||||
int icon = onlineUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, onlineUser.Username, onlineUser.Id, (DateTime.UtcNow - onlineUser.LoginTime).Minutes, onlineUser.X, onlineUser.Y, onlineUser.Idle);
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildPlayerList()
|
||||
{
|
||||
string message = Messages.PlayerListAllHeader;
|
||||
GameClient[] clients = GameServer.ConnectedClients;
|
||||
foreach(GameClient client in clients)
|
||||
{
|
||||
if(client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Stealth)
|
||||
continue;
|
||||
|
||||
int icon = client.LoggedinUser.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatPlayerEntry(iconFormat, client.LoggedinUser.Username, client.LoggedinUser.Id, (DateTime.UtcNow - client.LoggedinUser.LoginTime).Minutes, client.LoggedinUser.X, client.LoggedinUser.Y, client.LoggedinUser.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
message += Messages.PlayerListIconInformation;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string BuildBuddyList(User user)
|
||||
{
|
||||
string message = Messages.BuddyListHeader;
|
||||
|
@ -417,27 +510,14 @@ namespace HISP.Game
|
|||
try
|
||||
{
|
||||
User friend = GameServer.GetUserById(id);
|
||||
int icon = -1;
|
||||
if (friend.NewPlayer)
|
||||
icon = Messages.NewUserIcon;
|
||||
if (friend.Subscribed)
|
||||
{
|
||||
int months = (DateTime.UtcNow.Month - friend.SubscribedUntil.Month) + 12 * (DateTime.UtcNow.Year - friend.SubscribedUntil.Year);
|
||||
if (months <= 1)
|
||||
icon = Messages.MonthSubscriptionIcon;
|
||||
else if (months <= 3)
|
||||
icon = Messages.ThreeMonthSubscripitionIcon;
|
||||
else
|
||||
icon = Messages.YearSubscriptionIcon;
|
||||
}
|
||||
if (friend.Moderator)
|
||||
icon = Messages.ModeratorIcon;
|
||||
if (friend.Administrator)
|
||||
icon = Messages.AdminIcon;
|
||||
if (friend.Stealth)
|
||||
continue;
|
||||
|
||||
int icon = friend.GetPlayerListIcon();
|
||||
string iconFormat = "";
|
||||
if (icon != -1)
|
||||
iconFormat = Messages.FormatIconFormat(icon);
|
||||
|
||||
message += Messages.FormatOnlineBuddyEntry(iconFormat, friend.Username, friend.Id, (DateTime.UtcNow - friend.LoginTime).Minutes, friend.X, friend.Y);
|
||||
|
||||
}
|
||||
|
@ -529,6 +609,15 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string BuildAbuseReportPage()
|
||||
{
|
||||
string reportReasons = "";
|
||||
foreach(AbuseReport.ReportReason reason in AbuseReport.ReportReasons)
|
||||
{
|
||||
reportReasons += Messages.FormatAbuseReportReason(reason.Id, reason.Name);
|
||||
}
|
||||
return Messages.FormatAbuseReportMetaPage(reportReasons);
|
||||
}
|
||||
public static string BuildPlayerList(User user)
|
||||
{
|
||||
string message = "";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue