Make waypoints or "show locations" work in the libary.

This commit is contained in:
SilicaPi 2021-02-02 01:01:28 +13:00
parent abe8a8a353
commit e3dae116dd
6 changed files with 117 additions and 7 deletions

View file

@ -290,6 +290,13 @@
"horse_relative_format":"^I252^T7A Horse Relative, the %NAME%:^D4c%ID%|VIEW^R1",
"maximum_stats":"<B>MAXIMUM STATS:</B><BR>^AA",
"breed_preview_format":"<B>Viewing %NAME%:</B><BR>%DESCRIPTION%^D4|RETURN TO BREED LIST^R2^H",
"locations":{
"known_islands":"^H<B>Horse Isle Known Islands</B>",
"known_towns":"^H<B>Horse Isle Communities</B>",
"isle_entry":"^I233^T7 %ISLENAME% ^B1M%MAPXY%^R1",
"town_entry":"^I210^T7 %TOWNNAME% ^B1M%MAPXY%^R1",
"location_description":"^H %AREADESC%"
},
"minigames":{
"singleplayer":"^H<B>Single Player Mini-Games</B><BR>These typically earn you money, some can earn you objects",
"twoplayer":"^H<B>Two Player Mini-Games</B><BR>These all require another player to start the game.",

View file

@ -185,6 +185,13 @@ namespace HISP.Game
public static string MaxJewelryMessage;
public static string RemoveJewelry;
// Locations (Libary)
public static string LocationKnownIslands;
public static string LocationKnownTowns;
public static string LocationIslandFormat;
public static string LocationTownFormat;
public static string LocationDescriptionFormat;
// Minigames (Libary)
public static string MinigameSingleplayer;
public static string MinigameTwoplayer;
@ -526,8 +533,18 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatLocationDescription(string description)
{
return LocationDescriptionFormat.Replace("%AREADESC%", description);
}
public static string FormatIslandLocation(string isleName, string mapXy)
{
return LocationIslandFormat.Replace("%ISLENAME%", isleName).Replace("%MAPXY%",mapXy);
}
public static string FormatTownLocation(string townName, string mapXy)
{
return LocationTownFormat.Replace("%TOWNNAME%", townName).Replace("%MAPXY%",mapXy);
}
public static string FormatMinigameEntry(string gameName, string mapXy)
{
return MinigameEntryFormat.Replace("%GAMENAME%",gameName).Replace("%MAPXY%",mapXy);

View file

@ -419,7 +419,33 @@ namespace HISP.Game
message += Messages.MetaTerminator;
return message;
}
public static string BuildLocationsLibary()
{
string message = "";
message += Messages.LocationKnownIslands;
foreach(World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
{
if(waypoint.Type == "ISLE")
{
string mapxy = Messages.FormatMapLocation(waypoint.PosX, waypoint.PosY);
message += Messages.FormatIslandLocation(waypoint.Name, mapxy);
message += Messages.FormatLocationDescription(waypoint.Description);
}
}
message += Messages.LocationKnownTowns;
foreach(World.Waypoint waypoint in World.Waypoints.OrderBy(o => o.Name).ToArray())
{
if(waypoint.Type == "TOWN")
{
string mapxy = Messages.FormatMapLocation(waypoint.PosX, waypoint.PosY);
message += Messages.FormatTownLocation(waypoint.Name, mapxy);
message += Messages.FormatLocationDescription(waypoint.Description);
}
}
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildHorseReleased()
{
string message = "";

View file

@ -6,7 +6,28 @@ namespace HISP.Game
public class World
{
public struct Isle
private static Waypoint getWaypoint(string find)
{
foreach(Waypoint waypoint in Waypoints)
{
if(waypoint.Name == find)
return waypoint;
}
throw new KeyNotFoundException("Waypoint with name "+find+" not found.");
}
public struct Waypoint
{
public string Name;
public int PosX;
public int PosY;
public string Type;
public string Description;
public string[] WeatherTypesAvalible;
}
public class Isle
{
public int StartX;
public int EndX;
@ -14,14 +35,25 @@ namespace HISP.Game
public int EndY;
public int Tileset;
public string Name;
public Waypoint GetWaypoint()
{
return getWaypoint(this.Name);
}
}
public struct Town
public class Town
{
public int StartX;
public int EndX;
public int StartY;
public int EndY;
public string Name;
public Waypoint GetWaypoint()
{
return getWaypoint(this.Name);
}
}
public struct Area
{
@ -66,12 +98,14 @@ namespace HISP.Game
}
public static Time ServerTime = new Time();
public static List<Waypoint> Waypoints = new List<Waypoint>();
public static List<Isle> Isles = new List<Isle>();
public static List<Town> Towns = new List<Town>();
public static List<Area> Areas = new List<Area>();
public static List<Zone> Zones = new List<Zone>();
public static List<SpecialTile> SpecialTiles = new List<SpecialTile>();
public static void TickWorldClock()
{
ServerTime.Minutes += 1;

View file

@ -89,6 +89,20 @@ namespace HISP.Server
World.Isles.Add(isle);
}
int totalWaypoints = gameData.places.waypoints.Count;
for(int i = 0; i < totalWaypoints; i++)
{
World.Waypoint waypoint = new World.Waypoint();
waypoint.Name = gameData.places.waypoints[i].name;
waypoint.PosX = gameData.places.waypoints[i].pos_x;
waypoint.PosY = gameData.places.waypoints[i].pos_y;
waypoint.Type = gameData.places.waypoints[i].type;
waypoint.Description = gameData.places.waypoints[i].description;
waypoint.WeatherTypesAvalible = gameData.places.waypoints[i].weather_avalible.ToObject<string[]>();
Logger.DebugPrint("Registered Waypoint: "+waypoint.PosX.ToString()+", "+waypoint.PosY.ToString() +" TYPE: "+waypoint.Type);
World.Waypoints.Add(waypoint);
}
// Register Special Tiles
int totalSpecialTiles = gameData.places.special_tiles.Count;
for (int i = 0; i < totalSpecialTiles; i++)
@ -588,6 +602,13 @@ namespace HISP.Server
Messages.StatMiscNoneRecorded = gameData.messages.meta.misc_stats.no_stats_recorded;
Messages.StatMiscEntryFormat = gameData.messages.meta.misc_stats.stat_format;
// Locations (Libary)
Messages.LocationKnownIslands = gameData.messages.meta.libary.locations.known_islands;
Messages.LocationKnownTowns = gameData.messages.meta.libary.locations.known_towns;
Messages.LocationIslandFormat = gameData.messages.meta.libary.locations.isle_entry;
Messages.LocationTownFormat = gameData.messages.meta.libary.locations.town_entry;
Messages.LocationDescriptionFormat = gameData.messages.meta.libary.locations.location_description;
// Minigame (Libary)
Messages.MinigameSingleplayer = gameData.messages.meta.libary.minigames.singleplayer;
Messages.MinigameTwoplayer = gameData.messages.meta.libary.minigames.twoplayer;

View file

@ -1294,14 +1294,19 @@ namespace HISP.Server
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigamesLibary());
sender.SendPacket(metaPacket);
break;
case "20": // Minigame Rankings
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigameRankingsForUser(sender.LoggedinUser));
sender.SendPacket(metaPacket);
break;
case "21": // Private Notes
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildPrivateNotes(sender.LoggedinUser));
sender.SendPacket(metaPacket);
break;
case "20": // Minigame Rankings
case "22": // View Locations (Libary)
sender.LoggedinUser.MetaPriority = true;
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildMinigameRankingsForUser(sender.LoggedinUser));
metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildLocationsLibary());
sender.SendPacket(metaPacket);
break;
case "24": // Award List