public void ModifierTests(DiceResolver.DiceOperation?operation, int modifier) { var resolver = new DiceResolver { Count = 4, Sides = 6, Operation = operation, Modifier = modifier }; resolver.Roll(); var sum = resolver.LastRolls.Sum(); if (operation == DiceResolver.DiceOperation.Add) { sum += modifier; } if (operation == DiceResolver.DiceOperation.Subtract) { sum -= modifier; } Assert.AreEqual(sum, resolver.LastSum); Console.WriteLine(resolver.LastResult); }
public void BasicRoll() { var resolver = new DiceResolver { Count = 4, Sides = 6 }; resolver.Roll(); Assert.IsTrue(resolver.LastRolls.Count == 4); Assert.IsTrue(resolver.LastRolls.All(x => x >= 1 && x <= 6)); Console.WriteLine(resolver.LastResult); }
public async Task RollDice(string diceNotation) { var resolver = DiceResolver.FromDiceNotation(diceNotation); if (resolver == null) { await ReplyAsync("Invalid dice notation"); return; } resolver.Roll(); await ReplyAsync(resolver.LastResult); }
public void DiceNotationTests(string diceNotation, int count, int sides, DiceResolver.DiceOperation?operation, int modifier, bool?removeLowest) { var resolver = DiceResolver.FromDiceNotation(diceNotation); Assert.IsNotNull(resolver); Assert.AreEqual(resolver.Count, count); Assert.AreEqual(resolver.Sides, sides); Assert.AreEqual(resolver.Operation, operation); Assert.AreEqual(resolver.Modifier, modifier); Assert.AreEqual(resolver.RemoveLowest, removeLowest); resolver.Roll(); Console.WriteLine(resolver.LastResult); }