Example #1
0
        private static void CompareAndPushResult(SkillState skill, Func <int, int, bool> comparator)
        {
            int b = skill.PopBack();
            int a = skill.PopBack();

            skill.Push(Convert.ToInt32(comparator(a, b)));
        }
Example #2
0
        private static void Calculate(SkillState skill, Func <int, int, int> calculator)
        {
            int b      = skill.PopBack();
            int a      = skill.PopBack();
            int result = calculator(a, b);

            skill.Push(result);
        }
Example #3
0
        private static void If(SkillState skill)
        {
            int jump      = skill.PopBack();
            int condition = skill.PopBack();

            // We jump on the else, not the positive
            if (condition == 0)
            {
                skill.Jump(jump);
            }
        }
Example #4
0
        private static void SetHealth(SkillState skill)
        {
            Player player    = GetPlayer(skill);
            int    newHealth = skill.PopBack();

            player.Health = newHealth;
        }
Example #5
0
        private static Player GetPlayer(SkillState skill)
        {
            int id = skill.PopBack();

            return(id switch
            {
                Player => skill.Controller,
                Opponent => skill.Opponent,
                Owner => skill.Owner,
                _ => throw new ArgumentOutOfRangeException()
            });
Example #6
0
        private static void Draw(SkillState skill)
        {
            Player player = GetPlayer(skill);
            int    count  = skill.PopBack();

            for (int i = 0; i < count; i++)
            {
                Card card = player.Deck[player.Deck.Count - 1];
                player.Deck.Remove(card);
                player.Hand.Add(card);
                skill.AddEvent(new Draw(card));
            }
        }
Example #7
0
 private static void Or(SkillState skill)
 {
     skill.Push(Convert.ToInt32(skill.PopBack() == 1 || skill.PopBack() == 1));
 }
Example #8
0
 private static void And(SkillState skill)
 {
     skill.Push(Convert.ToInt32(skill.PopBack() == 1 && skill.PopBack() == 1));
 }