Esempio n. 1
0
 public void Attack(BattleUnitStack from, List <BattleUnitStack> to)
 {
     to.ForEach(stack =>
     {
         var dealt    = from.OnAttack(stack);
         var inReturn = stack.OnDefense(from, dealt);
         from.DecreaseHealth(inReturn);
     });
 }
Esempio n. 2
0
 public void UseSpell(BattleUnitStack from, List <BattleUnitStack> to, ISpell spell)
 {
     if (!from.GetSpells().Contains(spell))
     {
         throw new ArgumentOutOfRangeException("From stack does not contain provided spell");
     }
     Console.WriteLine($"Using spell {spell}");
     to.ForEach(stack => spell.Apply(stack));
 }
Esempio n. 3
0
        public int OnDefense(BattleUnitStack from, int received)
        {
            //var received = Utils.CalculateDamage(from, this);

            DecreaseHealth(received);

            // Calculate damage in return
            if (Count < 0)
            {
                return(0);
            }

            return(Utils.CalculateDamage(this, from));
        }
Esempio n. 4
0
        public static int CalculateDamage(BattleUnitStack first, BattleUnitStack second)
        {
            var random = new Random();
            var result = first.Count * random.Next(first.UnitType.Damage.Item1, first.UnitType.Damage.Item2);

            if (first.Attack > second.Defense)
            {
                return((int)Math.Round(result * (1 + 0.05 * (first.Attack - second.Defense))));
            }
            else
            {
                return((int)Math.Round(result * (1 + 0.05 * (second.Defense - first.Attack))));
            }
        }
Esempio n. 5
0
        public void Await(BattleUnitStack stack)
        {
            if (firstQueue.Count == 0)
            {
                throw new Exception("Queue is empty");
            }
            if (!firstQueue.Contains(stack))
            {
                throw new Exception("Stack is not in the queue!");
            }
            if (!firstQueue.Peek().Equals(stack))
            {
                throw new Exception("Stack is not first");
            }
            var toAwait = firstQueue.Dequeue();

            awaitQueue.Push(toAwait);
        }
Esempio n. 6
0
 public int OnAttack(BattleUnitStack to)
 {
     return(Utils.CalculateDamage(this, to));
 }
Esempio n. 7
0
 public void Await(BattleUnitStack stack)
 {
     Queue.Await(stack);
 }
Esempio n. 8
0
 public void Defense(BattleUnitStack stack)
 {
     stack.AddEffect(new Effects.DefenseBuff(stack));
 }
Esempio n. 9
0
 public Effect(BattleUnitStack stack)
 {
     Stack = stack;
 }
Esempio n. 10
0
 public PassiveRange(BattleUnitStack stack) : base(stack)
 {
 }
Esempio n. 11
0
 public PunishingStrikeBuff(BattleUnitStack stack) : base(stack)
 {
 }
Esempio n. 12
0
 public DefenseBuff(BattleUnitStack stack) : base(stack)
 {
 }
Esempio n. 13
0
 public void Apply(BattleUnitStack stack)
 {
     stack.AddEffect(new Effects.PunishingStrikeBuff(stack));
 }