Esempio n. 1
0
    public static RollResult GetResultFromRoll(IAttacker attacker, IDefender defender, List <int> rolledFaceIndexAttack, List <int> rolledFaceIndexDefense)
    {
        var result = new RollResult();

        if (attacker != null)
        {
            var attackerDice = attacker.AttackDice;
            for (int i = 0; i < attackerDice.Count; ++i)
            {
                var face = attackerDice[i].GetFace(rolledFaceIndexAttack[i]);
                result.heart     += face.heart;
                result.surge     += face.surge;
                result.range     += face.range;
                result.pierce     = attacker.Pierce;
                result.bonusRange = attacker.RangeModifier;
                if (face.IsMiss)
                {
                    result.miss = true;
                }
            }
        }
        if (defender != null)
        {
            var defenderDice = defender.DefenseDice;
            for (int i = 0; i < defenderDice.Count; ++i)
            {
                result.defense += defenderDice[i].GetDefensePerFace(rolledFaceIndexDefense[i]);
            }
        }
        result.defense = Mathf.Max(0, result.defense);

        return(result);
    }
Esempio n. 2
0
        public override void attack(IDefender DefenderVisitor)
        {
            int damage;

            damage = DefenderVisitor.Defend(this);
            this.GetDamage(damage);
        }
Esempio n. 3
0
        public override void attack(IDefender DefenderVisitor)
        {
            int damage;

            damage = DefenderVisitor.Defend(this);

            GetDamage(Math.Max(1, (damage - Armor)));
        }
Esempio n. 4
0
        private bool CalculateHit(IAttacker attacker, IDefender target)
        {
            int armorClass = target.GetArmorClass();
            int hitBonus = attacker.GetHitBonus();
            int roll = rng.RandiRange(1, 20);

            return (roll + hitBonus) >= armorClass;
        }
Esempio n. 5
0
 public void ResolveAttack(IAttacker attacker, IDefender target)
 {
     bool hit = CalculateHit(attacker, target);
     if (hit)
     {
         int damage = CalculateDamage(attacker);
         target.TakeDamage(damage);
     }
 }
Esempio n. 6
0
        public override void attack(IDefender DefenderVisitor)
        {
            int damage;

            damage = DefenderVisitor.Defend(this);
            if (damage != 0)
            {
                Speed++;
            }
            GetDamage(damage);
        }
Esempio n. 7
0
        public override void Attacked(IDefender defender)
        {
            int damage = defender.Attack(this);

            if (damage > Armor)
            {
                damage -= Armor;
            }
            else if (damage > 0)
            {
                damage = 1; //in the .txt it says "but always at least 1 point", not sure if it refers to this
            }
            GetDamage(damage);
        }
        public static void Main()
        {
            SoldierList soldiers = new SoldierList();
            King        king     = new King(Console.ReadLine());

            string[] royalGuardNames = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var name in royalGuardNames)
            {
                RoyalGuard rg = new RoyalGuard(name);
                rg.SoldierDead += soldiers.HandleDeadSoldier;
                rg.SoldierDead += king.OnSoldierDeath;
                soldiers.Add(rg);
                king.KingAttacked += rg.OnKingAttack;
            }

            string[] footmanNames = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var name in footmanNames)
            {
                Footman fm = new Footman(name);
                fm.SoldierDead += soldiers.HandleDeadSoldier;
                fm.SoldierDead += king.OnSoldierDeath;
                soldiers.Add(fm);
                king.KingAttacked += fm.OnKingAttack;
            }

            string command = string.Empty;

            while ((command = Console.ReadLine()) != "End")
            {
                var tokens = command.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (tokens[0] == "Attack")
                {
                    king.RespondToAttack();
                }
                else if (tokens[0] == "Kill")
                {
                    string    name    = tokens[1];
                    IDefender soldier = soldiers.First(x => x.Name == name);
                    soldier.TakeAttack();
                }
            }
        }
Esempio n. 9
0
        protected Int32 Dmg(IDefender Target)
        {
            Int32 TrueDmg = Dmg();

            if (Scale == Skills.Scale.Ap)
            {
                TrueDmg -= Target.Armor.Int();
            }
            else
            {
                TrueDmg -= Target.Barrier.Int();
            }

            if (TrueDmg < 0)
            {
                TrueDmg = 0;
            }

            return(TrueDmg);
        }
Esempio n. 10
0
    public void Setup(IAttacker attacker, IDefender defender)
    {
        gameObject.SetActive(true);
        ResetResultsText();
        _attacker          = attacker;
        _textAttacker.text = "";
        if (_attacker != null)
        {
            if ((_attacker is ItemWeaponDef))
            {
                _textAttacker.text += Game.PlayerCharacter.name + " (" + _attacker.name + ")";
            }
            else
            {
                _textAttacker.text += _attacker.name;
            }
        }
        else
        {
            _textAttacker.text = "Manually roll attack dice for Attacker.";
        }
        UpdatePierce(_attacker);
        UpdateRangeModifier(_attacker);

        _defender          = defender;
        _textDefender.text = "";
        if (_defender != null)
        {
            _textDefender.text += _defender.name;
        }
        else
        {
            _textDefender.text = "Manually roll defense dice for Defender(s).";

            if (!(_attacker is MonsterDef.Properties))
            {
                _textDefender.text += "\n\n<b>Road to Legend</b>: When targeting multiple monsters, apply half damage (rounded up) to <u>additional</u> targets.";
            }
        }
        _textRange.transform.parent.gameObject.SetActive(_attacker != null && _attacker.AttackType == AttackType.Ranged);
    }
Esempio n. 11
0
    public static RollResult CombatRoll(IAttacker attacker, IDefender defender, out List <int> rolledFaceIndexAttack, out List <int> rolledFaceIndexDefense)
    {
        rolledFaceIndexAttack  = new List <int>();
        rolledFaceIndexDefense = new List <int>();

        if (attacker != null)
        {
            var attackerDice = attacker.AttackDice;
            for (int i = 0; i < attackerDice.Count; ++i)
            {
                rolledFaceIndexAttack.Add(attackerDice[i].Roll());
            }
        }
        if (defender != null)
        {
            var defenderDice = defender.DefenseDice;
            for (int i = 0; i < defenderDice.Count; ++i)
            {
                rolledFaceIndexDefense.Add(defenderDice[i].Roll());
            }
        }

        return(GetResultFromRoll(attacker, defender, rolledFaceIndexAttack, rolledFaceIndexDefense));
    }
Esempio n. 12
0
 public void AddDefender(IDefender def)
 {
     defenders.Add(def);
 }
Esempio n. 13
0
 public override void Attacked(IDefender defender)
 {
     GetDamage(defender.Attack(this));
 }
Esempio n. 14
0
 public abstract void attack(IDefender DefenderVisitor);
Esempio n. 15
0
 public void RegisterObserver(IDefender battleObserver)
 {
     Observers.Add(battleObserver);
 }
Esempio n. 16
0
 abstract public void Attacked(IDefender defender);
Esempio n. 17
0
 public override void AttackedBy(IDefender defender)
 {
     //Console.WriteLine($"{defender.GetType()} {defender.Name} attacked {this.GetType()} {this.Name} ");
     defender.Attack(this);
 }
Esempio n. 18
0
 public abstract void AttackedBy(IDefender defender);
Esempio n. 19
0
 public override void AttackedBy(IDefender defender)
 {
     defender.Attack(this);
 }
 public SoldierArgs(IDefender soldier, KingUnderAttackEventHandler onKingAttack)
 {
     this.Soldier      = soldier;
     this.OnKingAttack = onKingAttack;
 }
Esempio n. 21
0
 public void AddDefender(IDefender defender)
 {
     this.Defenders.Add(defender);
     this.AttackEvent += defender.RespondAttack;
 }
Esempio n. 22
0
 public void AddDefender(IDefender defender)
 {
     this.Defenders.Add(defender);
     this.AttackEvent      += defender.RespondAttack;
     defender.DefenceEvent += this.OnDefenderDie;
 }
Esempio n. 23
0
 public void UnregisterObserver(IDefender observer)
 {
     Observers.Remove(observer);
 }
Esempio n. 24
0
 public void SetDefender(IDefender defender)
 {
     this.defender = defender;
 }