mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 21:25:52 +12:00
Add barns!
This commit is contained in:
parent
62a2e64ea5
commit
e32dabb1b4
7 changed files with 267 additions and 13 deletions
48
Horse Isle Server/HorseIsleServer/Game/Services/Barn.cs
Normal file
48
Horse Isle Server/HorseIsleServer/Game/Services/Barn.cs
Normal 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!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue