예제 #1
0
        private static bool CanPlayerEnterRoom(Character.Models.Character player, Models.Room foundRoom, ItemRequirement itemReq = null, AttributeRequirement attrReq = null)
        {
            if (itemReq != null)
            {
                foreach (var item in player.CarriedItems)
                {
                    if (item.ItemName == itemReq.RelevantItem.ItemName)
                    {
                        return(true);
                    }
                }

                Console.WriteLine($"You need: <{itemReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod);
            }

            if (attrReq != null)
            {
                if (PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, attrReq))
                {
                    return(true);
                }
                Console.WriteLine($"You need: <{attrReq.RequirementName}> to enter {foundRoom.RoomName}. \n", Color.DarkGoldenrod);
            }

            return(false);
        }
예제 #2
0
        public static bool PlayerMeetsRequirementForItem(Character.Models.Character player, bool takeItem = true, InventoryItem inventoryItem = null, WeaponItem weaponItem = null)
        {
            if (inventoryItem != null)
            {
                if (takeItem)
                {
                    return(PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, inventoryItem.AttributeRequirementToTake));
                }

                return(PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, inventoryItem.AttributeRequirementToSee));
            }

            if (weaponItem != null)
            {
                if (takeItem)
                {
                    return(PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, weaponItem.AttributeRequirementToTake));
                }

                return(PlayerAttributeComparer.ComparePlayerTraitsToAttributeRequirement(player, weaponItem.AttributeRequirementToSee));
            }

            return(false);
        }