mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-23 05:05:53 +12:00
Add inns.
This commit is contained in:
parent
a0a328aa7d
commit
be56815996
17 changed files with 333 additions and 78 deletions
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace HISP.Game
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
|
||||
interface IInventory
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
class InventoryItem
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Game;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
|
||||
class PlayerInventory : IInventory
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using HISP.Game.Services;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HISP.Game
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
class ShopInventory : IInventory
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
{
|
||||
|
@ -55,6 +57,37 @@ namespace HISP.Game
|
|||
public static int Telescope;
|
||||
public static int Pitchfork;
|
||||
|
||||
public static bool ConsumeItem(User user, ItemInformation itmInfo)
|
||||
{
|
||||
|
||||
bool toMuch = false;
|
||||
foreach (Item.Effects effect in itmInfo.Effects)
|
||||
{
|
||||
switch (effect.EffectsWhat)
|
||||
{
|
||||
case "TIREDNESS":
|
||||
if (user.Tiredness + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Tiredness += effect.EffectAmount;
|
||||
break;
|
||||
case "THIRST":
|
||||
if (user.Thirst + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Thirst += effect.EffectAmount;
|
||||
break;
|
||||
case "HUNGER":
|
||||
if (user.Hunger + effect.EffectAmount > 1000)
|
||||
toMuch = true;
|
||||
user.Hunger += effect.EffectAmount;
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unknown effect: " + effect.EffectsWhat);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return toMuch;
|
||||
}
|
||||
public static bool IsThrowable(int id)
|
||||
{
|
||||
foreach(ThrowableItem itm in ThrowableItems)
|
||||
|
|
|
@ -281,6 +281,14 @@ namespace HISP.Game
|
|||
public static string LongFullLine;
|
||||
public static string MetaTerminator;
|
||||
|
||||
// Inn
|
||||
public static string InnBuyMeal;
|
||||
public static string InnBuyRest;
|
||||
public static string InnItemEntryFormat;
|
||||
public static string InnEnjoyedServiceFormat;
|
||||
public static string InnFullyRested;
|
||||
public static string InnCannotAffordService;
|
||||
|
||||
// Fountain
|
||||
public static string FountainMeta;
|
||||
public static string FountainDrankYourFull;
|
||||
|
@ -299,7 +307,14 @@ namespace HISP.Game
|
|||
|
||||
// Click
|
||||
public static string NothingInterestingHere;
|
||||
|
||||
public static string FormatInnEnjoyedServiceMessage(string item, int price)
|
||||
{
|
||||
return InnEnjoyedServiceFormat.Replace("%ITEM%", item).Replace("%PRICE%", price.ToString("N0"));
|
||||
}
|
||||
public static string FormatInnItemEntry(int iconId, string itemName, int price, int itemId)
|
||||
{
|
||||
return InnItemEntryFormat.Replace("%ICON%", iconId.ToString()).Replace("%NAME%", itemName).Replace("%PRICE%", price.ToString("N0")).Replace("%ID%", itemId.ToString());
|
||||
}
|
||||
public static string FormatDroppedMoneyMessage(int amount)
|
||||
{
|
||||
return FountainDroppedMoneyFormat.Replace("%MONEY%", amount.ToString("N0"));
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using HISP.Player;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Services;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -227,6 +229,23 @@ namespace HISP.Game
|
|||
return message;
|
||||
}
|
||||
|
||||
public static string buildInn(Inn inn)
|
||||
{
|
||||
string message = Messages.InnBuyMeal;
|
||||
foreach(Item.ItemInformation item in inn.MealsOffered)
|
||||
{
|
||||
message += Messages.FormatInnItemEntry(item.IconId, item.Name, inn.CalculateBuyCost(item), item.Id);
|
||||
}
|
||||
message += Messages.InnBuyRest;
|
||||
foreach (Item.ItemInformation item in inn.RestsOffered)
|
||||
{
|
||||
message += Messages.FormatInnItemEntry(item.IconId, item.Name, inn.CalculateBuyCost(item), item.Id);
|
||||
}
|
||||
message += Messages.ExitThisPlace;
|
||||
message += Messages.MetaTerminator;
|
||||
return message;
|
||||
}
|
||||
|
||||
public static string SelectPlayerStatFormat(int statValue)
|
||||
{
|
||||
int curValue = 1000;
|
||||
|
@ -606,6 +625,14 @@ namespace HISP.Game
|
|||
message += buildShopInfo(shop,user.Inventory);
|
||||
|
||||
}
|
||||
|
||||
if(TileCode == "INN")
|
||||
{
|
||||
int InnID = int.Parse(TileArg);
|
||||
Inn inn = Inn.GetInnById(InnID);
|
||||
user.LastVisitedInn = inn;
|
||||
message += buildInn(inn);
|
||||
}
|
||||
if(TileCode == "FOUNTAIN")
|
||||
{
|
||||
message += buildFountain();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Player;
|
||||
using HISP.Server;
|
||||
|
||||
|
|
84
Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs
Normal file
84
Horse Isle Server/Horse Isle Server/Game/Services/Inn.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using HISP.Player;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Inn
|
||||
{
|
||||
private static List<Inn> listInns = new List<Inn>();
|
||||
public static Inn[] Inns
|
||||
{
|
||||
get
|
||||
{
|
||||
return listInns.ToArray();
|
||||
}
|
||||
}
|
||||
public int Id;
|
||||
public Item.ItemInformation[] RestsOffered;
|
||||
public Item.ItemInformation[] MealsOffered;
|
||||
public int BuyPercentage;
|
||||
public int CalculateBuyCost(Item.ItemInformation item)
|
||||
{
|
||||
return (int)Math.Floor((float)item.SellPrice * (100.0 / (float)BuyPercentage));
|
||||
}
|
||||
|
||||
public Item.ItemInformation GetStockedItem(int itemId)
|
||||
{
|
||||
|
||||
// Check if inn stock.. (pun intended)
|
||||
foreach(Item.ItemInformation offering in RestsOffered)
|
||||
{
|
||||
if (offering.Id == itemId)
|
||||
return offering;
|
||||
}
|
||||
|
||||
foreach (Item.ItemInformation offering in MealsOffered)
|
||||
{
|
||||
if (offering.Id == itemId)
|
||||
return offering;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Item is not stocked by this inn.");
|
||||
}
|
||||
|
||||
|
||||
public Inn(int id, int[] restsOffered, int[] mealsOffered, int buyPercentage)
|
||||
{
|
||||
Id = id;
|
||||
List<Item.ItemInformation> itemInfos = new List<Item.ItemInformation>();
|
||||
|
||||
foreach(int itemId in restsOffered)
|
||||
{
|
||||
itemInfos.Add(Item.GetItemById(itemId));
|
||||
}
|
||||
|
||||
RestsOffered = itemInfos.ToArray();
|
||||
itemInfos.Clear();
|
||||
|
||||
foreach (int itemId in mealsOffered)
|
||||
{
|
||||
itemInfos.Add(Item.GetItemById(itemId));
|
||||
}
|
||||
MealsOffered = itemInfos.ToArray();
|
||||
|
||||
itemInfos.Clear();
|
||||
itemInfos = null;
|
||||
|
||||
BuyPercentage = buyPercentage;
|
||||
listInns.Add(this);
|
||||
}
|
||||
|
||||
public static Inn GetInnById(int id)
|
||||
{
|
||||
foreach (Inn inn in Inns)
|
||||
if (inn.Id == id)
|
||||
return inn;
|
||||
throw new KeyNotFoundException("Inn " + id + " doesnt exist.");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
using HISP.Server;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Shop
|
||||
{
|
|
@ -1,10 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Game
|
||||
namespace HISP.Game.Services
|
||||
{
|
||||
class Transport
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue