private void DiceRollerMenuButton_Click(object sender, RoutedEventArgs e) { DieRoller dr = new DieRoller(); this.Close(); dr.Show(); }
public void Roll_1d1plus10_11() { // Arrange var roller = new DieRoller(); // Act var result = roller.Roll("1d1+10"); // Assert Assert.IsTrue(result == 11); }
public void Advantage() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("d20+", "joe", out result); Assert.IsTrue(passed); Assert.IsTrue(result.Contains("joe rolled D20 with advantage:")); }
void Awake() { instance = this; initialDiePositions = new Vector3[transform.childCount]; for (int i = 0; i < transform.childCount; i++) { initialDiePositions[i] = transform.GetChild(i).transform.position; transform.GetChild(i).gameObject.SetActive(false); } }
public void Simple() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("d4", "joe", out result); Assert.IsTrue(passed); Assert.IsTrue(result.Contains("joe rolled 1D4:")); }
public void NegativeMod() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("3d8-3", "joe", out result); Assert.IsTrue(passed); Assert.IsTrue(result.Contains("joe rolled 3D8-3:")); }
public void PositiveMod() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("4d6+2", "joe", out result); Assert.IsTrue(passed); Assert.IsTrue(result.Contains("joe rolled 4D6+2:")); }
public void MultiDie() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("3D8", "joe", out result); Assert.IsTrue(passed); Assert.IsTrue(result.Contains("joe rolled 3D8:")); }
public void BadInput() { var result = string.Empty; var roller = new DieRoller(); var passed = roller.TryParseDieRoll("nomatch", "joe", out result); Assert.IsFalse(passed); Assert.IsTrue(string.IsNullOrEmpty(result)); }
public void Roll_1d6plus1_2to7() { // Arrange var roller = new DieRoller(); // Act var result = roller.Roll("1d6+1"); // Assert Assert.IsTrue(result >= 2); Assert.IsTrue(result <= 7); }
public void Roll_2d6_2to12() { // Arrange var roller = new DieRoller(); // Act var result = roller.Roll("2d6"); // Assert Assert.IsTrue(result >= 2); Assert.IsTrue(result <= 12); }
public CommandHandler(IServiceProvider services) { this.services = services; config = services.GetRequiredService <IConfiguration>(); client = services.GetRequiredService <DiscordSocketClient>(); commands = services.GetRequiredService <CommandService>(); dieRoller = new DieRoller(); commands.CommandExecuted += CommandExecutedAsync; client.MessageReceived += HandleCommand; }
public void Roll_1d6_1to6() { // Arrange var roller = new DieRoller(); // Act var result = roller.Roll("1d6"); // Assert Assert.IsTrue(result >= 1); Assert.IsTrue(result <= 6); }
void Start() { _dieRoller = GameObject.FindObjectOfType <DieRoller>(); _currentPlayerText = transform.GetChild(0).GetComponent <Text>(); }
public override void Invoke(IAdventurePlayer player, ChatCommandEventArgs e) { var canMove = false; if (e.ArgsAsList.Count == 2) { var direction = e.ArgsAsList[1].ToLower(); if (player.CurrentLocation.IsDark) { if (!player.Statuses.Contains(PlayerStatus.HasLight)) { if (DieRoller.Percentage(34)) { player.ChatClient.PostDirectMessage(player, "You stumble around in the darkness and fall into " + "a deep pit. Your bones break as you thud into the rock at its base. Your lamp smashes and darkness engulfs you..."); player.Statuses.Add(PlayerStatus.IsDead); _game.EndOfGame(player); return; } player.ChatClient.PostDirectMessage(player, "It is pitch black! If you move around, you'll probably fall into a chasm or something..."); } } if (player.CurrentLocation.ValidMoves.Any(d => d.IsMatch(direction))) { var move = player.CurrentLocation.ValidMoves.First(d => d.IsMatch(direction)); var(moveAllowed, notAllowedText) = move.IsMoveAllowed(player, _game); if (moveAllowed) { var moveTo = move.Destination; var moveText = move.MoveText; canMove = _game.Dungeon.TryGetLocation(moveTo, out var place); if (canMove) { if (MoveAffectedByEncumberedStatus(player, move)) { return; } player.PriorLocation = player.CurrentLocation; player.CurrentLocation = place; player.Moves++; if (player.Clocks != null && player.Clocks.Count > 0) { var keys = player.Clocks.Keys.ToList(); foreach (var key in keys) { var ticks = player.Clocks[key]; ticks++; player.Clocks[key] = ticks; } } if (!string.IsNullOrWhiteSpace(moveText)) { player.ChatClient.PostDirectMessage(player, moveText); } player.ChatClient.PostDirectMessage(player, "*" + player.CurrentLocation.Name + "*"); return; } } else { player.ChatClient.PostDirectMessage(player, "*" + player.CurrentLocation.Name + "*"); player.ChatClient.PostDirectMessage(player, notAllowedText); return; } } } player.ChatClient.PostDirectMessage(player, "You cannot go in that direction! Try *look* so see where you might go."); player.ChatClient.PostDirectMessage(player, "*" + player.CurrentLocation.Name + "*"); }
void Start() { _dieRoller = GameObject.FindObjectOfType <DieRoller>(); _turnController = GameObject.FindObjectOfType <TurnController>(); }
public bool Do(IAdventurePlayer player, IAdventureItem item) { return(DieRoller.Percentage(_pct)); }