no message

This commit is contained in:
SilicaAndPina 2020-10-26 14:18:33 +13:00
parent c3497a6582
commit d3b9cbf7a7
3 changed files with 22 additions and 11 deletions

View file

@ -138,7 +138,7 @@ namespace Horse_Isle_Server
return message;
}
public static string BuildInventoryInfo(IInventory inv)
public static string BuildInventoryInfo(PlayerInventory inv)
{
string message = "";
message += Messages.FormatPlayerInventoryHeaderMeta(inv.Count, Messages.DefaultInventoryMax);
@ -167,7 +167,7 @@ namespace Horse_Isle_Server
if (Item.IsThrowable(itemInfo.Id))
message += Messages.FormatItemThrowButton(randomId);
if(itemInfo.Type != "QUEST" || itemInfo.Type != "TEXT")
if (itemInfo.Type != "QUEST" && itemInfo.Type != "TEXT" && World.CanDropItems(inv.BaseUser.X, inv.BaseUser.Y))
message += Messages.FormatItemDropButton(randomId);
message += Messages.FormatItemInformationButton(randomId);
message += "^R1";

View file

@ -8,14 +8,14 @@ namespace Horse_Isle_Server
{
class PlayerInventory : IInventory
{
private User baseUser;
public User BaseUser;
private List<InventoryItem> inventoryItems;
public PlayerInventory(User forUser)
{
inventoryItems = new List<InventoryItem>();
baseUser = forUser;
ItemInstance[] instances = Database.GetPlayerInventory(baseUser.Id).ToArray();
BaseUser = forUser;
ItemInstance[] instances = Database.GetPlayerInventory(BaseUser.Id).ToArray();
foreach(ItemInstance instance in instances)
{
addItem(instance, false);
@ -32,7 +32,7 @@ namespace Horse_Isle_Server
private void addItem(ItemInstance item, bool addToDatabase)
{
if (addToDatabase)
Database.AddItemToInventory(baseUser.Id, item);
Database.AddItemToInventory(BaseUser.Id, item);
foreach (InventoryItem invetoryItem in inventoryItems)
{
@ -51,10 +51,6 @@ namespace Horse_Isle_Server
}
public void Add(ItemInstance item)
{
addItem(item, true);
}
public InventoryItem[] GetItemList()
@ -67,7 +63,7 @@ namespace Horse_Isle_Server
public void Remove(ItemInstance item)
{
Database.RemoveItemFromInventory(baseUser.Id, item);
Database.RemoveItemFromInventory(BaseUser.Id, item);
foreach (InventoryItem inventoryItem in inventoryItems)
{
@ -148,5 +144,9 @@ namespace Horse_Isle_Server
throw new KeyNotFoundException("random id: " + randomId + " not found in inventory");
}
public void Add(ItemInstance item)
{
addItem(item, true);
}
}
}

View file

@ -197,6 +197,17 @@ namespace Horse_Isle_Server
throw new KeyNotFoundException("x,y not in a town!");
}
public static bool CanDropItems(int x, int y)
{
if (World.InSpecialTile(x, y))
{
World.SpecialTile tile = World.GetSpecialTile(x, y);
if (tile.Code != null)
return false;
}
return true;
}
public static string GetWeather()
{
return Database.GetWorldWeather();