Implement "View Horse Breeds" in libary.

This commit is contained in:
SilicaAndPina 2021-01-04 22:26:10 +13:00
parent b66fe013ba
commit 663a148b77
7 changed files with 77 additions and 4 deletions

View file

@ -130,6 +130,9 @@
"venus_flytrap_format":"The Giant Venus Flytrap chomped at you!<BR><B>OUCH!!</B><BR>It chomped your pocket, taking $%MONEY% with it!!",
"password_input":"<BR>^PLReply:|^PS14|ANSWER^R1",
"last_poet":"^R1^LLast Player Poet:%USERNAME% ^R1",
"horse":{
"stat_format":"%BASE%;%COMPAINON%;%TACK%;%MAX%;"
},
"libary":{
"main_menu":"Welcome to the Library! You can research different subjects.<BR>^T2Search Residents: ^D30|SEARCH NPC^R1^T2Search Ranches: ^D31|SEARCH RANCH^R1^T2Research Horses: ^D4|VIEW BREEDS^R1^T2Research Tack: ^D9|VIEW TACK^R1^T2Research Companions: ^D10|VIEW COMPANIONS^R1^T2Research Mini-Games: ^D12|VIEW MINIGAMES^R1^T2Research Locations: ^D22|VIEW LOCATIONS^R1^T2Research Awards: ^D23|VIEW AWARDS^R1^T2Read Books: ^D38|READ BOOKS^R1",
"find_npc":"<B>SEARCH FOR A RESIDENT:</B><BR>Enter a resident's name below(not players). It will match on partial names.<BR>^PLResident Locator(NPC):|NPC name^PS4|FIND RESIDENTS^R3",
@ -138,7 +141,9 @@
"find_npc_no_results":"The following residents match closely:<BR>None were found by that name, try looking for a partial name.",
"find_npc_limit5":"^L- Limited to 5 results. Try narrowing the search.^R1",
"horse_breed_format":"^I252^T7Horse Breed %NAME%:^D4c%ID%|VIEW^R1",
"horse_relative_format":"^I252^T7A Horse Relative, the %NAME%:^D4c%ID%|VIEW^R1"
"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"
},
"multiroom":{
"other_players_participating":"<BR>^LThe following other players are participating:",

View file

@ -37,5 +37,14 @@ namespace HISP.Game
public static List<Breed> Breeds = new List<Breed>();
public static Breed GetBreedById(int id)
{
foreach(Breed breed in Breeds)
{
if (breed.Id == id)
return breed;
}
throw new KeyNotFoundException("No horse breed with id " + id);
}
}
}

View file

@ -85,6 +85,8 @@ namespace HISP.Game
public static string HorseBreedFormat;
public static string HorseRelativeFormat;
public static string BreedViewerFormat;
// Records
@ -159,6 +161,10 @@ namespace HISP.Game
public static string MaxJewelryMessage;
public static string RemoveJewelry;
// Horse
public static string BreedViewerMaximumStats;
public static string StatFormat;
// Consume
public static string ConsumeItemFormat;
@ -349,7 +355,14 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatHorseBreedPreview(string name, string description)
{
return BreedViewerFormat.Replace("%NAME%", name).Replace("%DESCRIPTION%", description);
}
public static string FormatHorseStat(int baseStat, int companionBoost, int tackBoost, int maxStat)
{
return StatFormat.Replace("%BASE%", baseStat.ToString()).Replace("%COMPAINON%", companionBoost.ToString()).Replace("%TACK%", tackBoost.ToString()).Replace("%MAX%", maxStat.ToString());
}
public static string FormatHorseRelative(string name, int id)
{
return HorseRelativeFormat.Replace("%NAME%", name).Replace("%ID%", id.ToString());

View file

@ -620,13 +620,27 @@ namespace HISP.Game
return message;
}
public static string BuildBreedViewerLibary(Horse.Breed breed)
{
string message = Messages.FormatHorseBreedPreview(breed.Name, breed.Description);
message += Messages.BreedViewerMaximumStats;
message += Messages.FormatHorseStat(breed.BaseStats.Speed * 2, 0, 0, breed.BaseStats.Speed * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Strength * 2, 0, 0, breed.BaseStats.Strength * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Conformation * 2, 0, 0, breed.BaseStats.Conformation * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Agility * 2, 0, 0, breed.BaseStats.Agility * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Endurance * 2, 0, 0, breed.BaseStats.Endurance * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Inteligence * 2, 0, 0, breed.BaseStats.Inteligence * 2);
message += Messages.FormatHorseStat(breed.BaseStats.Personality * 2, 0, 0, breed.BaseStats.Personality * 2);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildHorseList()
{
string message = "";
foreach(Horse.Breed breed in Horse.Breeds.OrderBy(o => o.Name).ToList())
{
if (breed.Type == "unicorn" || breed.Type == "pegasus")
continue;
if (breed.Type == "horse")
message += Messages.FormatHorseBreed(breed.Name, breed.Id);
else

View file

@ -503,6 +503,7 @@ namespace HISP.Server
Messages.PrivateNotesSavedMessage = gameData.messages.private_notes_save;
Messages.PrivateNotesMetaFormat = gameData.messages.meta.private_notes_format;
// Announcements
Messages.WelcomeFormat = gameData.messages.welcome_format;
@ -585,6 +586,9 @@ namespace HISP.Server
Messages.BankDepositedMoneyFormat = gameData.messages.bank.deposit_format;
Messages.BankWithdrewMoneyFormat = gameData.messages.bank.withdraw_format;
// Horses
Messages.StatFormat = gameData.messages.meta.horse.stat_format;
// Libary
Messages.LibaryMainMenu = gameData.messages.meta.libary.main_menu;
@ -596,6 +600,8 @@ namespace HISP.Server
Messages.HorseBreedFormat = gameData.messages.meta.libary.horse_breed_format;
Messages.HorseRelativeFormat = gameData.messages.meta.libary.horse_relative_format;
Messages.BreedViewerFormat = gameData.messages.meta.libary.breed_preview_format;
Messages.BreedViewerMaximumStats = gameData.messages.meta.libary.maximum_stats;
// Chat

View file

@ -379,6 +379,31 @@ namespace HISP.Server
sender.SendPacket(metaPacket);
break;
default:
if(buttonIdStr.StartsWith("4c"))
{
string idStr = buttonIdStr.Substring(2);
int breedId = -1;
Horse.Breed horseBreed;
try
{
breedId = int.Parse(idStr);
horseBreed = Horse.GetBreedById(breedId);
}
catch (Exception) {
Logger.DebugPrint(sender.LoggedinUser.Username + " Sent invalid libary breed viewer request.");
break;
};
string metaTag = Meta.BuildBreedViewerLibary(horseBreed);
metaPacket = PacketBuilder.CreateMetaPacket(metaTag);
sender.SendPacket(metaPacket);
string swf = "breedviewer.swf?terrain=book&breed=" + horseBreed.Swf + "&j=";
byte[] loadSwf = PacketBuilder.CreateSwfModulePacket(swf, PacketBuilder.PACKET_SWF_MODULE_FORCE);
sender.SendPacket(loadSwf);
break;
}
if(AbuseReport.DoesReasonExist(buttonIdStr))
{
sender.LoggedinUser.MetaPriority = true;

View file

@ -21,6 +21,7 @@ namespace HISP.Server
public const byte PACKET_WORLD = 0x7A;
public const byte PACKET_BASE_STATS = 0x7B;
public const byte PACKET_SWF_CUTSCENE = 0x29;
public const byte PACKET_SWF_MODULE_FORCE = 0x28;
public const byte PACKET_SWF_MODULE_GENTLE = 0x2A;
public const byte PACKET_PLACE_INFO = 0x1E;
public const byte PACKET_AREA_DEFS = 0x79;