public bool AddMultipleOfItem(GameItem item, int amount) { if (totalItems >= maxSize && (item.IsStackable == false || HasItem(item) == false)) { return(false); } if (amount <= 0) { return(false); } if (item.IsStackable || AllItemsStack) { return(AddItemStackable(item, amount)); } else { for (int i = 0; i < amount; i++) { if (AddItem(item.Copy()) == false) { UpdateItemCount(); return(false); } } } UpdateItemCount(); return(true); }
public bool AddMultipleOfItem(GameItem item, int amount) { if (item == null || (totalItems >= maxSize && (item.IsStackable == false || HasItem(item) == false))) { //Console.WriteLine("Item was null:"+(item == null) + " total surpassed max size:" + (totalItems >= maxSize)); return(false); } if (amount <= 0) { return(false); } if (item.IsStackable || AllItemsStack) { return(AddItemStackable(item, amount)); } else { for (int i = 0; i < amount; i++) { if (AddItem(item.Copy()) == false) { UpdateItemCount(); return(false); } } } UpdateItemCount(); return(true); }
public bool FollowerGatherItem(GameItem item) { if (CurrentFollower != null && CurrentFollower.IsBanking == false) { if (CurrentFollower.Inventory.GetAvailableSpaces() <= 0) { CurrentFollower.SendToBank(); MessageManager.AddMessage(CurrentFollower.AutoCollectMessage.Replace("$", item.Name)); return(false); } else if (CurrentFollower.MeetsRequirements(item)) { CurrentFollower.Inventory.AddItem(item.Copy()); GainExperience(item.ExperienceGained); MessageManager.AddMessage(item.GatherString); return(true); } else { if (MessageManager.GetMessages().Any(x => x.Text.Contains(CurrentFollower.Name + " is unable to carry ")) == false) { MessageManager.AddMessage(CurrentFollower.Name + " is unable to carry " + item.Name + "."); } return(false); } } return(false); }
public bool PlayerGatherItem(GameItem item) { if (item == null) { return(false); } if (Inventory.AddItem(item.Copy()) == false) { if (CurrentFollower != null && CurrentFollower.IsBanking) { MessageManager.AddMessage("Your inventory is full. You wait for your follower to return from banking."); } else { MessageManager.AddMessage("Your inventory is full."); } return(false); } else { GainExperience(item.ExperienceGained); MessageManager.AddMessage(item.GatherString); } return(true); }
public void Deposit(GameItem item, int amount) { if (item == null) { return; } if (item.IsEquipped) { MessageManager.AddMessage("You'll need to unequip this item before banking it."); return; } int amountToBank = Math.Min(Player.Instance.Inventory.GetNumberOfItem(item), amount); Console.WriteLine("Amount to bank:" + amountToBank); Inventory.AddMultipleOfItem(item.Copy(), Player.Instance.Inventory.RemoveItems(item, amountToBank)); }
public void Deposit(GameItem item, int amount) { if (item == null) { return; } if (item.IsEquipped) { MessageManager.AddMessage("You'll need to unequip this item before banking it."); return; } if (item.IsLocked) { MessageManager.AddMessage("You'll need to unlock this item before banking it."); return; } int amountToBank = Math.Min(Player.Instance.Inventory.GetNumberOfItem(item), amount); Inventory.AddMultipleOfItem(item.Copy(), Player.Instance.Inventory.RemoveItems(item, amountToBank)); HasChanged = true; }
public void Withdraw(GameItem item, int amount) { if (item == null) { return; } int maxWithdraw = Math.Max(0, amount); //If the item is stackable and the player has a stack in their inventory already, or the player has space for another item if ((item.IsStackable && Player.Instance.Inventory.HasItem(item) && Player.Instance.Inventory.GetAvailableSpaces() == 0) || (item.IsStackable && Player.Instance.Inventory.GetAvailableSpaces() > 0)) { maxWithdraw = Math.Min(amount, Inventory.GetNumberOfItem(item)); } else { //Gets the smallest of the amount, inventory space, and number in the bank. maxWithdraw = Math.Min(Math.Min(amount, Player.Instance.Inventory.GetAvailableSpaces()), Inventory.GetNumberOfItem(item)); } if (Player.Instance.Inventory.AddMultipleOfItem(item.Copy(), maxWithdraw)) { Inventory.RemoveItems(item, maxWithdraw); } }