mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-10 23:25:41 +12:00
implement basic player list..
more later
This commit is contained in:
parent
3ae6d61034
commit
c690e3f3a4
8 changed files with 203 additions and 6 deletions
|
@ -118,6 +118,42 @@
|
|||
"completed":"<FONT COLOR='#008800'><B>COMPLETED</B></FONT>",
|
||||
"footer_format":"<BR>You have completed <B>%TOTALCOMPLETED%</B> of <B>%TOTALQUESTS%</B> total adventures (<B>%TOTALPERCENT%%</B>)<BR>You have earned <B>%YOURQP%qp</B> of <B>%MAXQP%qp</B> total (<B>%QPERCENT%%</B>)<BR>(qp = quest points, they are a score of difficulty for each adventure)",
|
||||
},
|
||||
"player_list":{
|
||||
"playerlist_header":"^ATLists of Players Online^H",
|
||||
"select_from_following":"<B>Select from the following Player Lists:</B>",
|
||||
"list_of_buddies_format":"^T4List of all buddies(%AMOUNT% on):^D35|VIEW BUDDIES^R1",
|
||||
"list_of_players_nearby":"^T4List of nearby players:^D36|VIEW NEARBY^R1",
|
||||
"list_of_all_players_format":"^T4List of all players online(%AMOUNT% on):^D37|VIEW ALL ONLINE^R1",
|
||||
"list_of_all_players_alphabetically":"^T4List of all players alphabetically:^D40|VIEW ALL ONLINE^R1",
|
||||
"map_all_buddies_format":"^T4Show all of your buddies on map:^B1M%BUDDYXYLIST%^R1",
|
||||
"map_all_players_format":"^T4Show all players online on map:^B1M%ALLXYLIST%^R1",
|
||||
"abuse_report":"^R1^T4If you witness a rule violation:^D28c1|ABUSE REPORT^R1",
|
||||
},
|
||||
"misc_stats":{
|
||||
"no_stats_recorded":"<BR>None Yet.",
|
||||
"stat_format":"%STAT% (%COUNT%)<BR>",
|
||||
"pirate_treasures":"Pirate Treasures",
|
||||
"travels":"Travels",
|
||||
"horse_captures":"Horse Captures",
|
||||
"crafts":"Crafts",
|
||||
"wishes":"Wishes",
|
||||
"trainer":"Trainer",
|
||||
"arena_loss":"Arena Loss",
|
||||
"trades":"Trades",
|
||||
"horse_leases":"Horse Leases",
|
||||
"auto_sell":"Auto Sell",
|
||||
"pegasus_team_up":"Pegasus Team up",
|
||||
"horse_giveaway_win":"Horse Giveaway Wins",
|
||||
"real_time_quiz_win":"Real Time Quiz Wins",
|
||||
"real_time_riddle":"Real Time Riddles",
|
||||
"real_time_isle_cards_win":"Real Time Isle Cards Win",
|
||||
"sold_horse_to_pawneer":"Sold Horse To Pawneer",
|
||||
"water_balloon_win":"Water Balloon Wins",
|
||||
"unicorn_team_up":"Unicorn Team up",
|
||||
"pot_of_gold":"Pot Of Gold",
|
||||
"game_update_reset":"Game Updates / Resets",
|
||||
"unipeg_team_up":"UniPeg Team up"
|
||||
},
|
||||
"stats_page":{
|
||||
"stats_bar_format":"^ATPlayer %USERNAME%'s Details^H",
|
||||
"stats_area_format":"Currently %AREA%",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -80,10 +81,12 @@ namespace HISP.Game
|
|||
public static string PrivateNotesMetaFormat;
|
||||
|
||||
// Hay Pile
|
||||
|
||||
public static string HasPitchforkMeta;
|
||||
public static string NoPitchforkMeta;
|
||||
|
||||
// Chat
|
||||
|
||||
public static string GlobalChatFormat;
|
||||
public static string AdsChatFormat;
|
||||
public static string BuddyChatFormat;
|
||||
|
@ -218,6 +221,17 @@ namespace HISP.Game
|
|||
public static string BeatHighscoreFormat;
|
||||
public static string BeatBestTimeFormat;
|
||||
|
||||
// Player List
|
||||
public static string PlayerListHeader;
|
||||
public static string PlayerListSelectFromFollowing;
|
||||
public static string PlayerListOfBuddiesFormat;
|
||||
public static string PlayerListOfNearby;
|
||||
public static string PlayerListOfPlayersFormat;
|
||||
public static string PlayerListOfPlayersAlphabetically;
|
||||
public static string PlayerListMapAllBuddiesForamt;
|
||||
public static string PlayerListMapAllPlayersFormat;
|
||||
public static string PlayerListAbuseReport;
|
||||
|
||||
|
||||
// Meta
|
||||
public static string IsleFormat;
|
||||
|
@ -567,8 +581,35 @@ namespace HISP.Game
|
|||
return GrabItemFormat.Replace("%ICONID%",iconid.ToString()).Replace("%ITEMNAME%", name).Replace("%RANDOMID%", randomid.ToString());
|
||||
}
|
||||
|
||||
public static string FormatPlayerBuddyList(int amount)
|
||||
{
|
||||
return PlayerListOfBuddiesFormat.Replace("%AMOUNT%", amount.ToString("N0"));
|
||||
}
|
||||
public static string FormatPlayerList(int amount)
|
||||
{
|
||||
return PlayerListOfPlayersFormat.Replace("%AMOUNT%", amount.ToString("N0"));
|
||||
}
|
||||
|
||||
public static string FormatTransportMessage(string method, string place, int cost, int id, int x, int y)
|
||||
public static string FormatMapAllBuddiesList(string buddyxys)
|
||||
{
|
||||
return PlayerListMapAllBuddiesForamt.Replace("%BUDDYXYLIST%", buddyxys);
|
||||
}
|
||||
|
||||
public static string FormatMapAllPlayersList(string playerxys)
|
||||
{
|
||||
return PlayerListMapAllPlayersFormat.Replace("%ALLXYLIST%", playerxys);
|
||||
}
|
||||
|
||||
public static string FormatMapLocations(Point[] xys)
|
||||
{
|
||||
string allXys = "";
|
||||
foreach(Point xy in xys)
|
||||
{
|
||||
allXys += FormatMapLocation(xy.X, xy.Y);
|
||||
}
|
||||
return allXys;
|
||||
}
|
||||
public static string FormatMapLocation(int x, int y)
|
||||
{
|
||||
string xy = "";
|
||||
xy += (char)(((x - 4) / 64) + 20);
|
||||
|
@ -576,6 +617,12 @@ namespace HISP.Game
|
|||
|
||||
xy += (char)(((y - 1) / 64) + 20);
|
||||
xy += (char)(((y - 1) % 64) + 20);
|
||||
return xy;
|
||||
}
|
||||
|
||||
public static string FormatTransportMessage(string method, string place, int cost, int id, int x, int y)
|
||||
{
|
||||
string xy = FormatMapLocation(x, y);
|
||||
|
||||
int iconId = 253;
|
||||
if(method == "WAGON")
|
||||
|
|
|
@ -469,6 +469,25 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string BuildPlayerList(User user)
|
||||
{
|
||||
string message = "";
|
||||
message += Messages.PlayerListHeader;
|
||||
message += Messages.PlayerListSelectFromFollowing;
|
||||
message += Messages.FormatPlayerBuddyList(user.Friends.Count);
|
||||
message += Messages.PlayerListOfNearby;
|
||||
message += Messages.FormatPlayerList(GameServer.GetNumberOfPlayers() - 1);
|
||||
message += Messages.PlayerListOfPlayersAlphabetically;
|
||||
|
||||
message += Messages.FormatMapAllBuddiesList(Messages.FormatMapLocations(GameServer.GetAllBuddyLocations(user)));
|
||||
message += Messages.FormatMapAllPlayersList(Messages.FormatMapLocations(GameServer.GetAllPlayerLocations(user)));
|
||||
|
||||
message += Messages.PlayerListAbuseReport;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
|
||||
return message;
|
||||
}
|
||||
public static string BuildInventoryInfo(PlayerInventory inv)
|
||||
{
|
||||
string message = "";
|
||||
|
|
|
@ -28,13 +28,17 @@ namespace HISP.Player
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void AddFriend(User userToFriend)
|
||||
{
|
||||
bool pendingRequest = Database.IsPendingBuddyRequestExist(baseUser.Id, userToFriend.Id);
|
||||
if (pendingRequest)
|
||||
{
|
||||
Database.AcceptBuddyRequest(baseUser.Id, userToFriend.Id);
|
||||
|
||||
List.Add(userToFriend.Id);
|
||||
userToFriend.Friends.List.Add(baseUser.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -200,6 +200,9 @@ namespace HISP.Server
|
|||
case PacketBuilder.PACKET_MOVE:
|
||||
GameServer.OnMovementPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_PLAYERINFO:
|
||||
GameServer.OnPlayerInfoPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_PLAYER:
|
||||
GameServer.OnProfilePacket(this, Packet);
|
||||
break;
|
||||
|
|
|
@ -550,6 +550,19 @@ namespace HISP.Server
|
|||
Messages.Brought5ButInventoryFull = gameData.messages.shop.brought_5_but_inv_full;
|
||||
Messages.Brought25ButInventoryFull = gameData.messages.shop.brought_25_but_inv_full;
|
||||
|
||||
// Player List
|
||||
|
||||
Messages.PlayerListHeader = gameData.messages.meta.player_list.playerlist_header;
|
||||
Messages.PlayerListSelectFromFollowing = gameData.messages.meta.player_list.select_from_following;
|
||||
Messages.PlayerListOfBuddiesFormat = gameData.messages.meta.player_list.list_of_buddies_format;
|
||||
Messages.PlayerListOfNearby = gameData.messages.meta.player_list.list_of_players_nearby;
|
||||
Messages.PlayerListOfPlayersFormat = gameData.messages.meta.player_list.list_of_all_players_format;
|
||||
Messages.PlayerListOfPlayersAlphabetically = gameData.messages.meta.player_list.list_of_all_players_alphabetically;
|
||||
Messages.PlayerListMapAllBuddiesForamt = gameData.messages.meta.player_list.map_all_buddies_format;
|
||||
Messages.PlayerListMapAllPlayersFormat = gameData.messages.meta.player_list.map_all_players_format;
|
||||
Messages.PlayerListAbuseReport = gameData.messages.meta.player_list.abuse_report;
|
||||
|
||||
|
||||
// Consume
|
||||
|
||||
Messages.ConsumeItemFormat = gameData.messages.consume.consumed_item_format;
|
||||
|
|
|
@ -10,6 +10,7 @@ using HISP.Game;
|
|||
using HISP.Security;
|
||||
using HISP.Game.Chat;
|
||||
using HISP.Player.Equips;
|
||||
using System.Drawing;
|
||||
|
||||
namespace HISP.Server
|
||||
{
|
||||
|
@ -124,6 +125,30 @@ namespace HISP.Server
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void OnPlayerInfoPacket(GameClient sender, byte[] packet)
|
||||
{
|
||||
if (!sender.LoggedIn)
|
||||
{
|
||||
Logger.ErrorPrint(sender.RemoteIp + " Requests player info when not logged in.");
|
||||
return;
|
||||
}
|
||||
if(packet.Length < 3)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent playerinfo packet of wrong size");
|
||||
}
|
||||
|
||||
byte method = packet[1];
|
||||
switch(method)
|
||||
{
|
||||
case PacketBuilder.PLAYERINFO_PLAYER_LIST:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPlayerList(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
public static void OnDynamicButtonPressed(GameClient sender, byte[] packet)
|
||||
{
|
||||
|
@ -150,18 +175,22 @@ namespace HISP.Server
|
|||
switch(buttonId)
|
||||
{
|
||||
case 3:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildQuestLog(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 21:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPrivateNotes(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 20:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigameRankingsForUser(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case 24:
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAwardList(sender.LoggedinUser));
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
|
@ -576,15 +605,17 @@ namespace HISP.Server
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (method == PacketBuilder.PLAYERINFO_HIGHSCORES_LIST)
|
||||
else if (method == PacketBuilder.PROFILE_HIGHSCORES_LIST)
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string gameName = packetStr.Substring(2, packetStr.Length - 4);
|
||||
byte[] metaTag = PacketBuilder.CreateMetaPacket(Meta.BuildTopHighscores(gameName));
|
||||
sender.SendPacket(metaTag);
|
||||
}
|
||||
else if (method == PacketBuilder.PLAYERINFO_BESTTIMES_LIST)
|
||||
else if (method == PacketBuilder.PROFILE_BESTTIMES_LIST)
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string gameName = packetStr.Substring(2, packetStr.Length - 4);
|
||||
byte[] metaTag = PacketBuilder.CreateMetaPacket(Meta.BuildTopTimes(gameName));
|
||||
|
@ -1977,6 +2008,49 @@ namespace HISP.Server
|
|||
return count;
|
||||
}
|
||||
|
||||
public static Point[] GetAllBuddyLocations(User caller)
|
||||
{
|
||||
List<Point> allLocations = new List<Point>();
|
||||
|
||||
foreach (GameClient client in ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
|
||||
if (!caller.Friends.List.Contains(client.LoggedinUser.Id))
|
||||
continue;
|
||||
|
||||
|
||||
if (!client.LoggedinUser.Stealth)
|
||||
allLocations.Add(new Point(client.LoggedinUser.X, client.LoggedinUser.Y));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return allLocations.ToArray();
|
||||
}
|
||||
|
||||
public static Point[] GetAllPlayerLocations(User caller)
|
||||
{
|
||||
List<Point> allLocations = new List<Point>();
|
||||
|
||||
foreach (GameClient client in ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
|
||||
if (client.LoggedinUser.Id == caller.Id)
|
||||
continue;
|
||||
|
||||
if (!client.LoggedinUser.Stealth)
|
||||
allLocations.Add(new Point(client.LoggedinUser.X, client.LoggedinUser.Y));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return allLocations.ToArray();
|
||||
}
|
||||
public static int GetNumberOfPlayersListeningToAdsChat()
|
||||
{
|
||||
int count = 0;
|
||||
|
|
|
@ -29,7 +29,6 @@ namespace HISP.Server
|
|||
public const byte PACKET_KEEP_ALIVE = 0x7C;
|
||||
public const byte PACKET_DYNAMIC_BUTTON = 0x45;
|
||||
public const byte PACKET_DYNAMIC_INPUT = 0x46;
|
||||
|
||||
public const byte PACKET_PLAYER = 0x18;
|
||||
public const byte PACKET_INVENTORY = 0x17;
|
||||
public const byte PACKET_TRANSPORT = 0x29;
|
||||
|
@ -53,8 +52,10 @@ namespace HISP.Server
|
|||
|
||||
public const byte PLAYERINFO_LEAVE = 0x16;
|
||||
public const byte PLAYERINFO_UPDATE_OR_CREATE = 0x15;
|
||||
public const byte PLAYERINFO_HIGHSCORES_LIST = 0x51;
|
||||
public const byte PLAYERINFO_BESTTIMES_LIST = 0x52;
|
||||
public const byte PLAYERINFO_PLAYER_LIST = 0x14;
|
||||
|
||||
public const byte PROFILE_HIGHSCORES_LIST = 0x51;
|
||||
public const byte PROFILE_BESTTIMES_LIST = 0x52;
|
||||
|
||||
public const byte VIEW_PROFILE = 0x14;
|
||||
public const byte SAVE_PROFILE = 0x15;
|
||||
|
|
Loading…
Add table
Reference in a new issue