From 4f61b636a699dacd8701b32fe50b23bfe88dcc8f Mon Sep 17 00:00:00 2001 From: KuromeSan Date: Sun, 24 Jan 2021 19:56:01 +1300 Subject: [PATCH] Add vets --- DataCollection/gamedata.json | 10 ++++- .../Horse Isle Server/Game/Messages.cs | 32 +++++++++++++++ .../Horse Isle Server/Game/Meta.cs | 31 +++++++++++++++ .../Horse Isle Server/Game/Services/Vet.cs | 39 +++++++++++++++++++ .../Horse Isle Server.csproj | 1 + .../Horse Isle Server/Server/GameDataJson.cs | 19 ++++++++- 6 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 Horse Isle Server/Horse Isle Server/Game/Services/Vet.cs diff --git a/DataCollection/gamedata.json b/DataCollection/gamedata.json index 8d01591..80d920b 100644 --- a/DataCollection/gamedata.json +++ b/DataCollection/gamedata.json @@ -136,10 +136,11 @@ "vet":{ "service_horse":"^LYour horse %HORSENAME%: health currently %CURHEALTH%/%MAXHEALTH%^R1", "not_needed":"^I257^T8Vet services are not needed for this horse.^R1", + "apply":"^I257^T6Apply vet services for $%PRICE% ^B3V%RANDOMID%", "apply_all":"^R1^I257^T6Apply all vet services for $%PRICE% ^B3v^R1", "now_full_health":"Your horse %HORSENAME% is now at full health!", - "not_needed":"Your horses do not require any vet services right now.", + "not_needed_all":"Your horses do not require any vet services right now.", "all_full":"Your horses are now all at full health!", }, "pond":{ @@ -713,6 +714,13 @@ "pm_sound":"PM" } }, + "vet":{ + "price_multipliers":[ + {"id":1,"cost":0.5}, + {"id":2,"cost":0.8}, + {"id":3,"cost":0.9} + ] + }, "horses":{ "names":["A Buck Or Two","A Cowboy's Dream","A Cowgirls's Dream","A Promise Kept","A Smile","A Splash Of Class", "A Whole Lotta Luck","A'dab","A'idah","Abaccus","Abalone","Abba", diff --git a/Horse Isle Server/Horse Isle Server/Game/Messages.cs b/Horse Isle Server/Horse Isle Server/Game/Messages.cs index bb06678..eadf9c5 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Messages.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Messages.cs @@ -296,6 +296,17 @@ namespace HISP.Game public static string HorseEquipFormat; public static string BackToHorse; + // Vet + public static string VetServiceHorseFormat; + public static string VetSerivcesNotNeeded; + public static string VetApplyServicesFormat; + + public static string VetApplyServicesForAllFormat; + public static string VetFullHealthRecoveredMessageFormat; + + public static string VetServicesNotNeededAll; + public static string VetAllFullHealthRecoveredMessage; + // Consume public static string ConsumeItemFormat; @@ -490,6 +501,27 @@ namespace HISP.Game // Click public static string NothingInterestingHere; + public static string FormatVetServiceHorseMeta(string horseName, int currentHealth, int maxHealth) + { + return VetServiceHorseFormat.Replace("%HORSENAME%", horseName).Replace("%CURHEALTH%", currentHealth.ToString()).Replace("%MAXHEALTH%", maxHealth.ToString()); + } + + public static string FormatVetApplyServiceMeta(int price, int randomId) + { + return VetApplyServicesFormat.Replace("%PRICE%", price.ToString()).Replace("%RANDOMID%", randomId.ToString()); + } + + public static string FormatVetApplyAllServiceMeta(int price) + { + return VetApplyServicesForAllFormat.Replace("%PRICE%", price.ToString()); + } + + public static string FormatVetHorseAtFullHealthMessage(string horseName) + { + return VetFullHealthRecoveredMessageFormat.Replace("%HORSENAME%", horseName); + } + + public static string FormatPondNotThirsty(string horseName) { return PondNotThirstyFormat.Replace("%HORSENAME%", horseName); diff --git a/Horse Isle Server/Horse Isle Server/Game/Meta.cs b/Horse Isle Server/Horse Isle Server/Game/Meta.cs index 8e6c6b2..c3b42d5 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Meta.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Meta.cs @@ -803,6 +803,30 @@ namespace HISP.Game return message; } + private static string buildVet(Vet vet, User user) + { + string message = ""; + int totalPrice = 0; + foreach (HorseInstance horse in user.HorseInventory.HorseList) + { + message += Messages.FormatVetServiceHorseMeta(horse.Name, horse.BasicStats.Health, 1000); + + if (horse.BasicStats.Health >= 1000) + message += Messages.VetSerivcesNotNeeded; + else + { + int price = vet.CalculatePrice(horse.BasicStats.Health); + totalPrice += price; + + message += Messages.FormatVetApplyServiceMeta(price, horse.RandomId); + } + + } + message += Messages.FormatVetApplyAllServiceMeta(totalPrice); + message += Messages.ExitThisPlace; + message += Messages.MetaTerminator; + return message; + } public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile) { @@ -862,6 +886,13 @@ namespace HISP.Game message += buildShopInfo(shop,user.Inventory); } + if(TileCode == "VET") + { + int VetId = int.Parse(TileArg); + Vet vet = Vet.GetVetById(VetId); + message += buildVet(vet, user); + Logger.DebugPrint(message); + } if(TileCode == "BANK") { message += buildBank(user); diff --git a/Horse Isle Server/Horse Isle Server/Game/Services/Vet.cs b/Horse Isle Server/Horse Isle Server/Game/Services/Vet.cs new file mode 100644 index 0000000..1e88bcc --- /dev/null +++ b/Horse Isle Server/Horse Isle Server/Game/Services/Vet.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HISP.Game.Services +{ + class Vet + { + + public static List Vets = new List(); + + public Vet(int id, double price) + { + Id = id; + PriceMultiplier = price; + Vets.Add(this); + } + + public int Id; + public double PriceMultiplier; + public int CalculatePrice(int health) + { + double price = ((double)health - 1000.0) * PriceMultiplier; + return Convert.ToInt32(Math.Floor(price)); + } + + public static Vet GetVetById(int id) + { + foreach(Vet vet in Vets) + { + if (id == vet.Id) + return vet; + } + throw new KeyNotFoundException("Vet with id: " + id + " Not found."); + } + } +} diff --git a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj index 527e7d2..a0b7f3c 100644 --- a/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj +++ b/Horse Isle Server/Horse Isle Server/Horse Isle Server.csproj @@ -87,6 +87,7 @@ + diff --git a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs index fae8db6..5fb2b3b 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameDataJson.cs @@ -502,7 +502,14 @@ namespace HISP.Server Tracking.TrackedItemsStatsMenu.Add(trackedItem); Logger.DebugPrint("Registered Tracked Item: " + trackedItem.What + " value: " + trackedItem.Value); } - + int totalVets = gameData.vet.price_multipliers.Count; + for (int i = 0; i < totalVets; i++) + { + double cost = gameData.vet.price_multipliers[i].cost; + int id = gameData.vet.price_multipliers[i].id; + Vet vet = new Vet(id, cost); + Logger.DebugPrint("Registered Vet: " + vet.Id + " selling at: " + vet.PriceMultiplier); + } HorseInfo.HorseNames = gameData.horses.names.ToObject(); Item.Present = gameData.item.special.present; @@ -580,6 +587,16 @@ namespace HISP.Server Messages.StatMiscNoneRecorded = gameData.messages.meta.misc_stats.no_stats_recorded; Messages.StatMiscEntryFormat = gameData.messages.meta.misc_stats.stat_format; + // Vet + Messages.VetServiceHorseFormat = gameData.messages.meta.vet.service_horse; + Messages.VetSerivcesNotNeeded = gameData.messages.meta.vet.not_needed; + Messages.VetApplyServicesFormat = gameData.messages.meta.vet.apply; + + Messages.VetApplyServicesForAllFormat = gameData.messages.meta.vet.apply_all; + Messages.VetFullHealthRecoveredMessageFormat = gameData.messages.meta.vet.now_full_health; + Messages.VetServicesNotNeededAll = gameData.messages.meta.vet.not_needed_all; + Messages.VetAllFullHealthRecoveredMessage = gameData.messages.meta.vet.all_full; + // Pond Messages.PondHeader = gameData.messages.meta.pond.header; Messages.PondGoFishing = gameData.messages.meta.pond.go_fishing;