Add barns!

This commit is contained in:
SilicaAndPina 2021-02-13 14:29:33 +13:00
parent 62a2e64ea5
commit e32dabb1b4
7 changed files with 267 additions and 13 deletions

View file

@ -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)
{

View file

@ -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 >-<

View 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!");
}
}
}