Add Horse Pawneer

and Pawneer Orders.
This commit is contained in:
SilicaAndPina 2021-02-15 13:31:00 +13:00
parent 2345b302fc
commit d9cdd05acb
12 changed files with 653 additions and 263 deletions
Horse Isle Server/HorseIsleServer/Game

View file

@ -480,7 +480,7 @@ namespace HISP.Game.Horse
private int experience;
}
public struct Breed
public class Breed
{
public int Id;
public string Name;
@ -491,8 +491,29 @@ namespace HISP.Game.Horse
public string SpawnInArea;
public string Swf;
public string Type;
}
public string[] GenderTypes()
{
string[] options = new string[2];
if (Type == "camel")
{
options[0] = "cow";
options[1] = "bull";
}
else if (Type == "llama")
{
options[0] = "male";
options[1] = "female";
}
else
{
options[0] = "stallion";
options[1] = "mare";
}
return options;
}
}
public struct HorseEquips
{
public Item.ItemInformation Saddle;

View file

@ -16,51 +16,19 @@ namespace HISP.Game.Horse
if (breed.Type == "camel")
{
name = "Wild Camel";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "cow";
}
else
{
Sex = "bull";
}
}
else if (breed.Type == "llama")
{
name = "Jungle Llama";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "male";
}
else
{
Sex = "female";
}
}
else if (breed.Type == "zebra")
{
name = "Wild Zebra";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
}
}
else
{
name = "Wild Horse";
if (GameServer.RandomNumberGenerator.Next(0, 100) >= 50)
{
Sex = "stallion";
}
else
{
Sex = "mare";
}
}
}
else
@ -68,6 +36,8 @@ namespace HISP.Game.Horse
name = loadName;
}
Sex = breed.GenderTypes()[GameServer.RandomNumberGenerator.Next(0, 1)];
description = loadDescription;
Breed = breed;
Color = breed.Colors[GameServer.RandomNumberGenerator.Next(0, breed.Colors.Length)];

View file

@ -92,11 +92,7 @@ namespace HISP.Game.Items
return pos;
}
}
private static string capitalizeFirstLetter(string str)
{
char firstChar = char.ToUpper(str[0]);
return firstChar + str.Substring(1);
}
private static List<TackSet> tackSets = new List<TackSet>();
public static TackSet[] TackSets
{
@ -126,14 +122,13 @@ namespace HISP.Game.Items
try
{
TackSet set = GetSetByName(capitalizeFirstLetter(itemInfo.EmbedSwf));
TackSet set = GetSetByName(Converters.CapitalizeFirstLetter(itemInfo.EmbedSwf));
set.Add(itemInfo);
}
catch(KeyNotFoundException)
{
TackSet tackSet = new TackSet();
tackSet.SetName = capitalizeFirstLetter(itemInfo.EmbedSwf);
Logger.DebugPrint("Created Tack Set: "+tackSet.SetName);
tackSet.SetName = Converters.CapitalizeFirstLetter(itemInfo.EmbedSwf);
tackSet.Add(itemInfo);
tackSets.Add(tackSet);
}

View file

@ -313,6 +313,7 @@ namespace HISP.Game
public static string HorseCaptureTimer;
public static string YouCapturedTheHorse;
public static string HorseEvadedCapture;
public static string HorseEscapedAnyway;
public static string TooManyHorses;
public static string HorsesMenuHeader;
public static string UpdateHorseCategory;
@ -643,6 +644,25 @@ namespace HISP.Game
public static string LongFullLine;
public static string MetaTerminator;
// Pawneer
public static string PawneerUntackedHorsesICanBuy;
public static string PawneerHorseFormat;
public static string PawneerOrderMeta;
public static string PawneerHorseConfirmationFormat;
public static string PawneerHorseSoldMessagesFormat;
public static string PawneerHorseNotFound;
public static string PawneerOrderSelectBreed;
public static string PawneerOrderBreedEntryFormat;
public static string PawneerOrderSelectColorFormat;
public static string PawneerOrderColorEntryFormat;
public static string PawneerOrderSelectGenderFormat;
public static string PawneerOrderGenderEntryFormat;
public static string PawneerOrderHorseFoundFormat;
// Shortcuts
public static string NoTelescope;
@ -702,6 +722,43 @@ namespace HISP.Game
// Click
public static string NothingInterestingHere;
public static string FormatPawneerOrderHorseFound(string breedName, string color, string gender, int height, int personality, int inteligence)
{
return PawneerOrderHorseFoundFormat.Replace("%BREEDNAME%", breedName).Replace("%COLOR%", color).Replace("%GENDER%", gender).Replace("%HEIGHT%", height.ToString()).Replace("%PERSONALITY%", personality.ToString()).Replace("%INTELIGENCE%", inteligence.ToString());
}
public static string FormatPawneerOrderGenderEntry(string genderName, string genderInternal)
{
return PawneerOrderGenderEntryFormat.Replace("%GENDERNAME%", genderName).Replace("%GENDERINTERNAL%", genderInternal);
}
public static string FormatPawneerOrderSelectGender(string color, string breedName)
{
return PawneerOrderSelectGenderFormat.Replace("%BREEDNAME%", breedName).Replace("%COLOR%", color);
}
public static string FormatPawneerOrderColorEntry(string color)
{
return PawneerOrderColorEntryFormat.Replace("%COLOR%", color);
}
public static string FormatPawneerOrderSelectColor(string breedName)
{
return PawneerOrderSelectColorFormat.Replace("%BREEDNAME%", breedName);
}
public static string FormatPawneerOrderBreedEntry(string breedName, int breedId)
{
return PawneerOrderBreedEntryFormat.Replace("%BREEDNAME%", breedName).Replace("%BREEDID%", breedId.ToString());
}
public static string FormatPawneerHorseEntry(string horseName, int price, int randomId)
{
return PawneerHorseFormat.Replace("%HORSENAME%", horseName).Replace("%PRICE%", price.ToString("N0")).Replace("%RANDOMID%", randomId.ToString());
}
public static string FormatPawneerConfirmPawn(string breedName, int randomId)
{
return PawneerHorseConfirmationFormat.Replace("%BREEDNAME%", breedName).Replace("%RANDOMID%", randomId.ToString());
}
public static string FormatPawneerSold(string horseName, int price)
{
return PawneerHorseSoldMessagesFormat.Replace("%HORSENAME%", horseName).Replace("%PRICE%", price.ToString("N0"));
}
public static string FormatPlayerHereMessage(string playerName)

View file

@ -1430,7 +1430,13 @@ namespace HISP.Game
message += Messages.MetaTerminator;
return message;
}
public static string BuildHorseEscapedAnyway()
{
string message = Messages.HorseEscapedAnyway;
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildHorseCaughtMessage()
{
string message = Messages.YouCapturedTheHorse;
@ -1879,6 +1885,74 @@ namespace HISP.Game
message += buildCommonInfo(x, y);
return message;
}
public static string BuildPawneerOrderFound(HorseInstance instance)
{
string message = Messages.FormatPawneerOrderHorseFound(instance.Breed.Name, instance.Color, instance.Sex, instance.AdvancedStats.Height, instance.AdvancedStats.Personality, instance.AdvancedStats.Inteligence);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildPawneerOrderGenderList(HorseInfo.Breed breed, string color)
{
string message = Messages.FormatPawneerOrderSelectGender(color, breed.Name);
foreach (string gender in breed.GenderTypes())
message += Messages.FormatPawneerOrderGenderEntry(Converters.CapitalizeFirstLetter(gender), gender);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildPawneerOrderColorList(HorseInfo.Breed breed)
{
string message = Messages.FormatPawneerOrderSelectColor(breed.Name);
foreach (string color in breed.Colors)
message += Messages.FormatPawneerOrderColorEntry(color);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildPawneerOrderBreedList()
{
string message = Messages.PawneerOrderSelectBreed;
foreach (HorseInfo.Breed breed in HorseInfo.Breeds.OrderBy(o => o.Name).ToList())
{
if (breed.Swf == "")
continue;
if (breed.SpawnInArea == "none")
continue;
message += Messages.FormatPawneerOrderBreedEntry(breed.Name, breed.Id);
}
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
public static string BuildPawneerConfimation(HorseInstance horse)
{
string message = "";
message += Messages.FormatPawneerConfirmPawn(horse.Breed.Name, horse.RandomId);
message += Messages.BackToMap;
message += Messages.MetaTerminator;
return message;
}
private static string buildPawneer(User user)
{
string message = "";
if (user.Inventory.HasItemId(Item.PawneerOrder))
message += Messages.PawneerOrderMeta;
message += Messages.PawneerUntackedHorsesICanBuy;
foreach(HorseInstance horse in user.HorseInventory.HorseList)
{
if(horse.Category == "TRADING" && horse.Equipment.Bridle == null && horse.Equipment.Saddle == null && horse.Equipment.SaddlePad == null && horse.Equipment.Companion == null)
{
message += Messages.FormatPawneerHorseEntry(horse.Name, Pawneer.CalculateTotalPrice(horse), horse.RandomId);
}
}
message += Messages.ExitThisPlace;
message += Messages.MetaTerminator;
return message;
}
public static string BuildSpecialTileInfo(User user, World.SpecialTile specialTile)
{
string message = "";
@ -1961,6 +2035,10 @@ namespace HISP.Game
{
message += buildWishingWell(user);
}
if(TileCode == "HORSEPAWNEER")
{
message += buildPawneer(user);
}
if (TileCode == "VENUSFLYTRAP")
{
message += buildVenusFlyTrap(user);

View file

@ -0,0 +1,57 @@
using HISP.Game.Horse;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HISP.Game.Services
{
public class Pawneer
{
public Pawneer(int breedId, int basePrice)
{
BreedId = breedId;
BasePrice = basePrice;
}
public static List<Pawneer> PawneerPriceModels = new List<Pawneer>();
public int BreedId;
public int BasePrice;
public static int GetPawneerBasePriceForHorse(HorseInfo.Breed breed)
{
foreach (Pawneer ppm in PawneerPriceModels)
{
if (ppm.BreedId == breed.Id)
{
return ppm.BasePrice;
}
}
throw new Exception("No pawneeer base price found >_> for breed #" + breed.Id + " " + breed.Name);
}
public static int CalculateTotalPrice(HorseInstance horse)
{
HorseInfo.StatCalculator speedStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.SPEED);
HorseInfo.StatCalculator strengthStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.STRENGTH);
HorseInfo.StatCalculator conformationStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.CONFORMATION);
HorseInfo.StatCalculator agilityStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.AGILITY);
HorseInfo.StatCalculator enduranceStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.ENDURANCE);
int basePrice = GetPawneerBasePriceForHorse(horse.Breed);
int additionalPrice = speedStat.BreedOffset * 350;
additionalPrice += strengthStat.BreedOffset * 350;
additionalPrice += conformationStat.BreedOffset * 350;
additionalPrice += agilityStat.BreedOffset * 350;
additionalPrice += enduranceStat.BreedOffset * 350;
additionalPrice += horse.BasicStats.Health * 40;
additionalPrice += horse.BasicStats.Shoes * 20;
int price = basePrice + additionalPrice;
return price;
}
}
}