static void Main(string[] args) { DiceRoller dh = new DiceRoller(); //List<RollParameter> rollParams = new List<RollParameter>() { new RollParameter(3, 6, ModifierType.Explode, new ExplodeModifier(6, 6)), new RollParameter(4, 8) }; DicePool rollParam = new DicePool(6, 6, ModifierType.Explode, new ExplodeModifier(6, 6, 2)); List <RollResult> rolls = dh.Roll(rollParam); rolls.AddRange(dh.Explode(rolls, rollParam.RollModifiers[0] as ExplodeModifier)); foreach (RollResult roll in rolls) { if (roll.Exploded) { Console.ForegroundColor = ConsoleColor.Red; } else if (roll.FromExplode) { Console.ForegroundColor = ConsoleColor.Yellow; } Console.Write(roll.ToString() + ", "); Console.ResetColor(); } }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="objCulture">Culture in which to print numbers.</param> /// <param name="strLanguageToPrint">Language in which to print.</param> public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint) { objWriter.WriteStartElement("spell"); if (Limited) { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint) + LanguageManager.GetString("String_Space", strLanguageToPrint) + '(' + LanguageManager.GetString("String_SpellLimited", strLanguageToPrint) + ')'); } else if (Alchemical) { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint) + LanguageManager.GetString("String_Space", strLanguageToPrint) + '(' + LanguageManager.GetString("String_SpellAlchemical", strLanguageToPrint) + ')'); } else { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); } objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("descriptors", DisplayDescriptors(strLanguageToPrint)); objWriter.WriteElementString("category", DisplayCategory(strLanguageToPrint)); objWriter.WriteElementString("category_english", Category); objWriter.WriteElementString("type", DisplayType(strLanguageToPrint)); objWriter.WriteElementString("range", DisplayRange(strLanguageToPrint)); objWriter.WriteElementString("damage", DisplayDamage(strLanguageToPrint)); objWriter.WriteElementString("duration", DisplayDuration(strLanguageToPrint)); objWriter.WriteElementString("dv", DisplayDV(strLanguageToPrint)); objWriter.WriteElementString("alchemy", Alchemical.ToString()); objWriter.WriteElementString("dicepool", DicePool.ToString(objCulture)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
public void DiceRollTest() { // Declare var pool = new DicePool(); pool.AddDie(DiceType.Ability); pool.AddDie(DiceType.Boost); pool.AddDie(DiceType.Challenge); pool.AddDie(DiceType.Difficulty); pool.AddDie(DiceType.Force); pool.AddDie(DiceType.Proficiency); pool.AddDie(DiceType.Setback); // Setup var result = pool.Roll(); foreach (var res in result.Keys) { Console.WriteLine($"{res} : {result[res]}"); } // Assert Assert.AreEqual(8, result.Count); Assert.AreEqual(7, pool.Pool.Count); }
public void TestMethod1() { var testPool = new DicePool(); testPool.AddDie(new SuccessTestDie()); var result = testPool.Roll(); Assert.AreEqual("1 success ", result); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
public bool mnChallenge(DicePool dicepool) //makano & narssis { for (int i = 0; i < makanoList.Count; ++i) { if (makanoList[i] != dicepool[i].value) { return(false); } } return(true); }
public override bool skillChallenge(DicePool dicepool) { int val = dicepool[0].value; foreach (Dice d in dicepool) { if (d.value != val) { return(false); } } return(true); }
public override bool skillChallenge(DicePool dicepool) { int sum = dicepool.count(); if (sum >= value) { return(true); } else { return(false); } }
public virtual bool Roll(int modifier = 0) { DicePool rollDicePool = new DicePool(3); int roll = rollDicePool.Roll(); var required = RollRequired(modifier); if (roll <= required) { return(true); } else { return(false); } }
public bool serrinChallenge(DicePool dicepool) { int val = serrinList[0]; foreach (Dice d in dicepool) { if (d.value != val) { return(false); } } for (int i = 0; i < serrinList.Count; ++i) { serrinList[i] = 1; } return(true); }
public virtual bool RollAgainst(int number1, int number2) { int success = 11 + number1 - (number2); DicePool rollDicePool = new DicePool(3); int roll = rollDicePool.Roll(); if (roll <= success) { return(true); } else { return(false); } }
public override void performDefensiveManuever() { int roll = new DicePool(3).Roll(); int required = Character.OCV.CurrentValue - AttackDefendingAgainst.Attacker.OCV.CurrentValue + 11; if (roll <= required) { RollStatus = RollStatus.RollSuccessful; AttackDefendingAgainst.Result.HitResult = HitResult.RolledWithThePunch; AttackDefendingAgainst.HitStatus = HitStatus.RolledWithThePunch; } else { RollStatus = RollStatus.RollFailed; Character.ActiveManuever = null; } }
public override void performDefensiveManuever() { int roll = new DicePool(3).Roll(); int required = Blocker.OCV.CurrentValue - AttackDefendingAgainst.Attacker.OCV.CurrentValue + 11; if (roll <= required) { BlockStatus = BlockStatus.BlockSuccessful; AttackDefendingAgainst.Result.HitResult = HitResult.Blocked; AttackDefendingAgainst.HitStatus = HitStatus.Blocked; } else { BlockStatus = BlockStatus.BlockFailed; Blocker.ActiveManuever = null; Modifier.OCV.ModiferAmount = 0; } }
/// <summary> /// Print the object's XML to the XmlWriter. /// </summary> /// <param name="objWriter">XmlTextWriter to write with.</param> /// <param name="objCulture">Culture in which to print numbers.</param> /// <param name="strLanguageToPrint">Language in which to print.</param> public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint) { if (objWriter == null) { return; } objWriter.WriteStartElement("spell"); objWriter.WriteElementString("guid", InternalId); objWriter.WriteElementString("sourceid", SourceIDString); if (Limited) { objWriter.WriteElementString("name", string.Format(objCulture, "{0}{1}({2})", DisplayNameShort(strLanguageToPrint), LanguageManager.GetString("String_Space", strLanguageToPrint), LanguageManager.GetString("String_SpellLimited", strLanguageToPrint))); } else if (Alchemical) { objWriter.WriteElementString("name", string.Format(objCulture, "{0}{1}({2})", DisplayNameShort(strLanguageToPrint), LanguageManager.GetString("String_Space", strLanguageToPrint), LanguageManager.GetString("String_SpellAlchemical", strLanguageToPrint))); } else { objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint)); } objWriter.WriteElementString("name_english", Name); objWriter.WriteElementString("descriptors", DisplayDescriptors(strLanguageToPrint)); objWriter.WriteElementString("category", DisplayCategory(strLanguageToPrint)); objWriter.WriteElementString("category_english", Category); objWriter.WriteElementString("type", DisplayType(strLanguageToPrint)); objWriter.WriteElementString("range", DisplayRange(strLanguageToPrint)); objWriter.WriteElementString("damage", DisplayDamage(strLanguageToPrint)); objWriter.WriteElementString("duration", DisplayDuration(strLanguageToPrint)); objWriter.WriteElementString("dv", DisplayDV(strLanguageToPrint)); objWriter.WriteElementString("alchemy", Alchemical.ToString(GlobalOptions.InvariantCultureInfo)); objWriter.WriteElementString("dicepool", DicePool.ToString(objCulture)); objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint)); objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint)); objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint)); if (_objCharacter.Options.PrintNotes) { objWriter.WriteElementString("notes", Notes); } objWriter.WriteEndElement(); }
void Awake() { _dice = new Dictionary <string, Die>(); if (_instance != null) { Debug.LogError("Multiple Dice Pools in scene"); } else { _instance = this; } Central.Instance.onBluetoothError += OnBluetoothError; Central.Instance.onDieDiscovered += OnDieDiscovered; Central.Instance.onDieConnected += OnDieReady; Central.Instance.onDieDisconnected += OnDieDisconnected; Central.Instance.RegisterFactory(CreateDie); }
internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild) { EmbedBuilder embedBuilder = new EmbedBuilder(); Match m = Regex.Match(message.Content, "(\\d+) (\\d+) (\\d+) (\\d+)"); if (m.Success) { List <DicePool> pools = new List <DicePool>(); pools.Add(new DicePool($"{m.Groups[1].ToString()}d6", "Discipline")); pools.Add(new DicePool($"{m.Groups[2].ToString()}d6", "Exhaustion")); pools.Add(new DicePool($"{m.Groups[3].ToString()}d6", "Madness")); DicePool painPool = new DicePool($"{m.Groups[4].ToString()}d6", "Pain"); int playerSuccess = 0; DicePool dominantPool = pools[0]; foreach (DicePool entry in pools) { int success = entry.CountAtOrBelow(3); playerSuccess += success; if (dominantPool.HighestValue() < entry.HighestValue()) { dominantPool = entry; } embedBuilder.AddField($"{entry.Label}", $"{entry.SummarizePoolRoll(0)} = {success}"); } embedBuilder.AddField($"{painPool.Label}", $"{painPool.SummarizePoolRoll(0)} = {painPool.CountAtOrBelow(3)}"); if (painPool.HighestValue() > dominantPool.HighestValue()) { dominantPool = painPool; } string winString = (playerSuccess >= painPool.CountAtOrBelow(3)) ? "wins" : "loses"; string successNoun = (playerSuccess == 1) ? "success" : "successes"; embedBuilder.Description = $"**The player {winString}** the conflict with {playerSuccess} {successNoun} versus {painPool.CountAtOrBelow(3)}. **{dominantPool.Label} dominates** with a {dominantPool.HighestValue()}."; await message.Channel.SendMessageAsync($"{message.Author.Mention}:", false, embedBuilder); } else { await message.Channel.SendMessageAsync($"{message.Author.Mention}: Dice syntax is `{guild.commandPrefix}dryh [Discipline] [Exhaustion] [Madness] [Pain]`."); } }
internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild) { EmbedBuilder embedBuilder = new EmbedBuilder(); bool foundDice = false; foreach (Match m in Regex.Matches(message.Content.Substring(6), "(\\d*)(#*)d(\\d+)([+-]\\d+)*")) { DicePool dice = new DicePool(m); embedBuilder.AddField(dice.Label, dice.SummarizeStandardRoll()); foundDice = true; } if (!foundDice) { await message.Channel.SendMessageAsync($"{message.Author.Mention}: Dice syntax is `{guild.commandPrefix}roll [1-100]d[1-100]<+/-[modifier]>` separated by spaces or commas. Separate dice count from number of sides with `#` for individual rolls."); } else { await message.Channel.SendMessageAsync($"{message.Author.Mention}:", false, embedBuilder); } }
public void Valid() { // arrange const int seed = 1234; const int _numberOfDice = 3; var bag = new DiceBag(seed); var actual = new DicePool(bag, _numberOfDice); var expected = new DicePoolResults(new List <int> { 2, 5, 2 }); // act var results = actual.Roll(); // assert Assert.AreEqual(expected.RollResults.Count, results.RollResults.Count); for (int i = 0; i < results.RollResults.Count; i++) { Assert.AreEqual(expected.RollResults[i], results.RollResults[i]); } }
internal override async Task ExecuteCommand(SocketMessage message, GuildConfig guild) { EmbedBuilder embedBuilder = new EmbedBuilder(); int mod = 0; Match m = Regex.Match(message.Content, "([-+])(\\d+)"); if (m.Success) { mod = Convert.ToInt32(m.Groups[2].ToString()); if (m.Groups[1].ToString().Equals("-")) { mod = -(mod); } } DicePool dice = new DicePool($"4d3", "FATE"); int resultValue = (dice.CountAtOrAbove(3) - dice.CountAtOrBelow(1)) + mod; string modString = (resultValue >= 0) ? $"+{mod}" : $"{mod}"; string descriptiveResult; if (resultValue > 7) { descriptiveResult = $"+{resultValue}, Legendary!"; } else if (resultValue < -2) { descriptiveResult = $"{resultValue}, Abysmal..."; } else { string resultKey = (resultValue < 0) ? $"{resultValue}" : $"+{resultValue}"; descriptiveResult = $"{resultKey}, {fateTiers[resultKey]}"; } embedBuilder.Description = descriptiveResult; embedBuilder.AddField("Rolled", $"{dice.SummarizePoolRoll(-2)} ({modString})"); await Program.SendReply(message, embedBuilder); }
public void BoostDieTest() { // Declare var pool = new DicePool(); pool.AddDie(DiceType.Boost); // Setup var results = pool.Roll(); foreach (var res in results.Keys) { Console.WriteLine($"{res} : {results[res]}"); } // Assert Assert.IsTrue(results[ResultTypes.DarkPoint] == 0); Assert.IsTrue(results[ResultTypes.Dispair] == 0); Assert.IsTrue(results[ResultTypes.Failure] == 0); Assert.IsTrue(results[ResultTypes.LightPoint] == 0); Assert.IsTrue(results[ResultTypes.Threat] == 0); Assert.IsTrue(results[ResultTypes.Triumph] == 0); }
public ActionResult Do(IDiceBag bag, ICharacter source) { if (bag == null) { throw new ArgumentNullException("bag"); } if (source == null) { throw new ArgumentNullException("source"); } var times = 0; AttributesUsed.ForEach(x => times += source.Attributes[x]); SkillsUsed.ForEach(x => times += source.Skills[x]); var pool = new DicePool(bag, times); var results = (Limit == LimitType.None) ? pool.Roll() : pool.Roll(source.Attributes.LimitValue(Limit)); var rollNotation = buildNotation(source); return(new ActionResult(rollNotation, results)); }
public void Setup() { sixDice = 6; sixDicePool = new DicePool(sixDice); }
public override bool skillChallenge(DicePool dicepool) { throw new NotImplementedException(); }
public void GivenNullDiceBag_ThrowArgumentNullException() { // arrange, act & assert var results = new DicePool(null, 1); }
public void GivenZeroNumberOfDice_ThrowArgumentOutOfRangeException() { // arrange, act & assert var results = new DicePool(new DiceBag(), 0); }
public abstract bool skillChallenge(DicePool dicepool);
public Player(PlayerLoginData playerLoginData) { playerData = playerLoginData; dicePool = new DicePool(); crestPool = new CrestPool(); }
private int Calculate(FightingUnit unitFrom, FightingUnit unitTo) { var battleDice = unitFrom.Attacking ? unitFrom.OffensiveDie : unitFrom.DefensiveDie; var AC = unitTo.ArmorClass; if (!unitTo.Attacking && unitTo.Action == Actions.shieldFormation && unitFrom.Unit.type == UnitTypes.ranged) { AC += 2; } else if (!unitTo.Attacking && unitTo.Action == Actions.defensiveStance) { AC += (unitTo.LeadershipBonus - 6) / 4; } else if (unitTo.Action == Actions.charge && unitTo.Attacking && unitTo.Unit.type == UnitTypes.infantry) { AC -= 3; } var toHit = unitFrom.ToHit; if (!unitFrom.Attacking && unitFrom.Action == Actions.offensiveStance) { toHit++; } var damageMod = (unitFrom.Attacking && unitFrom.Action == Actions.charge && unitFrom.Unit.name != "Polearms") ? 1.5f : 1.0f; if (unitFrom.Unit.name == "Polearms" && unitTo.Unit.type == UnitTypes.cavalry) { damageMod *= 2; if (unitTo.Action == Actions.charge && unitTo.Attacking) { damageMod *= 2; } } unitFrom.AttackRoll = unitFrom.AdvantageType switch { AdvantageType.Advantage => Math.Max(rand.Next(1, 21), rand.Next(1, 21)), AdvantageType.Disadvantage => Math.Min(rand.Next(1, 21), rand.Next(1, 21)), _ => rand.Next(1, 21) }; var attackHit = unitFrom.AttackRoll + toHit; var nat20 = unitFrom.AttackRoll == 20; var ACdifferential = attackHit - AC; if (ACdifferential <= -6 && !(unitFrom.Attacking && unitFrom.Unit.type == UnitTypes.cavalry && unitFrom.Action == Actions.charge)) { battleDice.dieCount = 0; } else { battleDice.dieCount += (ACdifferential / 2); } var pool = DicePool.FromDice(battleDice); if (nat20) { pool.flatBonus = battleDice.dieSides; } if (!unitFrom.Attacking && unitFrom.Unit.type == UnitTypes.artillery) { pool = new DicePool(); battleDice.dieCount = 0; } int totalDamage = 0; for (int i = 0; i < unitFrom.UnitStrength; i++) { totalDamage += pool.CalculateDamage(rand); } if (unitFrom.Attacking) { unitFrom.OffensiveDie = battleDice; } else { unitFrom.DefensiveDie = battleDice; } unitTo.ArmorClass = AC; unitFrom.ToHit = toHit; unitFrom.DamageModifier = damageMod; return((int)(totalDamage * damageMod)); } }