コード例 #1
0
ファイル: SellCommand.cs プロジェクト: Kais120/7201a2
 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);
         }
 }
コード例 #2
0
ファイル: DropCommand.cs プロジェクト: Kais120/7201a2
 private CommandResponse DropItemToLocation(String itemLabel, Inventory locationItems, Player player)
 {
     if (itemLabel == "gold")
     {
         int amount = player.Inventory.GetGold().Total;
         player.Inventory.RemoveMoney(amount);
         player.CurrentLocation.Items.AddMoney(amount);
         return new CommandResponse("You dropped " + amount + " gold");
     }
     Item item = player.Inventory.GetItem(itemLabel);
     player.Inventory.RemoveItem(item);
     locationItems.AddItem(item);
     return new CommandResponse("You dropped the item: " + itemLabel);
 }