mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-19 19:29:15 +12:00
Allow searching for NPCS.
This commit is contained in:
parent
0c42d02359
commit
cb497ef7d2
5 changed files with 125 additions and 1 deletions
|
@ -75,7 +75,16 @@ namespace HISP.Game
|
|||
public static string LoginMessageFormat;
|
||||
public static string LogoutMessageFormat;
|
||||
|
||||
// Libary
|
||||
public static string LibaryMainMenu;
|
||||
public static string LibaryFindNpc;
|
||||
public static string LibaryFindNpcSearchResultsHeader;
|
||||
public static string LibaryFindNpcSearchResultFormat;
|
||||
public static string LibaryFindNpcSearchNoResults;
|
||||
public static string LibaryFindNpcLimit5;
|
||||
|
||||
// Records
|
||||
|
||||
public static string ProfileSavedMessage;
|
||||
public static string PrivateNotesSavedMessage;
|
||||
public static string PrivateNotesMetaFormat;
|
||||
|
@ -338,6 +347,11 @@ namespace HISP.Game
|
|||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatNpcSearchResult(string name, int x, int y)
|
||||
{
|
||||
string mapXy = FormatMapLocation(x, y);
|
||||
return LibaryFindNpcSearchResultFormat.Replace("%NPCNAME%", name).Replace("%MAPXY%", mapXy);
|
||||
}
|
||||
public static string FormatLastPoet(string name)
|
||||
{
|
||||
return LastPoetFormat.Replace("%USERNAME%", name);
|
||||
|
|
|
@ -247,7 +247,10 @@ namespace HISP.Game
|
|||
return message;
|
||||
|
||||
}
|
||||
|
||||
public static string buildLibary()
|
||||
{
|
||||
return Messages.LibaryMainMenu + Messages.ExitThisPlace + Messages.MetaTerminator;
|
||||
}
|
||||
private static string buildNpc(User user, int x, int y)
|
||||
{
|
||||
string message = "";
|
||||
|
@ -617,6 +620,57 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string BuildNpcSearch(string search)
|
||||
{
|
||||
List<Npc.NpcEntry> foundNpcs = new List<Npc.NpcEntry>();
|
||||
foreach(Npc.NpcEntry npc in Npc.NpcList)
|
||||
{
|
||||
if(npc.Name.ToLower().Contains(search.ToLower()))
|
||||
{
|
||||
if(npc.LibarySearchable)
|
||||
{
|
||||
if (foundNpcs.Count >= 5)
|
||||
break;
|
||||
foundNpcs.Add(npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
string message = Messages.LibaryFindNpcSearchNoResults;
|
||||
if(foundNpcs.Count >= 1)
|
||||
{
|
||||
message = Messages.LibaryFindNpcSearchResultsHeader;
|
||||
foreach(Npc.NpcEntry npc in foundNpcs)
|
||||
{
|
||||
string searchResult = Messages.FormatNpcSearchResult(npc.Name, npc.X, npc.Y);
|
||||
Logger.DebugPrint(searchResult);
|
||||
message += searchResult;
|
||||
}
|
||||
}
|
||||
if(foundNpcs.Count >= 5)
|
||||
{
|
||||
message += Messages.LibaryFindNpcLimit5;
|
||||
}
|
||||
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
|
||||
}
|
||||
public static string BuildFindNpcMenu()
|
||||
{
|
||||
string message = Messages.LibaryFindNpc;
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildFountain()
|
||||
{
|
||||
return Messages.FountainMeta;
|
||||
|
@ -721,6 +775,10 @@ namespace HISP.Game
|
|||
{
|
||||
message += buildVenusFlyTrap(user);
|
||||
}
|
||||
if(TileCode == "LIBRARY")
|
||||
{
|
||||
message += buildLibary();
|
||||
}
|
||||
if(TileCode == "MULTIROOM")
|
||||
{
|
||||
user.MetaPriority = false; // acturally want to track updates here >-<
|
||||
|
|
|
@ -554,6 +554,15 @@ namespace HISP.Server
|
|||
Messages.BankDepositedMoneyFormat = gameData.messages.bank.deposit_format;
|
||||
Messages.BankWithdrewMoneyFormat = gameData.messages.bank.withdraw_format;
|
||||
|
||||
|
||||
// Libary
|
||||
Messages.LibaryMainMenu = gameData.messages.meta.libary.main_menu;
|
||||
Messages.LibaryFindNpc = gameData.messages.meta.libary.find_npc;
|
||||
Messages.LibaryFindNpcSearchResultsHeader = gameData.messages.meta.libary.find_npc_results_header;
|
||||
Messages.LibaryFindNpcSearchResultFormat = gameData.messages.meta.libary.find_npc_results_format;
|
||||
Messages.LibaryFindNpcSearchNoResults = gameData.messages.meta.libary.find_npc_no_results;
|
||||
Messages.LibaryFindNpcLimit5 = gameData.messages.meta.libary.find_npc_limit5;
|
||||
|
||||
// Chat
|
||||
|
||||
Messages.ChatViolationMessageFormat = gameData.messages.chat.violation_format;
|
||||
|
|
|
@ -148,6 +148,20 @@ namespace HISP.Server
|
|||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (private notes, wrong size)");
|
||||
break;
|
||||
}
|
||||
case 4: // NPC Search
|
||||
if(dynamicInput.Length >= 2)
|
||||
{
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
string metaWindow = Meta.BuildNpcSearch(dynamicInput[1]);
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(metaWindow);
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Tried to send a invalid dynamic input (NPC Search, wrong size)");
|
||||
break;
|
||||
}
|
||||
case 7: // Private Notes
|
||||
if (dynamicInput.Length >= 2)
|
||||
{
|
||||
|
@ -335,6 +349,27 @@ namespace HISP.Server
|
|||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPlayerListAlphabetical());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "30": // Find NPC
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildFindNpcMenu());
|
||||
sender.SendPacket(metaPacket);
|
||||
break;
|
||||
case "31": // Find Ranch
|
||||
break;
|
||||
case "4": // View Horse Breed
|
||||
break;
|
||||
case "9": // View Tack
|
||||
break;
|
||||
case "10": // View Competitions
|
||||
break;
|
||||
case "12": // View Miigames
|
||||
break;
|
||||
case "22": // View Locations
|
||||
break;
|
||||
case "23": // View Awards
|
||||
break;
|
||||
case "38": // Read Books
|
||||
break;
|
||||
case "28c1":
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildAbuseReportPage());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue