Ejemplo n.º 1
0
 private CommandResponse DropItem(string itemLabel, Inventory locationItems, Player player)
 {
     if (itemLabel != "gold" && player.Inventory.ItemList.ContainsKey(itemLabel) == false)
         return new CommandResponse("There is no such item");
     else
     {
         return AddItemToLocation(itemLabel, locationItems, player);
     }
 }
Ejemplo n.º 2
0
        private CommandResponse TakeItem(string itemLabel, Inventory locationItems, Player player)
        {
            if (itemLabel!="gold" && locationItems.ItemList.ContainsKey(itemLabel)==false)
                return new CommandResponse("There is no such item");

            if (player.Inventory.GetWeightLimit() - player.Inventory.GetWeight() < GetItemWeight(itemLabel, player))
                return new CommandResponse("The item's too heavy");
            else
            {
                return AddItemToInventory(itemLabel, locationItems, player);
            }
        }
Ejemplo n.º 3
0
 private CommandResponse SellItem(string itemLabel, Inventory locationItems, Player player)
 {
     if (!(player.Inventory.ItemList.ContainsKey(itemLabel)))
         return new CommandResponse("There is no such item");
         else
         {
             Item item = player.Inventory.GetItem(itemLabel);
             player.Inventory.RemoveItem(item);
             locationItems.AddItem(item);
             player.Inventory.GetGold().Total += item.Value;
             return new CommandResponse("You've sold the item: " + itemLabel);
         }
 }
Ejemplo n.º 4
0
 private CommandResponse AddItemToLocation(String itemLabel, Inventory locationItems, Player player)
 {
     if (itemLabel == "gold")
     {
         int amount = player.Inventory.GetGold().Total;
         player.CurrentLocation.Items.AddMoney(amount);
         player.Inventory.RemoveMoney(amount);
         return new CommandResponse("You dropped " + amount + " gold");
     }
     Item item = locationItems.GetItem(itemLabel);
     player.Inventory.AddItem(item);
     locationItems.RemoveItem(item);
     return new CommandResponse("You dropped the item: " + itemLabel);
 }
Ejemplo n.º 5
0
 private CommandResponse BuyItem(string itemLabel, Inventory locationItems, Player player)
 {
     if (! (locationItems.ItemList.ContainsKey(itemLabel)))
         return new CommandResponse("There is no such item");
     else
         if (player.Inventory.GetWeightLimit() - player.Inventory.GetWeight() < locationItems.GetItem(itemLabel).Weight)
             return new CommandResponse("The item's too heavy");
         else if (player.Inventory.GetGold().Total < locationItems.GetItem(itemLabel).Value)
             return new CommandResponse("You have no enough gold");
         else
         {
             Item item = locationItems.GetItem(itemLabel);
             player.Inventory.AddItem(item);
             locationItems.RemoveItem(item);
             player.Inventory.GetGold().Total -= item.Value;
             return new CommandResponse("You've bought the item: " + itemLabel);
         }
 }
Ejemplo n.º 6
0
 public Location()
 {
     this.exitCollection = new ExitCollection();
     this.items = new Inventory();
     this.characterList = new NonPlayerCharacterCollection();
 }