"Players Here" shows up, but doesnt do anything

This commit is contained in:
SilicaAndPina 2021-02-23 10:46:55 +13:00
parent bd18415bbf
commit c3585b655a
7 changed files with 157 additions and 12 deletions

View file

@ -13,6 +13,18 @@ namespace HISP.Game
// Mod isle
public static string ModIsleMessage;
// Player Interaction
public static string PlayerHereMenuFormat;
public static string PlayerHereMulitpleMenuFormat;
public static string PlayerHereProfileButton;
public static string PlayerHereSocialButton;
public static string PlayerHereTradeButton;
public static string PlayerHereAddBuddyButton;
public static string PlayerHereTagButton;
public static string PlayerHerePmButton;
// Auction House
public static string AuctionsRunning;
public static string AuctionHorseEntryFormat;
@ -56,7 +68,7 @@ namespace HISP.Game
public static string FailedToUnderstandLocation;
// Click
public static string PlayerHereFormat;
public static string ClickPlayerHereFormat;
// Hammock
public static string HammockText;
@ -804,6 +816,7 @@ namespace HISP.Game
public static string TownFormat;
public static string AreaFormat;
public static string LocationFormat;
public static string PlayersHere;
public static string NearbyPlayers;
public static string North;
public static string East;
@ -900,6 +913,38 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
// Player Interactions
public static string FormatPlayerHerePMButton(string playerName)
{
return PlayerHerePmButton.Replace("%PLAYERNAME%", playerName);
}
public static string FormatPlayerHereTagButton(int playerId)
{
return PlayerHereTagButton.Replace("%PLAYERID%", playerId.ToString());
}
public static string FormatPlayerHereBuddyButton(int playerId)
{
return PlayerHereAddBuddyButton.Replace("%PLAYERID%", playerId.ToString());
}
public static string FormatPlayerHereTradeButton(int playerId)
{
return PlayerHereTradeButton.Replace("%PLAYERID%", playerId.ToString());
}
public static string FormatPlayerHereSocialButtton(int playerId)
{
return PlayerHereSocialButton.Replace("%PLAYERID%", playerId.ToString());
}
public static string FormatPlayerHereProfileButton(int playerId)
{
return PlayerHereProfileButton.Replace("%PLAYERID%", playerId.ToString());
}
public static string FormatPlayerHereMenu(int playerIcon, string playerName, string button)
{
return PlayerHereMenuFormat.Replace("%PLAYERICON%", playerIcon.ToString()).Replace("%PLAYERNAME%", playerName).Replace("%BUTTONS%", button);
}
// Auctions
public static string FormatAuctionSoldTo(string playerName, int money)
{
return AuctionSoldToFormat.Replace("%PLAYERNAME%", playerName).Replace("%PRICE%", money.ToString("N0", CultureInfo.InvariantCulture));
@ -1115,7 +1160,7 @@ namespace HISP.Game
public static string FormatPlayerHereMessage(string playerName)
{
return PlayerHereFormat.Replace("%USERNAME%", playerName);
return ClickPlayerHereFormat.Replace("%USERNAME%", playerName);
}
// Barn Formats

View file

@ -35,12 +35,48 @@ namespace HISP.Game
return locationString;
}
private static string buildPlayersHere(User fromUser, int x, int y)
{
string playersHere = "";
User[] playersAt = GameServer.GetUsersAt(x, y, true, true);
if(playersAt.Length > 1)
{
playersHere += Messages.PlayersHere;
int count = 0;
foreach(User playerAt in playersAt)
{
if (playerAt.Id == fromUser.Id)
continue;
string buttons = "";
buttons += Messages.FormatPlayerHereProfileButton(playerAt.Id);
buttons += Messages.FormatPlayerHereSocialButtton(playerAt.Id);
buttons += Messages.FormatPlayerHereTradeButton(playerAt.Id);
if (fromUser.Friends.IsFriend(playerAt.Id))
buttons += Messages.FormatPlayerHereTagButton(playerAt.Id);
else
buttons += Messages.FormatPlayerHereBuddyButton(playerAt.Id);
buttons += Messages.FormatPlayerHerePMButton(playerAt.Username);
playersHere += Messages.FormatPlayerHereMenu(playerAt.GetPlayerListIcon(), playerAt.Username,buttons);
count++;
}
if(count >= 2)
playersHere += Messages.PlayerHereMulitpleMenuFormat;
if (count <= 0)
return "";
}
return playersHere;
}
private static string buildNearbyString(int x, int y)
{
string playersNearby = "";
User[] nearbyUsers = GameServer.GetNearbyUsers(x, y, true, true);
int count = 0;
if (nearbyUsers.Length > 1)
{
playersNearby += Messages.Seperator;
@ -71,6 +107,9 @@ namespace HISP.Game
usersSouth += " " + nearbyUser.Username + " ";
else if (angle >= 0 && angle <= 90)
usersNorth += " " + nearbyUser.Username + " ";
count++;
}
if (usersEast != "")
@ -85,7 +124,10 @@ namespace HISP.Game
}
if(count <= 0)
{
return "";
}
return playersNearby;
}
@ -171,9 +213,10 @@ namespace HISP.Game
}
private static string buildCommonInfo(int x, int y)
private static string buildCommonInfo(User user, int x, int y)
{
string message = "";
message += buildPlayersHere(user, x, y);
message += buildNearbyString(x, y);
// Dropped Items
@ -2152,8 +2195,7 @@ namespace HISP.Game
message += BuildWildHorseList(user);
message += buildNpc(user, x, y);
message += buildCommonInfo(x, y);
message += buildCommonInfo(user, x, y);
return message;
}
public static string BuildPawneerOrderFound(HorseInstance instance)
@ -2408,7 +2450,7 @@ namespace HISP.Game
message += npc;
if (specialTile.Code == null || specialTile.Code == "")
message += buildCommonInfo(specialTile.X, specialTile.Y);
message += buildCommonInfo(user, specialTile.X, specialTile.Y);
else
{