Add HORSELEASER ....

This commit is contained in:
SilicaAndPina 2021-02-19 00:45:47 +13:00
parent ebb5b0edf8
commit 37faab1a6d
9 changed files with 709 additions and 78 deletions

View file

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

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