Пример #1
0
        public void TestReset()
        {
            Throws t = new Throws();

            t.Add(1);
            t.Add(6);
            var h = t.Histogram;

            Assert.AreEqual(7, h.Length);
            t.Add(12);
            h = t.Histogram;
            Assert.AreEqual(13, h.Length);
        }
Пример #2
0
 public BasicFrame(IList <Throw> throws, int firstThrowFalledPins, int secondThrowFalledPins) : base(throws)
 {
     _firstThrowFalledPins  = firstThrowFalledPins;
     _secondThrowFalledPins = secondThrowFalledPins;
     Throws.Add(new Throw(firstThrowFalledPins));
     Throws.Add(new Throw(secondThrowFalledPins));
 }
Пример #3
0
        public int CalculeScore(string bowls)
        {
            foreach (var roll in bowls)
            {
                Throw aThow = CreateThrow(roll);
                throws.Add(aThow);
            }

            return(throws.CalculeScore());
        }
Пример #4
0
    void QueueDieThrow(string diceType, int quantity, string description)
    {
        Debug.Log(string.Format("Queueing a dice throw"));
        Throw newThrow = new Throw();

        newThrow.description = description;
        for (int i = 0; i < quantity; i++)
        {
            newThrow.Add(diceType);
        }
        throws.Add(newThrow);
    }
Пример #5
0
 public Turn WithAdditionalThrow(ThrowResult throwResult)
 {
     if (throwResult == null)
     {
         throw new ArgumentNullException("throwResult");
     }
     if (Finished)
     {
         throw new InvalidOperationException("Turn is over already.");
     }
     return(new Turn(ScoreBefore, Throws.Add(throwResult)));
 }
Пример #6
0
        public void TestTwoThrows()
        {
            Throws t1 = new Throws();

            t1.Add(1);
            t1.Add(6);
            var h1a = t1.Histogram;

            Assert.AreEqual(1, h1a[1]);
            Assert.AreEqual(0, h1a[2]);
            Assert.AreEqual(0, h1a[3]);
            Assert.AreEqual(0, h1a[4]);
            Assert.AreEqual(0, h1a[5]);
            Assert.AreEqual(1, h1a[6]);

            Throws t2 = new Throws();

            t2.Add(2);
            t2.Add(4);
            t2.Add(2);
            var h2b = t2.Histogram;

            Assert.AreEqual(5, h2b.Length);
            Assert.AreEqual(0, h2b[1]);
            Assert.AreEqual(2, h2b[2]);
            Assert.AreEqual(0, h2b[3]);
            Assert.AreEqual(1, h2b[4]);

            var h1b = t1.Histogram;

            Assert.AreEqual(1, h1b[1]);
            Assert.AreEqual(0, h1b[2]);
            Assert.AreEqual(0, h1b[3]);
            Assert.AreEqual(0, h1b[4]);
            Assert.AreEqual(0, h1b[5]);
            Assert.AreEqual(1, h1b[6]);
        }
Пример #7
0
        /// <summary>
        /// Pops a value off the stack and throws it as an exception.
        ///
        /// Throw expects the value to be or extend from a System.Exception.
        /// </summary>
        public Emit <DelegateType> Throw()
        {
            UpdateState(OpCodes.Throw, Wrap(StackTransition.Pop <Exception>(), "Throw"));
            UpdateState(Wrap(new[] { new StackTransition(new[] { typeof(PopAllType) }, TypeHelpers.EmptyTypes) }, "Throw"));

            Throws.Add(IL.Index);

            MustMark = true;

            var verify = CurrentVerifiers.Throw();

            if (!verify.Success)
            {
                throw new SigilVerificationException("Throw", verify, IL.Instructions(AllLocals));
            }

            return(this);
        }
Пример #8
0
        /// <summary>
        /// From within a catch block, rethrows the exception that caused the catch block to be entered.
        /// </summary>
        public Emit <DelegateType> ReThrow()
        {
            if (!CatchBlocks.Any(c => c.Value.Item2 == -1))
            {
                throw new InvalidOperationException("ReThrow is only legal in a catch block");
            }

            UpdateState(OpCodes.Rethrow, Wrap(StackTransition.None(), "ReThrow"));
            UpdateState(Wrap(new[] { new StackTransition(new[] { typeof(PopAllType) }, Type.EmptyTypes) }, "ReThrow"));

            Throws.Add(IL.Index);

            MustMark = true;

            var verify = CurrentVerifiers.ReThrow();

            if (!verify.Success)
            {
                throw new SigilVerificationException("ReThrow", verify, IL.Instructions(AllLocals));
            }

            return(this);
        }
Пример #9
0
 public Strike(IList <Throw> throws) : base(throws)
 {
     Throws.Add(new Throw(10));
 }
Пример #10
0
 public Spare(IList <Throw> throws, int firstThrowFalledPins, int secondThrowFalledPins) : base(throws)
 {
     Throws.Add(new Throw(firstThrowFalledPins));
     Throws.Add(new Throw(secondThrowFalledPins));
 }