/// <summary> /// Apply Item to Hero /// </summary> /// <param name="newItem">Item to Apply to Hero</param> /// <returns>Item that hero needs to discard.</returns> public Item Apply(Item newItem) { Item retItem = null; if (newItem.GetType() == typeof(Potion)) { this.HealMe(newItem.AffectValue); } else if (newItem.GetType() == typeof(Weapon)) { retItem = _EquippedWeapon; _EquippedWeapon = (Weapon)newItem; } else if (newItem.GetType() == typeof(DoorKey)) { retItem = _Key; _Key = (DoorKey)newItem; } else { retItem = newItem; } return(retItem); }
/// <summary> /// Check if a given key matches this door /// </summary> /// <param name="key">key to check against this door</param> /// <returns>true if the key code matches the door code. False otherwise.</returns> public bool isMatch(DoorKey key) { return(key.Code == _Code); }