Beispiel #1
0
        public void RollInRangeTest()
        {
            // Arrange

            // Act
            var score = _d20.Roll();

            // Assert
            Assert.InRange(score, 1, 20);
        }
Beispiel #2
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);
        }
Beispiel #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!");
     }
 }
        public int SavingThrow(Character.Character character)
        {
            var d20  = new D20();
            var roll = d20.Roll() + Modifier;

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

            return(roll);
        }
        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);
            }
        }
Beispiel #6
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;
                }
            }
        }
Beispiel #7
0
        public void RollInRangeTest()
        {
            var score = _d20.Roll();

            Assert.InRange(score, 1, 20);
        }
Beispiel #8
0
 public virtual bool Hide()
 {
     Console.WriteLine($"{Name} is attempting to hide..");
     HiddenDc = D20.Roll(1, getModifier("DEX"), true);
     return(true);
 }
Beispiel #9
0
 public void InitiativeRoll(int mod = 0)
 {
     CurrentInitiative = D20.Roll(1, (getModifier("DEX") + mod));
 }
        public int AbilityCheck(Character.Character character)
        {
            var d20 = new D20();

            return(d20.Roll() + Modifier);
        }