Beispiel #1
0
        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));
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
 public override void Apply(UnitsStack self)
 {
     self.DamageHandlers.Add((attacker, defender, damage) =>
                             Math.Max(defender.LastUnitHitPoints, damage));
 }
Beispiel #6
0
 public abstract void Process(UnitsStack stack);
Beispiel #7
0
 public abstract void Apply(UnitsStack self);
Beispiel #8
0
 public virtual bool CanCast(Cast cast, UnitsStack target) => true;
Beispiel #9
0
 public virtual bool CanAttack(UnitsStack enemy) => true;
Beispiel #10
0
 public override void Apply(UnitsStack self)
 {
     self.SetAbility("wait", false);
     self.SetAbility("cast", false);
     self.UpdateAttack((uint)Math.Round(self.Attack * AttackMultiplier));
 }
Beispiel #11
0
 public void Apply(UnitsStack self) => self.SetAbility("retaliate", true);
Beispiel #12
0
 public abstract bool Available(Battle battle, UnitsStack stack);
Beispiel #13
0
 public abstract void Act(Battle battle, UnitsStack stack, params UnitsStack[] stacks);
Beispiel #14
0
 public abstract bool Validate(Battle battle, UnitsStack stack, params UnitsStack[] stacks);
Beispiel #15
0
 public abstract Info RequiredInfo(Battle battle, UnitsStack stack);
Beispiel #16
0
        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());
        }
Beispiel #17
0
 public override void Apply(UnitsStack self) => self.SetAbility("act", false);
Beispiel #18
0
 public override bool Available(Battle battle, UnitsStack stack)
 => stack.Modifiers.All(m => m.CanWait());
Beispiel #19
0
 public override void Process(UnitsStack stack)
 {
     throw new System.NotImplementedException();
 }
Beispiel #20
0
 public override bool Validate(Battle battle, UnitsStack stack, params UnitsStack[] stacks)
 => Available(battle, stack);
Beispiel #21
0
 public virtual bool CanBeAttacked(UnitsStack enemy) => true;
Beispiel #22
0
 public override void Act(Battle battle, UnitsStack stack, params UnitsStack[] stacks)
 => stack.AddTemporaryModifier(new Modifiers.AlreadyWait(), new TurnModifierChecker(1));
Beispiel #23
0
 public virtual bool CanGotRetaliate(UnitsStack enemy) => true;
Beispiel #24
0
 public override bool CanBeAttacked(UnitsStack enemy) => false;
Beispiel #25
0
 public virtual uint FixDamage(UnitsStack attacker, UnitsStack defender, uint damage) => damage;
Beispiel #26
0
 public override bool CanCast(Cast cast, UnitsStack target) => false;
Beispiel #27
0
 public void Add(UnitsStack b, Position p)
 {
     a.addBattleUnitStack(b, p);
     transform.GetChild(transform.childCount - 1).GetComponent <uBattleUnitsStack>()
     .fill(a.getBUS(transform.childCount - 1));
 }
Beispiel #28
0
 public override bool CanGotRetaliate(UnitsStack enemy) => false;
Beispiel #29
0
 public override void Process(UnitsStack stack)
 {
 }
Beispiel #30
0
 public override void Apply(UnitsStack self)
 {
     self.UpdateAttack((uint)Math.Round(self.Attack * AttackMultiplier));
 }