protected new void AddItem(string[] inputParams)
 {
     Character characterToAcceptIitem = GetCharacterById(inputParams[1]);
     Item itemToAdd;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             itemToAdd = new Axe(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "shield":
             itemToAdd = new Shield(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "pill":
             itemToAdd = new Pill(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         case "injection":
             itemToAdd = new Injection(inputParams[3]);
             characterToAcceptIitem.AddToInventory(itemToAdd);
             break;
         default:
             break;
     }
 }
        protected new void AddItem(string[] inputParams)
        {
            var characterId = inputParams[1];
            var character = this.characterList.Find(x => x.Id == characterId);

            var itemClass = inputParams[2];
            var itemId = inputParams[3];

            Item item;
            switch (itemClass)
            {
                case "axe":
                    item = new Axe(itemId);
                    break;
                case "shield":
                    item = new Shield(itemId);
                    break;
                case "pill":
                    item = new Pill(itemId);
                    break;
                case "injection":
                default:
                    item = new Injection(itemId);
                    break;
            }

            character.AddToInventory(item);
        }
Beispiel #3
0
        protected void AddItem(string[] inputParams)
        {
            string nameOfCharacter = inputParams[1];
            string typeOfItem = inputParams[2];
            string nameOfItem = inputParams[3];

            switch (typeOfItem)
            {
                case "axe":
                    Item axe = new Axe(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(axe);
                    break;
                case "injection":
                    Bonus injection = new Injection(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(injection);
                    break;
                case "pill":
                    Bonus pill = new Pill(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(pill);
                    break;
                case "shield":
                    Item shield = new Shield(nameOfItem);
                    characterList.Find(character => character.Id == nameOfCharacter).AddToInventory(shield);
                    break;
                default:
                    throw new GameException("No such item exists");
            }
        }
Beispiel #4
0
        private void AddItem(string[] inputParams)
        {
            Item item = null;
            switch (inputParams[2])
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "pill":
                    item = new Pill(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
            }

            var target = base.GetCharacterById(inputParams[1]);

            target.AddToInventory(item);
        }
Beispiel #5
0
 protected new void AddItem(string[] inputParams)
 {
     Character targetCharacter = GetCharacterById(inputParams[1]);
     Item item;
     switch (inputParams[2].ToLower())
     {
         case "axe":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "shield":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "pill":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
         case "injection":
             item = new Axe(inputParams[3]);
             targetCharacter.AddToInventory(item);
             break;
     }
 }
Beispiel #6
0
        private new void AddItem(string[] inputParams)
        {
            Item item;
            switch (inputParams[2].ToLower())
            {
                case "axe":
                    item = new Axe(inputParams[3]);
                    break;
                case "shield":
                    item = new Shield(inputParams[3]);
                    break;
                case "injection":
                    item = new Injection(inputParams[3]);
                    break;
                case "pill":
                    item  =new Pill(inputParams[3]);
                    break;
                default:
                    throw new ApplicationException("No such kind of item.");
            }

            var character = this.characterList.First(c => c.Id == inputParams[1]);
            character.AddToInventory(item);
        }