public void BattleArmy_RemoveStack() { Unit angel = new UnitAngel(); Unit skeleton = new UnitSkeleton(); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(skeleton, 42); List <UnitsStack> stacks = new List <UnitsStack> { stack1, stack2 }; Army baseArmy = new Army(stacks); BattleArmy army = new BattleArmy(baseArmy, null); BattleUnitsStack stack = army.GetStack(0); Assert.AreEqual(2, army.GetStacks().Count); Assert.IsTrue(army.RemoveStack(stack)); Assert.AreEqual(1, army.GetStacks().Count); Assert.IsFalse(army.RemoveStack(stack)); }
public void CreateBattleArmy() { Unit angel = new UnitAngel(); Unit skeleton = new UnitSkeleton(); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(skeleton, 42); List <UnitsStack> stacks = new List <UnitsStack> { stack1, stack2 }; Army baseArmy = new Army(stacks); BattleArmy army = new BattleArmy(baseArmy, null); Assert.AreEqual(baseArmy, army.GetBaseArmy()); Assert.IsNull(army.GetBattle()); Assert.AreEqual(stack1, army.GetBaseArmy().GetStacks()[0]); Assert.AreEqual(stack2, army.GetBaseArmy().GetStacks()[1]); Assert.AreEqual(stack1, army.GetStack(0).GetBaseStack()); Assert.AreEqual(stack2, army.GetStack(1).GetBaseStack()); }
public void Act(BattleAction action, UnitsStack stack, params UnitsStack[] stacks) { action.Act(this, stack, stacks); stack.Refresh(); foreach (var s in stacks) { s.Refresh(); } UpdateInitiativeScales(); if (!CurrentRound.IsFinished) { return; } ++Round; foreach (var s in Stacks) { s.UpdateModifiers(); s.Refresh(); } UpdateInitiativeScales(); }
public void BattleArmy_AddStack() { Unit angel = new UnitAngel(); Unit skeleton = new UnitSkeleton(); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(angel, 5); List <UnitsStack> stacks = new List <UnitsStack> { stack1, stack2 }; Army baseArmy = new Army(stacks); BattleArmy army = new BattleArmy(baseArmy, null); BattleUnitsStack stack3 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack4 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack5 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack6 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack7 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack8 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack9 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); BattleUnitsStack stack10 = new BattleUnitsStack(new UnitsStack(skeleton, 42), army); Assert.AreEqual(2, army.GetStacks().Count); army.AddStack(stack3); Assert.AreEqual(3, army.GetStacks().Count); Assert.AreEqual(stack3, army.GetStack(2)); army.AddStack(stack4); army.AddStack(stack5); army.AddStack(stack6); army.AddStack(stack7); army.AddStack(stack8); army.AddStack(stack9); Assert.AreEqual(9, army.GetStacks().Count); Assert.Throws <ArgumentOutOfRangeException>(() => army.AddStack(stack10)); }
public override void Apply(UnitsStack self) { self.DamageHandlers.Add((attacker, defender, damage) => Math.Max(defender.LastUnitHitPoints, damage)); }
public abstract void Process(UnitsStack stack);
public abstract void Apply(UnitsStack self);
public virtual bool CanCast(Cast cast, UnitsStack target) => true;
public virtual bool CanAttack(UnitsStack enemy) => true;
public override void Apply(UnitsStack self) { self.SetAbility("wait", false); self.SetAbility("cast", false); self.UpdateAttack((uint)Math.Round(self.Attack * AttackMultiplier)); }
public void Apply(UnitsStack self) => self.SetAbility("retaliate", true);
public abstract bool Available(Battle battle, UnitsStack stack);
public abstract void Act(Battle battle, UnitsStack stack, params UnitsStack[] stacks);
public abstract bool Validate(Battle battle, UnitsStack stack, params UnitsStack[] stacks);
public abstract Info RequiredInfo(Battle battle, UnitsStack stack);
public void Mod_Battle_TestBattle() { Skill resurrect = Skills.Skills.GetSkill("resurrect"); Unit angel = Units.Units.GetUnit("angel"); Unit skeleton = Units.Units.GetUnit("skeleton"); Unit lich = Units.Units.GetUnit("lich"); UnitsStack stack1 = new UnitsStack(angel, 10); UnitsStack stack2 = new UnitsStack(skeleton, 42); UnitsStack stack3 = new UnitsStack(lich, 5); UnitsStack stack4 = new UnitsStack(lich, 20); List <UnitsStack> stacks1 = new List <UnitsStack> { stack1, stack2 }; List <UnitsStack> stacks2 = new List <UnitsStack> { stack3, stack4 }; Army army1 = new Army(stacks1); Army army2 = new Army(stacks2); Battle battle = new Battle(army1, army2); IList <BattleUnitsStack> battleStacks = battle.GetStacks(); BattleUnitsStack battleStack1 = battleStacks[0]; BattleUnitsStack battleStack2 = battleStacks[1]; BattleUnitsStack battleStack3 = battleStacks[2]; BattleUnitsStack battleStack4 = battleStacks[3]; battle.Start(); Assert.AreEqual(1, battle.GetRound()); Assert.AreEqual(battleStack1, battle.GetCurrentStack()); Assert.Throws <ArgumentException>(() => battle.UseSkill(resurrect, battleStack2)); battle.Attack(battleStack4); Assert.AreEqual(1800, battleStack1.GetHitPoints()); Assert.AreEqual(280, battleStack4.GetHitPoints()); Assert.AreEqual(battleStack2, battle.GetCurrentStack()); battle.Wait(); Assert.IsTrue(battleStack2.IsWaiting()); Assert.AreEqual(battleStack3, battle.GetCurrentStack()); battle.UseSkill(resurrect, battleStack3); Assert.AreEqual(battleStack3, battle.GetCurrentStack()); battle.UseSkill(resurrect, battleStack1); Assert.AreEqual(battleStack3, battle.GetCurrentStack()); battle.UseSkill(resurrect, battleStack4); Assert.AreEqual(530, battleStack4.GetHitPoints()); Assert.AreEqual(battleStack4, battle.GetCurrentStack()); battle.Attack(battleStack2); Assert.AreEqual(0, battleStack2.GetHitPoints()); Assert.AreEqual(530, battleStack4.GetHitPoints()); Assert.AreEqual(2, battle.GetRound()); Assert.AreEqual(battleStack1, battle.GetCurrentStack()); battle.Attack(battleStack4); Assert.AreEqual(0, battleStack4.GetHitPoints()); Assert.AreEqual(1800, battleStack1.GetHitPoints()); Assert.AreEqual(battleStack3, battle.GetCurrentStack()); battle.Attack(battleStack1); Assert.AreEqual(1763, battleStack1.GetHitPoints()); Assert.AreEqual(250, battleStack3.GetHitPoints()); Assert.AreEqual(3, battle.GetRound()); Assert.AreEqual(battleStack1, battle.GetCurrentStack()); battle.Attack(battleStack3); Assert.AreEqual(0, battleStack3.GetHitPoints()); Assert.AreEqual(1763, battleStack1.GetHitPoints()); Assert.AreEqual(BattleState.Ended, battle.GetBattleState()); Assert.AreEqual(army1, battle.GetWinner().GetBaseArmy()); }
public override void Apply(UnitsStack self) => self.SetAbility("act", false);
public override bool Available(Battle battle, UnitsStack stack) => stack.Modifiers.All(m => m.CanWait());
public override void Process(UnitsStack stack) { throw new System.NotImplementedException(); }
public override bool Validate(Battle battle, UnitsStack stack, params UnitsStack[] stacks) => Available(battle, stack);
public virtual bool CanBeAttacked(UnitsStack enemy) => true;
public override void Act(Battle battle, UnitsStack stack, params UnitsStack[] stacks) => stack.AddTemporaryModifier(new Modifiers.AlreadyWait(), new TurnModifierChecker(1));
public virtual bool CanGotRetaliate(UnitsStack enemy) => true;
public override bool CanBeAttacked(UnitsStack enemy) => false;
public virtual uint FixDamage(UnitsStack attacker, UnitsStack defender, uint damage) => damage;
public override bool CanCast(Cast cast, UnitsStack target) => false;
public void Add(UnitsStack b, Position p) { a.addBattleUnitStack(b, p); transform.GetChild(transform.childCount - 1).GetComponent <uBattleUnitsStack>() .fill(a.getBUS(transform.childCount - 1)); }
public override bool CanGotRetaliate(UnitsStack enemy) => false;
public override void Process(UnitsStack stack) { }
public override void Apply(UnitsStack self) { self.UpdateAttack((uint)Math.Round(self.Attack * AttackMultiplier)); }