public void Roll() { IsRolling = true; ResetResultsText(); _lastRollResult = Roller.CombatRoll(_attacker, _defender, out _rolledFaceIndexAttack, out _rolledFaceIndexDefense); var attackDice = _attacker != null ? _attacker.AttackDice : new List <AttackDieDef>(); var defenseDice = _defender != null ? _defender.DefenseDice : new List <DefenseDieDef>(); ShowCombatRoll(attackDice, defenseDice, _rolledFaceIndexAttack, _rolledFaceIndexDefense); UpdatePierce(_attacker); UpdateRangeModifier(_attacker); if (_coroutine != null) { StopCoroutine(_coroutine); } var listDice = new List <DieAnimator>(_attackDiceAnimator); listDice.AddRange(_defenseDiceAnimator); // add all die animators _coroutine = StartCoroutine(WaitAndUpdateResult(_lastRollResult, listDice)); }
protected static void EvaluateRoll(string diceExpr, RollerConfig conf, RollData data, int expectedRolls, string expectedResult) { var result = Roller.Roll(diceExpr, conf, data); Assert.AreEqual(expectedRolls, result.NumRolls); Assert.AreEqual(expectedResult, result.ToString()); }
public Roller GetRolByID(int RolID) { cmd = new SqlCommand("select * from roller where RolID=@RolID", cnn); cmd.Parameters.AddWithValue("@RolID", RolID); Roller rol = null; try { cnn.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); rol = new Roller() { RolID = Convert.ToInt32(reader["RolID"]), RolAdi = reader["RolAdi"].ToString() }; return(rol); } catch (Exception) { return(rol); } finally { cnn.Close(); } }
public void InsertRollerAt(int atIndex, int _rollerColorID, Vector3 hitPoint) { float targetPosition; if (atIndex == 0) { targetPosition = gm.BallDiameter + Rollers[atIndex].GetCurrentPosition; } else { targetPosition = Rollers[atIndex - 1].GetCurrentPosition; ChainMoveRollersByDelta(atIndex - 1, gm.BallDiameter); } Roller newRoller = GenerateRoller(_rollerColorID, targetPosition); if (atIndex == Rollers.Count) { Rollers.Add(newRoller); } else if (atIndex > Rollers.Count) { Debug.LogError("Inserting at improper location"); } else { Rollers.Insert(atIndex, newRoller); } newRoller.Tran.position = Curve.path.GetPointAtDistance(targetPosition); newRoller.PlayInsertAnimation(hitPoint); }
public void Successfully_CompareTwoRolls_HashCodes() { var res1 = Roller.Roll("3d20", Roll9Conf); var res2 = Roller.Roll("3d20", Roll9Conf); Assert.AreEqual(res1.GetHashCode(), res2.GetHashCode()); }
public void Successfully_CompareTwoRolls_NotEqual() { var res1 = Roller.Roll("3d20", Roll9Conf); var res2 = Roller.Roll("4d20", Roll9Conf); Assert.IsTrue(res1 != res2); }
public void Successfully_CompareTwoDice_Equals() { var res = Roller.Roll("2d20", Roll9Conf); Assert.AreEqual(res.Values[0], res.Values[2]); Assert.AreNotSame(res.Values[0], res.Values[2]); }
/// <summary> /// Evaluates the node and asserts that the number of rolls and result match what is expected. /// </summary> /// <param name="node"></param> /// <param name="conf"></param> /// <param name="expectedRolls"></param> /// <param name="expectedResult"></param> protected static void EvaluateNode(DiceAST node, RollData data, int expectedRolls, string expectedResult) { var result = Roller.Roll(node, data); Assert.AreEqual(expectedRolls, result.NumRolls); Assert.AreEqual(expectedResult, result.ToString()); }
public string RollDice(string parm, int diceAmount) { RollResult rollResult; string[] bedeutungen = new string[13]; string result = string.Empty; string rollValueString = string.Empty; switch (parm) { case "d20": case "d12": case "d6": case "d3": rollResult = Roller.Roll($"{diceAmount}{parm}"); result += $"{diceAmount}{parm}:"; foreach (DieResult singleRoll in rollResult.Values) { if (singleRoll.Value != 0) { result += $" {singleRoll.Value} +"; } } result = result[0..^ 2];
public ActionResult Delete(Roller roller) { var droller = db.Roller.FirstOrDefault(c => c.ID == roller.ID); db.Roller.Remove(droller); db.SaveChanges(); return(RedirectToAction("Index", "Roller")); }
public void Successfully_CompareTwoRolls_Equals() { var res1 = Roller.Roll("3d20", Roll9Conf); var res2 = Roller.Roll("3d20", Roll9Conf); Assert.AreEqual(res1, res2); Assert.AreNotSame(res1, res2); }
public void RemoveRollerOnDestroy(Roller rollerToRemove) { try { RemoveRoller(rollerToRemove); } catch { Debug.Log("Roller does not exist in the list"); } }
private void RollBtn_Click(object sender, EventArgs e) { DisplayText = false; Roller.Roll(scene); Drawables = scene.Dices.Values.SelectMany(d => d).ToList(); Roller.Throw(this, Drawables); Rotate = true; }
Roller GenerateRoller(int newRollerColorID, float startPosition = 0) { Roller newRoller = Instantiate(RollerPrefab, spawnPoint, Quaternion.identity, transform); newRoller.ActivateRoller(this, startPosition, newRollerColorID); return(newRoller); }
public void TestGiveRoller3Dice() { Roller roller = new Roller(); roller.ReplaceDice(3); Assert.AreEqual(3, roller.Dice.Count); }
public void TestRollerCreatesRollResults() { Roller roller = new Roller(); roller.ReplaceDice(3); Assert.IsInstanceOfType(roller.RollDiceAgainstThreshold(), typeof(RollResults)); }
public ActionResult DeleteConfirmed(int id) { Roller roller = db.Roller.Find(id); db.Roller.Remove(roller); db.SaveChanges(); return(RedirectToAction("Index")); }
public void TestRollerSystematicRolling() { Roller roller = new Roller(3); roller.ReplaceDice(5); Assert.AreEqual(roller.RollDiceAgainstThreshold(5), roller.RollDiceAgainstThreshold(5)); }
public void Successfully_CompareTwoDice_NotEqual() { var res = Roller.Roll("2d20", new RollerConfig() { GetRandomBytes = GetRNG(0, 1) }); Assert.IsTrue(res.Values[0] != res.Values[2]); }
public void ThrowInvalidOperationException_WhenTooLowMaxRerolls() { var conf = new RollerConfig() { MaxRerolls = -1 }; Roller.Roll("1d20", conf); }
public void ThrowInvalidOperationException_WhenTooFewMaxSides() { var conf = new RollerConfig() { MaxSides = 0 }; Roller.Roll("1d20", conf); }
public async Task RollSkill([Remainder] string skill) { var u = Utils.GetUser(Context.User.Id); if (u.Active == null) { await ReplyAsync(Context.User.Mention + ", you have no active character."); return; } var c = u.Active; string[] Bonuses = new string[0]; if (BonusRegex.IsMatch(skill)) { Bonuses = BonusRegex.Matches(skill).Select(x => x.Value).ToArray(); foreach (var b in Bonuses) { skill = skill.Replace(b, ""); } skill = skill.Trim(); } if (Constants.Skills.TryGetValue(skill.ToLower(), out string value)) { var dice = Roller.Roll("1d20" + (Bonuses.Length > 0 ? string.Join(" ", Bonuses) : "")); var embed = new EmbedBuilder() .WithTitle(c.Name + " makes a " + skill + " check.") .WithThumbnailUrl(c.Attributes["image"]); var fortune = int.Parse(c.Attributes[value]); var judgement = int.Parse(c.Attributes[value + "_judgement"]); if (dice.Value <= judgement) { embed.WithColor(Color.Red); embed.WithDescription("[**" + judgement + "**] | [" + (judgement + 1) + "~" + (fortune - 1) + "] | [" + fortune + "]\n" + ParseResult(dice) + " = `" + dice.Value + "` (Judgement)"); } else if (dice.Value >= fortune) { embed.WithColor(Color.Green); embed.WithDescription("[" + judgement + "] | [" + (judgement + 1) + "~" + (fortune - 1) + "] | [**" + fortune + "**]\n" + ParseResult(dice) + " = `" + dice.Value + "` (Fortune)"); } else { embed.WithColor(new Color(255, 255, 0)); embed.WithDescription("[" + judgement + "] | [**" + (judgement + 1) + "~" + (fortune - 1) + "**] | [" + fortune + "]\n" + ParseResult(dice) + " = `" + dice.Value + "` (Temperance)"); } await ReplyAsync(" ", false, embed.Build()); } else { await ReplyAsync(Context.User.Mention + ", This isn't a valid skill."); return; } }
public static Results Roll(this IEnumerable<IRollable> toRoll, int iterations) { var roller = new Roller(); foreach (var rollable in toRoll) { roller.AddRollable(rollable); } return roller.Roll(iterations); }
public ActionResult Edit([Bind(Include = "Id,RolAdi,RolOncelik")] Roller roller) { if (ModelState.IsValid) { db.Entry(roller).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(roller)); }
public void Successfully_PreserveMetadata() { var metadata = "foobar"; var res = Roller.Roll("1d20", Roll9Conf, new RollData() { Metadata = metadata }); Assert.AreEqual(metadata, (string)res.Metadata); }
public BattleInstance(GameSession session, PlayerCharacter player, BaseMonster monster) { CurrentSession = session; CurrentSession.ButtonContext = new BattleButtonContext(CurrentSession, this); CurrentPlayer = player; CurrentMonster = monster; DiceRoller = new Roller(); }
public void Successfully_RoundtripRollResult_ForPersistence() { var stream = new MemoryStream(); var result = Roller.Roll("1d20+4"); result.Serialize(stream); stream.Seek(0, SeekOrigin.Begin); var result2 = RollResult.Deserialize(stream); Assert.AreEqual(result, result2); }
public ActionResult Create([Bind(Include = "Id,RolAdi,RolOncelik")] Roller roller) { if (ModelState.IsValid) { db.Roller.Add(roller); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(roller)); }
private void Awake() { roller = GetComponent <Roller>(); _rigidbody = GetComponent <Rigidbody>(); _collider = GetComponent <Collider>(); cam = Camera.main.transform; roller.camOp = camOp; // Make sure we don't fall off StartCoroutine(CheckOutOfBounds()); }
private void TestParse(string text, string expected, float average, float[] frequencies) { Roller roller = Roller.Parse(text); Assert.AreEqual(expected, roller.ToString()); Assert.AreEqual(average, roller.Average); if (frequencies != null) { Statistics.TestFrequencies(frequencies, () => roller.Roll()); } }
static void Main(string[] args) { var roulette = new Roller(); roulette.Table = new Table(); roulette.Table.SetPrize("a", 20.0); roulette.Table.SetPrize("b", 20.0); var ret = roulette.Next(); Console.ReadKey(); }
public static Results Roll(this IRollable rollable, int iterations) { var roller = new Roller(); roller.AddRollable(rollable); return roller.Roll(iterations); }