/// <summary> /// Apply Item to Hero /// </summary> /// <param name="i">Item to Apply to Hero</param> /// <returns>Item that hero needs to discard. Returns weapon if hero replaces weapon.</returns> public Item Apply(Item i) { Item retItem = null; if (i.GetType() == typeof(Potion)) { healMe(i.AffectValue); } else if (i.GetType() == typeof(Weapon)) { retItem = _Weapon; _Weapon = (Weapon)i; } else if (i.GetType() == typeof(DoorKey)) { // checking wether hero has a key or not and to pick up the key to open the door. if (_DoorKey != null) { retItem = _DoorKey; _DoorKey = (DoorKey)i; } else { _DoorKey = (DoorKey)i; return(null); } } else { retItem = i; } return(retItem); }
public bool isMatch(DoorKey key) { return(key.Code == _Code); }