check if cant afford services

This commit is contained in:
AtelierWindows 2021-01-24 21:07:37 +13:00
parent c884ae1e3a
commit c57d7079d9
3 changed files with 13 additions and 6 deletions

View file

@ -136,7 +136,7 @@
"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":"^I257^T6Apply vet services for $%PRICE% ^B3V%RANDOMID%^R1",
"apply_all":"^R1^I257^T6Apply all vet services for $%PRICE% ^B3v^R1",
"now_full_health":"Your horse %HORSENAME% is now at full health!",

View file

@ -22,8 +22,8 @@ namespace HISP.Game.Services
public double PriceMultiplier;
public int CalculatePrice(int health)
{
double price = ((double)health - 1000.0) * PriceMultiplier;
return Convert.ToInt32(Math.Floor(price));
double price = (1000.0 - (double)health) * PriceMultiplier;
return Convert.ToInt32(Math.Round(price));
}
public static Vet GetVetById(int id)

View file

@ -211,8 +211,13 @@ namespace HISP.Server
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
price += vet.CalculatePrice(horse.BasicStats.Health);
if (sender.LoggedinUser.Money >= price)
if(price == 0)
{
byte[] notNeededMessagePacket = PacketBuilder.CreateChat(Messages.VetServicesNotNeededAll, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(notNeededMessagePacket);
break;
}
else if (sender.LoggedinUser.Money >= price)
{
foreach (HorseInstance horse in sender.LoggedinUser.HorseInventory.HorseList)
horse.BasicStats.Health = 1000;
@ -227,7 +232,9 @@ namespace HISP.Server
{
byte[] cannotAffordMessagePacket = PacketBuilder.CreateChat(Messages.VetCannotAffordMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cannotAffordMessagePacket);
break;
}
UpdateArea(sender);
}
}
break;
@ -276,9 +283,9 @@ namespace HISP.Server
byte[] cantAffordMessage = PacketBuilder.CreateChat(Messages.VetCannotAffordMessage, PacketBuilder.CHAT_BOTTOM_RIGHT);
sender.SendPacket(cantAffordMessage);
}
UpdateArea(sender);
}
}
break;
}
else