Exemplo n.º 1
0
        public List <IMappable> BaseSearch()
        {
            Console.WriteLine($"{Name} is searching...");
            int perceptionRoll  = D20.Roll(1, getModifier("WIS"), true);
            int perceptionCheck = perceptionRoll >= PassivePerception ? perceptionRoll : PassivePerception;
            int searchRangeFeet = (perceptionCheck - 8) * 5;

            var foundObjects = Location.GetObjectsWithinRange(searchRangeFeet / 5).Where(fO => fO is INamed && fO != this).ToList();

            foundObjects.RemoveAll(fO =>
                                   // Entity is not found if it is on another team and is successfully hiding:
                                   fO is Entity &&
                                   (fO as Entity).Team != Team &&
                                   (fO as Entity).HiddenDc > perceptionCheck ||
                                   // Object is not found if line of sight is blocked:
                                   !hasLineOfSightTo(fO));
            foreach (var obj in foundObjects)
            {
                if (obj is Entity && (obj as Entity).Team != Team)
                {
                    (obj as Entity).RevealIfHidden(this);
                }
            }
            return(foundObjects);
        }
Exemplo n.º 2
0
        public void ValidateThatDiceIsRolledCorrectNumberOfTimes(int numDice, int numSides)
        {
            // Arange
            var d20 = new D20(numDice, numSides);

            // Act
            var rolls = d20.Rolls;

            //Assert
            Assert.Equal(numDice, rolls.Count());
        }
Exemplo n.º 3
0
 public int AbilityCheck(string abil)
 {
     if (AbilityScores.BaseScores.ContainsKey(abil))
     {
         Console.WriteLine($"Rolling {AbilityScores.BaseScores[abil].Name} check for {this.Name}...");
         return(D20.Roll(1, getModifier(abil), true));
     }
     else
     {
         throw new InvalidAbilityException($"Ability '{abil}' in entity '{this.Name}' is not valid!");
     }
 }
Exemplo n.º 4
0
        public void ValidateThatRollsReturnsValidRolls(int numDice, int numSides)
        {
            // Arrange
            var d20 = new D20(numDice, numSides);

            // Act
            var rolls = d20.Rolls;

            // Assert
            Assert.Equal(numDice, rolls.Count());
            Assert.True(rolls.All(roll => roll >= 1 && roll <= numSides));
        }
Exemplo n.º 5
0
        public void ValidateThatStringConstructorSetsPropertiesCorrectly()
        {
            // Arrange
            var d20string = "3d6";

            // Act
            var d20 = new D20(d20string);

            // Assert
            Assert.Equal(3, d20.NumDice);
            Assert.Equal(6, d20.NumSides);
        }
Exemplo n.º 6
0
        public int SavingThrow(Character.Character character)
        {
            var d20  = new D20();
            var roll = d20.Roll() + Modifier;

            if (SavingThrowProficiency)
            {
                roll += character.Class.ProfBonus;
            }

            return(roll);
        }
Exemplo n.º 7
0
        public void ValidateThatIntConstructorSetsPropertiesCorrectly()
        {
            // Arrange
            var numDice  = 3;
            var numSides = 6;

            // Act
            var d20 = new D20(numDice, numSides);

            // Assert
            Assert.Equal(numDice, d20.NumDice);
            Assert.Equal(numSides, d20.NumSides);
        }
Exemplo n.º 8
0
        public void ValidateThatRollsAreDifferentEachTime()
        {
            // Arrange
            var numDice  = 100;
            var numSides = 100;
            var d20      = new D20(numDice, numSides);

            // Act
            var firstRolls  = d20.Rolls;
            var secondRolls = d20.Rolls;

            // Assert
            Assert.False(firstRolls.SequenceEqual(secondRolls));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="accessors">A class containing <see cref="IStatePropertyAccessor{T}"/> used to manage state.</param>
        /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> that is hooked to the Azure App Service provider.</param>
        /// <seealso cref="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#windows-eventlog-provider"/>
        public VoicyBot1Bot(VoicyBot1Accessors accessors, ILoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _logger = loggerFactory.CreateLogger <VoicyBot1Bot>();
            _logger.LogTrace("Turn start.");
            _accessors = accessors ?? throw new ArgumentNullException(nameof(accessors));

            _questionsAboutTime = new QuestionsAboutTime();
            _retorts            = new Retorts();
            _d20         = new D20();
            _translation = new Translation();
            _images      = new Images();
        }
Exemplo n.º 10
0
        public IActionResult GetDiceRoll([FromRoute] string d20string)
        {
            D20 d20;

            try
            {
                d20 = new D20(d20string);
            }
            catch
            {
                return(BadRequest());
            }

            return(Ok(new PipsResponse {
                Request = d20string, Rolls = d20.Rolls
            }));
        }
Exemplo n.º 11
0
        public void DetermineTurnOrder(List <Character.Character> chars)
        {
            Dictionary <Character.Character, int> initiativeRolls = new Dictionary <Character.Character, int>();

            var d20 = new D20();

            foreach (var character in chars)
            {
                initiativeRolls.Add(character, d20.Roll() + character.InitiativeBonus);
            }

            var sortedRolls = initiativeRolls.ToList();

            sortedRolls.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));

            for (int i = 0; i <= sortedRolls.Count; i++)
            {
                TurnOrder.Insert(i, sortedRolls[i].Key);
            }
        }
Exemplo n.º 12
0
        public override void DoAction(Character.Character attacker, Character.Character defender)
        {
            var d20        = new D20();
            var attackRoll = d20.Roll();

            if (attackRoll == 20)
            {
                var damage = RollDamage(attacker.EquippedWeapon, 2);
                defender.HitPoints -= damage + attacker.Str.Modifier;
            }
            else
            {
                attackRoll += attacker.Str.Modifier + attacker.Class.ProfBonus;

                if (attackRoll >= defender.AC)
                {
                    var damage = RollDamage(attacker.EquippedWeapon, 1);
                    defender.HitPoints -= damage + attacker.Str.Modifier;
                }
            }
        }
Exemplo n.º 13
0
        static public bool Hit(iCharacter one, iCharacter two)
        {
            int mod;
            int hit;
            int roll = new D20().Roll();

            switch (one.weapon.type)
            {
            case "Str":
                mod = Mod(one.Str);
                hit = roll + mod;
                Console.Write(one.name + " rolls a " + hit + "(" + roll + " + " + mod + " Str mod): ");
                break;

            case "Dex":
                mod = Mod(one.Dex);
                hit = roll + mod;
                Console.Write(one.name + " rolls a " + hit + "(" + roll + " + " + mod + " Dex mod): ");
                break;

            default:
                mod = Mod(one.Str);
                hit = roll + mod;
                Console.Write(one.name + " rolls a " + hit + "(" + roll + " + " + mod + " Str mod): ");
                break;
            }
            if (hit >= two.AC)
            {
                Console.WriteLine("Hit");
                return(true);
            }
            else
            {
                Console.WriteLine("Miss");
                return(false);
            }
        }
Exemplo n.º 14
0
        public int AbilityCheck(Character.Character character)
        {
            var d20 = new D20();

            return(d20.Roll() + Modifier);
        }
Exemplo n.º 15
0
 public D20Tests()
 {
     _d20 = new D20();
 }
Exemplo n.º 16
0
 public virtual bool Hide()
 {
     Console.WriteLine($"{Name} is attempting to hide..");
     HiddenDc = D20.Roll(1, getModifier("DEX"), true);
     return(true);
 }
Exemplo n.º 17
0
 public void InitiativeRoll(int mod = 0)
 {
     CurrentInitiative = D20.Roll(1, (getModifier("DEX") + mod));
 }
Exemplo n.º 18
0
 protected new void Awake()
 {
     base.Awake();
     sm = GameObject.FindWithTag("MainCamera").GetComponent<StateMachine>();
     nametag = gameObject.AddComponent<Nametag>();
     pathfinding = gameObject.AddComponent<Pathfinding>();
     d20 = gameObject.AddComponent<D20>();
 }
Exemplo n.º 19
0
        public int CompareTo(ReconciliationItem other)
        {
            int result = 1;

            if (other != null)
            {
                result = D1.CompareTo(other.D1);
                if (result == 0)
                {
                    result = D2.CompareTo(other.D2);
                    if (result == 0)
                    {
                        result = D3.CompareTo(other.D3);
                        if (result == 0)
                        {
                            result = D4.CompareTo(other.D4);
                            if (result == 0)
                            {
                                result = D5.CompareTo(other.D5);
                                if (result == 0)
                                {
                                    result = D6.CompareTo(other.D6);
                                    if (result == 0)
                                    {
                                        result = D7.CompareTo(other.D7);
                                        if (result == 0)
                                        {
                                            result = D8.CompareTo(other.D8);
                                            if (result == 0)
                                            {
                                                result = D9.CompareTo(other.D9);
                                                if (result == 0)
                                                {
                                                    result = D10.CompareTo(other.D10);
                                                    if (result == 0)
                                                    {
                                                        result = D11.CompareTo(other.D11);
                                                        if (result == 0)
                                                        {
                                                            result = D12.CompareTo(other.D12);
                                                            if (result == 0)
                                                            {
                                                                result = D13.CompareTo(other.D13);
                                                                if (result == 0)
                                                                {
                                                                    result = D14.CompareTo(other.D14);
                                                                    if (result == 0)
                                                                    {
                                                                        result = D15.CompareTo(other.D15);
                                                                        if (result == 0)
                                                                        {
                                                                            result = D16.CompareTo(other.D16);
                                                                            if (result == 0)
                                                                            {
                                                                                result = D17.CompareTo(other.D17);
                                                                                if (result == 0)
                                                                                {
                                                                                    result = D18.CompareTo(other.D18);
                                                                                    if (result == 0)
                                                                                    {
                                                                                        result = D19.CompareTo(other.D19);
                                                                                        if (result == 0)
                                                                                        {
                                                                                            result = D20.CompareTo(other.D20);
                                                                                            if (result == 0)
                                                                                            {
                                                                                                result = D21.CompareTo(other.D21);
                                                                                                if (result == 0)
                                                                                                {
                                                                                                    result = D22.CompareTo(other.D22);
                                                                                                    if (result == 0)
                                                                                                    {
                                                                                                        result = D23.CompareTo(other.D23);
                                                                                                        if (result == 0)
                                                                                                        {
                                                                                                            result = D24.CompareTo(other.D24);
                                                                                                            if (result == 0)
                                                                                                            {
                                                                                                                result = D25.CompareTo(other.D25);
                                                                                                                if (result == 0)
                                                                                                                {
                                                                                                                    result = D26.CompareTo(other.D26);
                                                                                                                    if (result == 0)
                                                                                                                    {
                                                                                                                        result = D27.CompareTo(other.D27);
                                                                                                                        if (result == 0)
                                                                                                                        {
                                                                                                                            result = D28.CompareTo(other.D28);
                                                                                                                            if (result == 0)
                                                                                                                            {
                                                                                                                                return(D29.CompareTo(other.D29));
                                                                                                                            }
                                                                                                                        }
                                                                                                                    }
                                                                                                                }
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 20
0
 protected void Start()
 {
     sm = GameObject.FindWithTag("MainCamera").GetComponent<StateMachine>();
     d20 = GetComponent<D20>();
     rb2d = GetComponent<Rigidbody2D>();
     bc2d = GetComponent<BoxCollider2D>();
     cc2d = GetComponent<CircleCollider2D>();
     p = GetComponent<Pathfinding>();
     e = GetComponent<Entity>();
     i = e.getInventory();
     hitter = GetComponent<Animator>();
 }