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); }
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)); }
public int CalculeScore(string bowls) { foreach (var roll in bowls) { Throw aThow = CreateThrow(roll); throws.Add(aThow); } return(throws.CalculeScore()); }
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); }
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))); }
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]); }
/// <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); }
/// <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); }
public Strike(IList <Throw> throws) : base(throws) { Throws.Add(new Throw(10)); }
public Spare(IList <Throw> throws, int firstThrowFalledPins, int secondThrowFalledPins) : base(throws) { Throws.Add(new Throw(firstThrowFalledPins)); Throws.Add(new Throw(secondThrowFalledPins)); }