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); }
public override void attack(IDefender DefenderVisitor) { int damage; damage = DefenderVisitor.Defend(this); this.GetDamage(damage); }
public override void attack(IDefender DefenderVisitor) { int damage; damage = DefenderVisitor.Defend(this); GetDamage(Math.Max(1, (damage - Armor))); }
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; }
public void ResolveAttack(IAttacker attacker, IDefender target) { bool hit = CalculateHit(attacker, target); if (hit) { int damage = CalculateDamage(attacker); target.TakeDamage(damage); } }
public override void attack(IDefender DefenderVisitor) { int damage; damage = DefenderVisitor.Defend(this); if (damage != 0) { Speed++; } GetDamage(damage); }
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(); } } }
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); }
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); }
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)); }
public void AddDefender(IDefender def) { defenders.Add(def); }
public override void Attacked(IDefender defender) { GetDamage(defender.Attack(this)); }
public abstract void attack(IDefender DefenderVisitor);
public void RegisterObserver(IDefender battleObserver) { Observers.Add(battleObserver); }
abstract public void Attacked(IDefender defender);
public override void AttackedBy(IDefender defender) { //Console.WriteLine($"{defender.GetType()} {defender.Name} attacked {this.GetType()} {this.Name} "); defender.Attack(this); }
public abstract void AttackedBy(IDefender defender);
public override void AttackedBy(IDefender defender) { defender.Attack(this); }
public SoldierArgs(IDefender soldier, KingUnderAttackEventHandler onKingAttack) { this.Soldier = soldier; this.OnKingAttack = onKingAttack; }
public void AddDefender(IDefender defender) { this.Defenders.Add(defender); this.AttackEvent += defender.RespondAttack; }
public void AddDefender(IDefender defender) { this.Defenders.Add(defender); this.AttackEvent += defender.RespondAttack; defender.DefenceEvent += this.OnDefenderDie; }
public void UnregisterObserver(IDefender observer) { Observers.Remove(observer); }
public void SetDefender(IDefender defender) { this.defender = defender; }