mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 12:19:15 +12:00
Add HORSELEASER ....
This commit is contained in:
parent
ebb5b0edf8
commit
37faab1a6d
9 changed files with 709 additions and 78 deletions
|
@ -6,7 +6,7 @@ namespace HISP.Game.Horse
|
|||
{
|
||||
public class HorseInstance
|
||||
{
|
||||
public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0, string loadCategory="KEEPER", int loadMagicUsed=0, int loadAutoSell=0)
|
||||
public HorseInstance(HorseInfo.Breed breed, int randomId = -1, string loadName=null, string loadDescription = "", int loadSpoiled=0, string loadCategory="KEEPER", int loadMagicUsed=0, int loadAutoSell=0, int leaseTimer=0)
|
||||
{
|
||||
RandomId = RandomID.NextRandomId(randomId);
|
||||
Owner = 0;
|
||||
|
@ -36,9 +36,9 @@ namespace HISP.Game.Horse
|
|||
name = loadName;
|
||||
}
|
||||
if(GameServer.RandomNumberGenerator.Next(0, 100) > 50)
|
||||
Sex = breed.GenderTypes()[1];
|
||||
Gender = breed.GenderTypes()[1];
|
||||
else
|
||||
Sex = breed.GenderTypes()[0];
|
||||
Gender = breed.GenderTypes()[0];
|
||||
|
||||
description = loadDescription;
|
||||
Breed = breed;
|
||||
|
@ -55,13 +55,24 @@ namespace HISP.Game.Horse
|
|||
category = loadCategory;
|
||||
spoiled = loadSpoiled;
|
||||
magicUsed = loadMagicUsed;
|
||||
RanchId = 0;
|
||||
leaseTime = leaseTimer;
|
||||
Leaser = 0;
|
||||
}
|
||||
public int RanchId;
|
||||
public int Leaser;
|
||||
public int RandomId;
|
||||
public int Owner;
|
||||
public int LeaseTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return leaseTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
leaseTime = value;
|
||||
Database.SetLeaseTime(this.RandomId, leaseTime);
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
|
@ -86,7 +97,7 @@ namespace HISP.Game.Horse
|
|||
Database.SetHorseDescription(this.RandomId, description);
|
||||
}
|
||||
}
|
||||
public string Sex;
|
||||
public string Gender;
|
||||
public string Color;
|
||||
public int TrainTimer
|
||||
{
|
||||
|
@ -159,6 +170,7 @@ namespace HISP.Game.Horse
|
|||
private string name;
|
||||
private string description;
|
||||
private int spoiled;
|
||||
private int leaseTime;
|
||||
private int magicUsed;
|
||||
private int autosell;
|
||||
private string category;
|
||||
|
|
121
Horse Isle Server/HorseIsleServer/Game/Horse/Leaser.cs
Normal file
121
Horse Isle Server/HorseIsleServer/Game/Horse/Leaser.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
using HISP.Game.Items;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Horse
|
||||
{
|
||||
public class Leaser
|
||||
{
|
||||
public static List<Leaser> HorseLeasers = new List<Leaser>();
|
||||
public Leaser(int breedId, int saddle, int saddlePad, int bridle)
|
||||
{
|
||||
Breed = HorseInfo.GetBreedById(breedId);
|
||||
|
||||
if (saddle != -1)
|
||||
Saddle = Item.GetItemById(saddle);
|
||||
if (saddlePad != -1)
|
||||
SaddlePad = Item.GetItemById(saddlePad);
|
||||
if (bridle != -1)
|
||||
Bridle = Item.GetItemById(bridle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int LeaseId;
|
||||
public string ButtonId;
|
||||
public string Info;
|
||||
public string OnLeaseText;
|
||||
public int Price;
|
||||
public int Minutes;
|
||||
|
||||
// Horse
|
||||
|
||||
public HorseInfo.Breed Breed;
|
||||
public string HorseName;
|
||||
public string Color;
|
||||
public string Gender;
|
||||
|
||||
public int Health;
|
||||
public int Shoes;
|
||||
public int Hunger;
|
||||
public int Thirst;
|
||||
public int Mood;
|
||||
public int Groom;
|
||||
public int Tiredness;
|
||||
public int Experience;
|
||||
|
||||
public Item.ItemInformation Saddle = null;
|
||||
public Item.ItemInformation SaddlePad = null;
|
||||
public Item.ItemInformation Bridle = null;
|
||||
|
||||
public int Speed;
|
||||
public int Strength;
|
||||
public int Conformation;
|
||||
public int Agility;
|
||||
public int Inteligence;
|
||||
public int Endurance;
|
||||
public int Personality;
|
||||
public int Height;
|
||||
|
||||
public HorseInstance GenerateLeaseHorse()
|
||||
{
|
||||
HorseInstance instance = new HorseInstance(this.Breed, -1, null, "", 0, "LEASED", 0, 0, this.Minutes);
|
||||
instance.Name = this.HorseName;
|
||||
instance.Color = this.Color;
|
||||
instance.Gender = this.Gender;
|
||||
instance.Leaser = this.LeaseId;
|
||||
|
||||
instance.BasicStats = new HorseInfo.BasicStats(instance, Health, Shoes, Hunger, Thirst, Mood, Groom, Tiredness, Experience);
|
||||
instance.AdvancedStats = new HorseInfo.AdvancedStats(instance, Speed, Strength, Conformation, Agility, Inteligence, Endurance, Personality, Height);
|
||||
|
||||
instance.Equipment.Saddle = this.Saddle;
|
||||
instance.Equipment.SaddlePad = this.SaddlePad;
|
||||
instance.Equipment.Bridle = this.Bridle;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static bool LeaserButtonIdExists(string bid)
|
||||
{
|
||||
foreach (Leaser leaser in HorseLeasers)
|
||||
{
|
||||
if (leaser.ButtonId == bid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Leaser GetLeaserByButtonId(string bid)
|
||||
{
|
||||
foreach(Leaser leaser in HorseLeasers)
|
||||
{
|
||||
if(leaser.ButtonId == bid)
|
||||
{
|
||||
return leaser;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("No leaser with button id: " + bid + " found.");
|
||||
}
|
||||
|
||||
public static Leaser[] GetLeasersById(int id)
|
||||
{
|
||||
List<Leaser> leasers = new List<Leaser>();
|
||||
|
||||
foreach (Leaser leaser in HorseLeasers)
|
||||
{
|
||||
if (leaser.LeaseId == id)
|
||||
{
|
||||
leasers.Add(leaser);
|
||||
}
|
||||
}
|
||||
return leasers.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -19,6 +19,16 @@ namespace HISP.Game
|
|||
// Hammock
|
||||
public static string HammockText;
|
||||
|
||||
// Horse Leaser
|
||||
public static string HorseLeaserCantAffordMessage;
|
||||
public static string HorseLeaserTemporaryHorseAdded;
|
||||
public static string HorseLeaserHorsesFull;
|
||||
|
||||
public static string HorseLeaserReturnedToUniterPegasus;
|
||||
|
||||
public static string HorseLeaserReturnedToUniterFormat;
|
||||
public static string HorseLeaserReturnedToOwnerFormat;
|
||||
|
||||
// Horse Games
|
||||
public static string HorseGamesSelectHorse;
|
||||
public static string HorseGamesHorseEntryFormat;
|
||||
|
@ -451,6 +461,8 @@ namespace HISP.Game
|
|||
public static string HorseTrainableInFormat;
|
||||
public static string HorseIsTrainable;
|
||||
|
||||
public static string HorseLeasedRemainingTimeFormat;
|
||||
|
||||
public static string HorseCannotMountUntilTackedMessage;
|
||||
public static string HorseDismountedBecauseNotTackedMessageFormat;
|
||||
public static string HorseMountButtonFormat;
|
||||
|
@ -842,6 +854,16 @@ namespace HISP.Game
|
|||
|
||||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatHorseReturnedToOwner(string horseName)
|
||||
{
|
||||
return HorseLeaserReturnedToOwnerFormat.Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
public static string FormatHorseReturnedToUniter(string horseName)
|
||||
{
|
||||
return HorseLeaserReturnedToUniterFormat.Replace("%HORSENAME%", horseName);
|
||||
}
|
||||
|
||||
public static string FormatArenaCompetingHorseEntry(string userName, string horseName, int horseRandomId)
|
||||
{
|
||||
return ArenaCompetingHorseFormat.Replace("%USERNAME%", userName).Replace("%HORSENAME%", horseName).Replace("%HORSERANDOMID%", horseRandomId.ToString());
|
||||
|
@ -1482,6 +1504,10 @@ namespace HISP.Game
|
|||
{
|
||||
return HorseTrainableInFormat.Replace("%TIME%", minutes.ToString());
|
||||
}
|
||||
public static string FormatHorseIsLeased(int minutes)
|
||||
{
|
||||
return HorseLeasedRemainingTimeFormat.Replace("%TIME%", minutes.ToString());
|
||||
}
|
||||
|
||||
public static string FormatDisMountButton(int randomId)
|
||||
{
|
||||
|
|
|
@ -1801,7 +1801,7 @@ namespace HISP.Game
|
|||
string message = Messages.HorseAllBasicStats;
|
||||
foreach(HorseInstance horse in user.HorseInventory.HorseList)
|
||||
{
|
||||
message += Messages.FormaHorseAllBasicStatsEntry(horse.Name, horse.Color, horse.Breed.Name, horse.Sex, horse.BasicStats.Experience);
|
||||
message += Messages.FormaHorseAllBasicStatsEntry(horse.Name, horse.Color, horse.Breed.Name, horse.Gender, horse.BasicStats.Experience);
|
||||
message += Messages.FormatHorseBasicStat(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, horse.BasicStats.Tiredness, horse.BasicStats.Groom, horse.BasicStats.Shoes);
|
||||
}
|
||||
message += Messages.BackToMap;
|
||||
|
@ -1825,15 +1825,21 @@ namespace HISP.Game
|
|||
message += Messages.FormatHorseNameOthers(horse.Name);
|
||||
|
||||
message += Messages.FormatHorseDescription(horse.Description);
|
||||
message += Messages.FormatHorseHandsHigh(horse.Color, horse.Breed.Name, horse.Sex, HorseInfo.CalculateHands(horse.AdvancedStats.Height, false));
|
||||
message += Messages.FormatHorseHandsHigh(horse.Color, horse.Breed.Name, horse.Gender, HorseInfo.CalculateHands(horse.AdvancedStats.Height, false));
|
||||
message += Messages.FormatHorseExperience(horse.BasicStats.Experience);
|
||||
|
||||
|
||||
if (horse.TrainTimer > 0)
|
||||
message += Messages.FormatTrainableIn(horse.TrainTimer);
|
||||
else
|
||||
message += Messages.HorseIsTrainable;
|
||||
|
||||
if(horse.Leaser != 0)
|
||||
{
|
||||
message += Messages.FormatHorseIsLeased(horse.LeaseTime);
|
||||
}
|
||||
|
||||
if(isMyHorse)
|
||||
if (isMyHorse)
|
||||
{
|
||||
if (user.CurrentlyRidingHorse == null)
|
||||
message += Messages.FormatMountButton(horse.RandomId);
|
||||
|
@ -1842,33 +1848,45 @@ namespace HISP.Game
|
|||
|
||||
|
||||
message += Messages.FormatFeedButton(horse.RandomId);
|
||||
message += Messages.FormatTackButton(horse.RandomId);
|
||||
message += Messages.FormatPetButton(horse.RandomId);
|
||||
message += Messages.FormatProfileButton(horse.RandomId);
|
||||
|
||||
if (horse.Equipment.Saddle == null && horse.Equipment.SaddlePad == null && horse.Equipment.Bridle == null && horse.Equipment.Companion == null)
|
||||
if (horse.Leaser == 0)
|
||||
{
|
||||
string autoSellMessage = Messages.HorseNoAutoSell;
|
||||
if (horse.AutoSell > 0)
|
||||
autoSellMessage = Messages.FormatAutoSellPrice(horse.AutoSell);
|
||||
message += Messages.FormatAutoSell(autoSellMessage);
|
||||
if (horse.AutoSell > 0)
|
||||
message += Messages.HorseChangeAutoSell;
|
||||
message += Messages.FormatTackButton(horse.RandomId);
|
||||
}
|
||||
message += Messages.FormatPetButton(horse.RandomId);
|
||||
if (horse.Leaser == 0)
|
||||
{
|
||||
message += Messages.FormatProfileButton(horse.RandomId);
|
||||
|
||||
if (horse.Equipment.Saddle == null && horse.Equipment.SaddlePad == null && horse.Equipment.Bridle == null && horse.Equipment.Companion == null)
|
||||
{
|
||||
string autoSellMessage = Messages.HorseNoAutoSell;
|
||||
if (horse.AutoSell > 0)
|
||||
autoSellMessage = Messages.FormatAutoSellPrice(horse.AutoSell);
|
||||
message += Messages.FormatAutoSell(autoSellMessage);
|
||||
if (horse.AutoSell > 0)
|
||||
message += Messages.HorseChangeAutoSell;
|
||||
else
|
||||
message += Messages.HorseSetAutoSell;
|
||||
}
|
||||
else
|
||||
message += Messages.HorseSetAutoSell;
|
||||
{
|
||||
message += Messages.HorseCantAutoSellTacked;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
message += Messages.HorseCantAutoSellTacked;
|
||||
message += "^R1";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isMyHorse)
|
||||
message += Messages.FormatHorseCategory(horse.Category, Messages.HorseMarkAsCategory);
|
||||
else
|
||||
message += Messages.FormatHorseCategory(horse.Category, "");
|
||||
if (horse.Leaser == 0)
|
||||
{
|
||||
if (isMyHorse)
|
||||
message += Messages.FormatHorseCategory(horse.Category, Messages.HorseMarkAsCategory);
|
||||
else
|
||||
message += Messages.FormatHorseCategory(horse.Category, "");
|
||||
}
|
||||
|
||||
message += Messages.HorseStats;
|
||||
|
||||
|
@ -1884,15 +1902,18 @@ namespace HISP.Game
|
|||
if (horse.Equipment.Bridle != null)
|
||||
message += Messages.FormatHorseTackEntry(horse.Equipment.Bridle.IconId, horse.Equipment.Bridle.Name, horse.Equipment.Bridle.Id);
|
||||
|
||||
message += Messages.HorseCompanion;
|
||||
if (horse.Equipment.Companion != null)
|
||||
if(isMyHorse)
|
||||
message += Messages.FormatHorseCompanionEntry(horse.Equipment.Companion.IconId, horse.Equipment.Companion.Name, Messages.HorseCompanionChangeButton, horse.Equipment.Companion.Id);
|
||||
if(horse.Leaser == 0)
|
||||
{
|
||||
message += Messages.HorseCompanion;
|
||||
if (horse.Equipment.Companion != null)
|
||||
if (isMyHorse)
|
||||
message += Messages.FormatHorseCompanionEntry(horse.Equipment.Companion.IconId, horse.Equipment.Companion.Name, Messages.HorseCompanionChangeButton, horse.Equipment.Companion.Id);
|
||||
else
|
||||
message += Messages.FormatHorseCompanionEntry(horse.Equipment.Companion.IconId, horse.Equipment.Companion.Name, "", horse.Equipment.Companion.Id);
|
||||
else
|
||||
message += Messages.FormatHorseCompanionEntry(horse.Equipment.Companion.IconId, horse.Equipment.Companion.Name, "", horse.Equipment.Companion.Id);
|
||||
else
|
||||
if(isMyHorse)
|
||||
if (isMyHorse)
|
||||
message += Messages.HorseNoCompanion;
|
||||
}
|
||||
|
||||
message += Messages.FormatHorseAdvancedStats(horse.Spoiled, horse.MagicUsed);
|
||||
|
||||
|
@ -1916,23 +1937,25 @@ namespace HISP.Game
|
|||
message += Messages.FormatHorseHeight(Convert.ToInt32(Math.Floor(HorseInfo.CalculateHands(horse.Breed.BaseStats.MinHeight,false))), Convert.ToInt32(Math.Floor(HorseInfo.CalculateHands(horse.Breed.BaseStats.MaxHeight,false))));
|
||||
|
||||
message += Messages.FormatPossibleColors(horse.Breed.Colors);
|
||||
|
||||
if(isMyHorse)
|
||||
if (horse.Leaser == 0)
|
||||
{
|
||||
bool canRelease = true;
|
||||
if (World.InTown(user.X, user.Y))
|
||||
canRelease = false;
|
||||
|
||||
|
||||
if (World.InSpecialTile(user.X, user.Y))
|
||||
if (isMyHorse)
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(user.X, user.Y);
|
||||
if (tile.Code != null)
|
||||
bool canRelease = true;
|
||||
if (World.InTown(user.X, user.Y))
|
||||
canRelease = false;
|
||||
}
|
||||
|
||||
if (canRelease)
|
||||
message += Messages.FormatHorseReleaseButton(horse.Breed.Type.ToUpper());
|
||||
|
||||
if (World.InSpecialTile(user.X, user.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(user.X, user.Y);
|
||||
if (tile.Code != null)
|
||||
canRelease = false;
|
||||
}
|
||||
|
||||
if (canRelease)
|
||||
message += Messages.FormatHorseReleaseButton(horse.Breed.Type.ToUpper());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1962,7 +1985,7 @@ namespace HISP.Game
|
|||
HorseInfo.StatCalculator inteligenceStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.INTELIGENCE);
|
||||
HorseInfo.StatCalculator personalityStat = new HorseInfo.StatCalculator(horse, HorseInfo.StatType.PERSONALITY);
|
||||
|
||||
message += Messages.FormatAllStatsEntry(horse.Name, horse.Color, horse.Breed.Name, horse.Sex, horse.BasicStats.Experience);
|
||||
message += Messages.FormatAllStatsEntry(horse.Name, horse.Color, horse.Breed.Name, horse.Gender, horse.BasicStats.Experience);
|
||||
message += Messages.FormatCompactedBasicStats(horse.BasicStats.Health, horse.BasicStats.Hunger, horse.BasicStats.Thirst, horse.BasicStats.Mood, horse.BasicStats.Tiredness, horse.BasicStats.Groom, horse.BasicStats.Shoes);
|
||||
message += Messages.FormatCompactedAdvancedStats(speedStat.Total, strengthStat.Total, conformationStat.Total, agilityStat.Total, enduranceStat.Total, inteligenceStat.Total, personalityStat.Total);
|
||||
}
|
||||
|
@ -2079,7 +2102,7 @@ namespace HISP.Game
|
|||
}
|
||||
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);
|
||||
string message = Messages.FormatPawneerOrderHorseFound(instance.Breed.Name, instance.Color, instance.Gender, instance.AdvancedStats.Height, instance.AdvancedStats.Personality, instance.AdvancedStats.Inteligence);
|
||||
message += Messages.BackToMap;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
|
@ -2206,6 +2229,25 @@ namespace HISP.Game
|
|||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildLeaserOnLeaseInfo(Leaser leaser)
|
||||
{
|
||||
string mesasge = "";
|
||||
mesasge += leaser.OnLeaseText;
|
||||
mesasge += Messages.BackToMap;
|
||||
mesasge += Messages.MetaTerminator;
|
||||
return mesasge;
|
||||
}
|
||||
private static string buildLeaser(User user, Leaser[] leasers)
|
||||
{
|
||||
string message = "";
|
||||
foreach(Leaser leaser in leasers)
|
||||
{
|
||||
message += leaser.Info;
|
||||
}
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
public static string BuildComposeMailMenu()
|
||||
{
|
||||
string message = Messages.CityHallMailSendMeta;
|
||||
|
@ -2394,6 +2436,10 @@ namespace HISP.Game
|
|||
{
|
||||
message += buildTrainer(user, Trainer.GetTrainerById(int.Parse(TileArg)));
|
||||
}
|
||||
if(TileCode == "HORSELEASER")
|
||||
{
|
||||
message += buildLeaser(user, Leaser.GetLeasersById(int.Parse(TileArg)));
|
||||
}
|
||||
if (TileCode == "LIBRARY")
|
||||
{
|
||||
message += buildLibary();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue