mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Add barns!
This commit is contained in:
parent
62a2e64ea5
commit
e32dabb1b4
7 changed files with 267 additions and 13 deletions
|
@ -264,6 +264,17 @@
|
|||
"all_full":"Your horses are now all at full health!",
|
||||
"cant_afford":"You cannot afford the vet's services at this time."
|
||||
},
|
||||
"barn":{
|
||||
"fully_fed":"Your horse %HORSENAME% is now fully rested and fed!",
|
||||
"cant_afford":"You cannot afford the barn's services at this time.",
|
||||
"rested_all":"Your horses are all now fully rested and fed!",
|
||||
"not_needed":"Your horses do not require any barn services right now.",
|
||||
|
||||
"horse_status":"^LYour horse %HORSENAME%: (tired %TIREDNESS%)(hunger %HUNGER%) (thirst %THIRST%)^R1",
|
||||
"horse_maxed":"^I241^T9This barn cannot help this horse in any way.^R1",
|
||||
"let_relax":"^I241^T8Let the horse relax for $%PRICE% ^B3B%RANDOMID%^R1",
|
||||
"relax_all":"^R1^LYou could also rest all of your horses at once:^R1^I241^T7Let all the horses relax for $%PRICE% ^B3H^R1^"
|
||||
},
|
||||
"pond":{
|
||||
"header":"^LYou can go fishing at this pond!^R1",
|
||||
"go_fishing":"^T6Go Fishing!^BMfishing^R5",
|
||||
|
@ -894,6 +905,14 @@
|
|||
}
|
||||
},
|
||||
"services":{
|
||||
"barn":{
|
||||
"price_multipliers":[
|
||||
{"id":1,"tired_cost":0.2,"hunger_cost":0.5, "thirst_cost":0.2},
|
||||
{"id":2,"tired_cost":0.3,"hunger_cost":0.6, "thirst_cost":0.3},
|
||||
{"id":3,"tired_cost":0.4,"hunger_cost":0.7, "thirst_cost":0.3},
|
||||
{"id":4,"tired_cost":0.5,"hunger_cost":0.8, "thirst_cost":0.4}
|
||||
]
|
||||
},
|
||||
"vet":{
|
||||
"price_multipliers":[
|
||||
{"id":1,"cost":0.5},
|
||||
|
|
|
@ -459,6 +459,17 @@ namespace HISP.Game
|
|||
public static string VetAllFullHealthRecoveredMessage;
|
||||
public static string VetCannotAffordMessage;
|
||||
|
||||
// Barn
|
||||
public static string BarnHorseFullyFedFormat;
|
||||
public static string BarnCantAffordService;
|
||||
public static string BarnAllHorsesFullyFed;
|
||||
public static string BarnServiceNotNeeded;
|
||||
|
||||
public static string BarnHorseStatusFormat;
|
||||
public static string BarnHorseMaxed;
|
||||
public static string BarnLetHorseRelaxFormat;
|
||||
public static string BarnLetAllHorsesReleaxFormat;
|
||||
|
||||
// Horse Whisperer
|
||||
|
||||
public static string WhispererHorseLocateButtonFormat;
|
||||
|
@ -693,6 +704,23 @@ namespace HISP.Game
|
|||
return PlayerHereFormat.Replace("%USERNAME%", playerName);
|
||||
}
|
||||
|
||||
// Barn Formats
|
||||
public static string FormatBarnLetAllHorsesReleax(int price)
|
||||
{
|
||||
return BarnLetAllHorsesReleaxFormat.Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
public static string FormatBarnLetHorseRelax(int price, int randomId)
|
||||
{
|
||||
return BarnLetHorseRelaxFormat.Replace("%PRICE%", price.ToString("N0")).Replace("%RANDOMID%", randomId.ToString());
|
||||
}
|
||||
public static string FormatBarnHorseStatus(string horseName, int tiredness, int hunger, int thirst)
|
||||
{
|
||||
return BarnHorseStatusFormat.Replace("%HORSENAME%", horseName).Replace("%TIREDNESS%", tiredness.ToString()).Replace("%HUNGER%", hunger.ToString()).Replace("%THIRST%", thirst.ToString());
|
||||
}
|
||||
public static string FormatBarnHorseFullyFed(string horseName)
|
||||
{
|
||||
return BarnHorseFullyFedFormat.Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
// Farrier Formats
|
||||
public static string FormatFarrierPutOnSteelShoesAllMesssage(int curShoes, int maxShoes)
|
||||
{
|
||||
|
|
|
@ -1334,7 +1334,7 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildVet(Vet vet, User user)
|
||||
private static string buildVet(User user, Vet vet)
|
||||
{
|
||||
string message = "";
|
||||
int totalPrice = 0;
|
||||
|
@ -1358,6 +1358,31 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildBarn(User user, Barn barn)
|
||||
{
|
||||
string message = "";
|
||||
int totalPrice = 0;
|
||||
foreach (HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
message += Messages.FormatBarnHorseStatus(horse.Name, horse.BasicStats.Tiredness, horse.BasicStats.Hunger, horse.BasicStats.Thirst);
|
||||
|
||||
int price = barn.CalculatePrice(horse.BasicStats.Tiredness, horse.BasicStats.Hunger, horse.BasicStats.Thirst);
|
||||
if(price > 0)
|
||||
{
|
||||
totalPrice += price;
|
||||
message += Messages.FormatBarnLetHorseRelax(price, horse.RandomId);
|
||||
}
|
||||
else
|
||||
{
|
||||
message += Messages.BarnHorseMaxed;
|
||||
}
|
||||
|
||||
}
|
||||
message += Messages.FormatBarnLetAllHorsesReleax(totalPrice);
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
private static string buildFarrier(User user, Farrier farrier)
|
||||
{
|
||||
string message = "";
|
||||
|
@ -1910,15 +1935,19 @@ namespace HISP.Game
|
|||
}
|
||||
if (TileCode == "VET")
|
||||
{
|
||||
int VetId = int.Parse(TileArg);
|
||||
Vet vet = Vet.GetVetById(VetId);
|
||||
message += buildVet(vet, user);
|
||||
message += buildVet(user, Vet.GetVetById(int.Parse(TileArg)));
|
||||
}
|
||||
if(TileCode == "GROOMER")
|
||||
{
|
||||
int groomId = int.Parse(TileArg);
|
||||
Groomer groomer = Groomer.GetGroomerById(groomId);
|
||||
message += buildGroomer(user, groomer);
|
||||
message += buildGroomer(user, Groomer.GetGroomerById(int.Parse(TileArg)));
|
||||
}
|
||||
if (TileCode == "FARRIER")
|
||||
{
|
||||
message += buildFarrier(user, Farrier.GetFarrierById(int.Parse(TileArg)));
|
||||
}
|
||||
if(TileCode == "BARN")
|
||||
{
|
||||
message += buildBarn(user, Barn.GetBarnById(int.Parse(TileArg)));
|
||||
}
|
||||
if (TileCode == "BANK")
|
||||
{
|
||||
|
@ -1956,10 +1985,6 @@ namespace HISP.Game
|
|||
{
|
||||
message += buildRanch(user, int.Parse(TileArg));
|
||||
}
|
||||
if(TileCode == "FARRIER")
|
||||
{
|
||||
message += buildFarrier(user, Farrier.GetFarrierById(int.Parse(TileArg)));
|
||||
}
|
||||
if (TileCode == "MULTIROOM")
|
||||
{
|
||||
user.MetaPriority = false; // acturally want to track updates here >-<
|
||||
|
|
48
Horse Isle Server/HorseIsleServer/Game/Services/Barn.cs
Normal file
48
Horse Isle Server/HorseIsleServer/Game/Services/Barn.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
public class Barn
|
||||
{
|
||||
public Barn(int id, double tiredCost, double hungerCost, double thirstCost)
|
||||
{
|
||||
this.Id = id;
|
||||
this.TiredCost = tiredCost;
|
||||
this.HungerCost = hungerCost;
|
||||
this.ThirstCost = thirstCost;
|
||||
barns.Add(this);
|
||||
}
|
||||
private static List<Barn> barns = new List<Barn>();
|
||||
public static Barn[] Barns
|
||||
{
|
||||
get
|
||||
{
|
||||
return barns.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public int Id;
|
||||
public double TiredCost;
|
||||
public double HungerCost;
|
||||
public double ThirstCost;
|
||||
public int CalculatePrice(int tiredness, int hunger, int thirst)
|
||||
{
|
||||
double tiredPrice = (1000.0 - (double)tiredness) * TiredCost;
|
||||
double hungerPrice = (1000.0 - (double)hunger) * HungerCost;
|
||||
double thirstPrice = (1000.0 - (double)thirst) * ThirstCost;
|
||||
return Convert.ToInt32(Math.Round(tiredPrice + hungerPrice + thirstPrice));
|
||||
}
|
||||
public static Barn GetBarnById(int id)
|
||||
{
|
||||
foreach (Barn barn in Barns)
|
||||
if (barn.Id == id)
|
||||
return barn;
|
||||
throw new KeyNotFoundException("Barn id: " + id.ToString() + " Not found!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -530,6 +530,7 @@ namespace HISP.Server
|
|||
Vet vet = new Vet(id, cost);
|
||||
Logger.DebugPrint("Registered Vet: " + vet.Id + " selling at: " + vet.PriceMultiplier.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
int totalGroomers = gameData.services.groomer.price_multipliers.Count;
|
||||
for (int i = 0; i < totalGroomers; i++)
|
||||
{
|
||||
|
@ -553,6 +554,19 @@ namespace HISP.Server
|
|||
Logger.DebugPrint("Registered Farrier: " + farrier.Id);
|
||||
}
|
||||
|
||||
int totalBarns = gameData.services.barn.price_multipliers.Count;
|
||||
for (int i = 0; i < totalBarns; i++)
|
||||
{
|
||||
int id = gameData.services.barn.price_multipliers[i].id;
|
||||
double tired_cost = gameData.services.barn.price_multipliers[i].tired_cost;
|
||||
double hunger_cost = gameData.services.barn.price_multipliers[i].hunger_cost;
|
||||
double thirst_cost = gameData.services.barn.price_multipliers[i].thirst_cost;
|
||||
|
||||
|
||||
Barn barn = new Barn(id, tired_cost, hunger_cost, thirst_cost);
|
||||
Logger.DebugPrint("Registered Barn: " + barn.Id);
|
||||
}
|
||||
|
||||
|
||||
// Register Libary Books
|
||||
int totalBooks = gameData.books.Count;
|
||||
|
@ -852,11 +866,21 @@ namespace HISP.Server
|
|||
Messages.GroomerBestToHisAbilitiesALL = gameData.messages.meta.groomer.groomed_best_all;
|
||||
Messages.GroomerDontNeed = gameData.messages.meta.groomer.dont_need;
|
||||
|
||||
|
||||
Messages.GroomerHorseCurrentlyAtFormat = gameData.messages.meta.groomer.currently_at;
|
||||
Messages.GroomerApplyServiceFormat = gameData.messages.meta.groomer.apply_service;
|
||||
Messages.GroomerApplyServiceForAllFormat = gameData.messages.meta.groomer.apply_all;
|
||||
|
||||
// Barn
|
||||
Messages.BarnHorseFullyFedFormat = gameData.messages.meta.barn.fully_fed;
|
||||
Messages.BarnCantAffordService = gameData.messages.meta.barn.cant_afford;
|
||||
Messages.BarnAllHorsesFullyFed = gameData.messages.meta.barn.rested_all;
|
||||
Messages.BarnServiceNotNeeded = gameData.messages.meta.barn.not_needed;
|
||||
|
||||
Messages.BarnHorseStatusFormat = gameData.messages.meta.barn.horse_status;
|
||||
Messages.BarnHorseMaxed = gameData.messages.meta.barn.horse_maxed;
|
||||
Messages.BarnLetHorseRelaxFormat = gameData.messages.meta.barn.let_relax;
|
||||
Messages.BarnLetAllHorsesReleaxFormat = gameData.messages.meta.barn.relax_all;
|
||||
|
||||
// Farrier
|
||||
Messages.FarrierCurrentShoesFormat = gameData.messages.meta.farrier.current_shoes;
|
||||
Messages.FarrierApplyIronShoesFormat = gameData.messages.meta.farrier.apply_iron;
|
||||
|
|
|
@ -545,6 +545,114 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PacketBuilder.HORSE_BARN_SERVICE:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
randomIdStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
|
||||
if (randomIdStr == "NaN")
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
randomId = int.Parse(randomIdStr);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid randomid to horse interaction packet ");
|
||||
break;
|
||||
}
|
||||
if (sender.LoggedinUser.HorseInventory.HorseIdExist(randomId))
|
||||
{
|
||||
HorseInstance barnHorseInst = sender.LoggedinUser.HorseInventory.GetHorseById(randomId);
|
||||
sender.LoggedinUser.LastViewedHorse = barnHorseInst;
|
||||
|
||||
if (World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if (tile.Code.StartsWith("BARN-"))
|
||||
{
|
||||
string[] barnInfo = tile.Code.Split('-');
|
||||
int barnId = int.Parse(barnInfo[1]);
|
||||
|
||||
Barn barn = Barn.GetBarnById(barnId);
|
||||
int price = barn.CalculatePrice(barnHorseInst.BasicStats.Tiredness, barnHorseInst.BasicStats.Hunger, barnHorseInst.BasicStats.Thirst); ;
|
||||
|
||||
|
||||
if (sender.LoggedinUser.Money >= price)
|
||||
{
|
||||
barnHorseInst.BasicStats.Tiredness = 1000;
|
||||
barnHorseInst.BasicStats.Hunger = 1000;
|
||||
barnHorseInst.BasicStats.Thirst = 1000;
|
||||
sender.LoggedinUser.Money -= price;
|
||||
|
||||
byte[] messagePacket = PacketBuilder.CreateChat(Messages.FormatBarnHorseFullyFed(barnHorseInst.Name), PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(messagePacket);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.BarnCantAffordService, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cantAffordMessage);
|
||||
break;
|
||||
}
|
||||
UpdateArea(sender);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to use groomer services on a non existant horse.");
|
||||
break;
|
||||
}
|
||||
case PacketBuilder.HORSE_BARN_SERVICE_ALL:
|
||||
if (World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if (tile.Code.StartsWith("BARN-"))
|
||||
{
|
||||
string[] barnInfo = tile.Code.Split('-');
|
||||
int barnId = int.Parse(barnInfo[1]);
|
||||
Barn barn = Barn.GetBarnById(barnId);
|
||||
int totalPrice = 0;
|
||||
|
||||
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
|
||||
{
|
||||
int price = barn.CalculatePrice(horse.BasicStats.Tiredness, horse.BasicStats.Hunger, horse.BasicStats.Thirst);
|
||||
if (price > 0)
|
||||
totalPrice += price;
|
||||
}
|
||||
if (totalPrice == 0)
|
||||
{
|
||||
byte[] notNeededMessagePacket = PacketBuilder.CreateChat(Messages.BarnServiceNotNeeded, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(notNeededMessagePacket);
|
||||
break;
|
||||
}
|
||||
else if (sender.LoggedinUser.Money >= totalPrice)
|
||||
{
|
||||
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
|
||||
{
|
||||
horse.BasicStats.Tiredness = 1000;
|
||||
horse.BasicStats.Thirst = 1000;
|
||||
horse.BasicStats.Hunger = 1000;
|
||||
}
|
||||
|
||||
byte[] barnedAllHorsesPacket = PacketBuilder.CreateChat(Messages.BarnAllHorsesFullyFed, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(barnedAllHorsesPacket);
|
||||
|
||||
sender.LoggedinUser.Money -= totalPrice;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] cannotAffordMessagePacket = PacketBuilder.CreateChat(Messages.BarnCantAffordService, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cannotAffordMessagePacket);
|
||||
break;
|
||||
}
|
||||
UpdateArea(sender);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PacketBuilder.HORSE_GIVE_FEED:
|
||||
randomId = 0;
|
||||
packetStr = Encoding.UTF8.GetString(packet);
|
||||
|
|
|
@ -74,10 +74,12 @@ namespace HISP.Server
|
|||
public const byte HORSE_VET_SERVICE_ALL = 0x2F;
|
||||
public const byte HORSE_GROOM_SERVICE_ALL = 0x33;
|
||||
public const byte HORSE_GROOM_SERVICE = 0x32;
|
||||
public const byte HORSE_MOUNT = 0x46;
|
||||
public const byte HORSE_BARN_SERVICE = 0x37;
|
||||
public const byte HORSE_BARN_SERVICE_ALL = 0x38;
|
||||
public const byte HORSE_SHOE_IRON = 0x28;
|
||||
public const byte HORSE_SHOE_STEEL = 0x29;
|
||||
public const byte HORSE_SHOE_ALL = 0x2E;
|
||||
public const byte HORSE_MOUNT = 0x46;
|
||||
public const byte HORSE_DISMOUNT = 0x47;
|
||||
public const byte HORSE_ESCAPE = 0x1E;
|
||||
public const byte HORSE_CAUGHT = 0x1D;
|
||||
|
|
Loading…
Add table
Reference in a new issue