Beispiel #1
0
        public bool RequirementsMet(IActor forActor)
        {
            //if it requires equipping
            if (Slot != null && !IsEquipped)
            {
                return(false);
            }

            //it has unique conditions that are not met yet
            return(Require.All(r => r.IsMet(forActor.CurrentLocation.World, GetSystemArgs(forActor))));
        }
Beispiel #2
0
        public bool CanUse(IActor actor, out string reason)
        {
            if (IsErased)
            {
                reason = "Item no longer exists";
                return(false);
            }

            if (!Require.All(c => c.IsMet(actor.CurrentLocation.World, GetSystemArgs(actor))))
            {
                reason = "Item requirements not met:" + string.Join(Environment.NewLine, Require.Select(r => r.ToString()));
                return(false);
            }

            reason = null;
            return(true);
        }
Beispiel #3
0
 public void All_WhenEmpty_DoesNotThrow()
 {
     Require.All(Enumerable.Empty <int>(), v => v > 1, "message", "name");
 }
Beispiel #4
0
 public void All_WhenContainsElementThatDoesNotMatchPredicate_ThrowsArgumentException()
 {
     Assert.Throws <ArgumentException>(() => Require.All(new[] { 1, 5 }, v => v > 1, "message", "name"));
 }
Beispiel #5
0
 public void All_WhenNull_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => Require.All((int[])null, v => v > 1, "message", "name"));
 }
Beispiel #6
0
 public void All_WhenAllElementsMatchesPredicate_DoesNotThrow()
 {
     Require.All(new[] { 2, 3 }, v => v > 1, "message", "name");
 }