Example #1
0
File: Game.cs Project: Amarinal/S3
        public void SetOptions(String optionString)
        {
            this.combatOptions = new CombatOptions();

            string[] options = optionString.Split(',');

            foreach (string option in options)
            {
                SetOption(option.ToLower());
            }
        }
Example #2
0
        public void InitCombat(CombatOptions options = null)
        {
            if (options == null)
            {
                options = new CombatOptions();
            }
            combatOptions = options;

            Attacker.Init();
            Defender.Init();

            foreach (Card card in combatOptions.DefenderCards)
            {
                Defender.Hand.Add(card);
            }
            foreach (Card card in combatOptions.AttackerCards)
            {
                Attacker.Hand.Add(card);
            }
        }
Example #3
0
File: Game.cs Project: Amarinal/S3
        public void SetOptions(String optionString)
        {
            this.combatOptions = new CombatOptions();

            string[] options = optionString.Split(',');

            foreach (string option in options)
            {
                SetOption(option.ToLower());
            }
        }
Example #4
0
        public Result Resolve(CombatOptions options=null, int? repeat = null)
        {
            Result result = new Result();
            result.Attacker = Attacker;
            result.Defender = Defender;

            bool isAttackerTurn = true;

            if (repeat == null) repeat = Repeat;

            if (options == null) options = new CombatOptions();
            this.combatOptions = options;

            for (int i = 0; i < repeat; i++)
            {
                turn = 0;
                Attacker.Init();
                Defender.Init();

                foreach (Card card in combatOptions.DefenderCards)
                {
                    Defender.Hand.Add(card.Clone());
                }

                foreach (Card card in combatOptions.AttackerCards)
                {
                    Attacker.Hand.Add(card);
                }

                while (Attacker.IsAlive && Defender.IsAlive)
                {
                    turn++;
                    isAttackerTurn = (turn % 2) == 1;

                    try
                    {
                        if (isAttackerTurn)
                        {
                            DoTurn(Attacker, Defender);
                        }
                        else
                        {
                            DoTurn(Defender, Attacker);
                        }
                    }
                    catch (DeadPlayerExeption dpex)
                    {
                        result.RecordLoss(dpex.DeadPlayer.Id);
                        break;
                    }

                    if (turn > MAX_TURNS)
                    {
                        result.RecordLoss(Attacker.Id);
                        break;
                    }

                }

            }

            return result;
        }
Example #5
0
        public void InitCombat(CombatOptions options = null)
        {
            if (options == null) options = new CombatOptions();
            combatOptions = options;

            Attacker.Init();
            Defender.Init();

            foreach(Card card in combatOptions.DefenderCards) { Defender.Hand.Add(card); }
            foreach (Card card in combatOptions.AttackerCards) { Attacker.Hand.Add(card); }
        }
Example #6
0
        public Result Resolve(CombatOptions options = null, int?repeat = null)
        {
            Result result = new Result();

            result.Attacker = Attacker;
            result.Defender = Defender;

            bool isAttackerTurn = true;

            if (repeat == null)
            {
                repeat = Repeat;
            }

            if (options == null)
            {
                options = new CombatOptions();
            }
            this.combatOptions = options;

            for (int i = 0; i < repeat; i++)
            {
                turn = 0;
                Attacker.Init();
                Defender.Init();

                foreach (Card card in combatOptions.DefenderCards)
                {
                    Defender.Hand.Add(card.Clone());
                }

                foreach (Card card in combatOptions.AttackerCards)
                {
                    Attacker.Hand.Add(card);
                }

                while (Attacker.IsAlive && Defender.IsAlive)
                {
                    turn++;
                    isAttackerTurn = (turn % 2) == 1;

                    try
                    {
                        if (isAttackerTurn)
                        {
                            DoTurn(Attacker, Defender);
                        }
                        else
                        {
                            DoTurn(Defender, Attacker);
                        }
                    }
                    catch (DeadPlayerExeption dpex)
                    {
                        result.RecordLoss(dpex.DeadPlayer.Id);
                        break;
                    }

                    if (turn > MAX_TURNS)
                    {
                        result.RecordLoss(Attacker.Id);
                        break;
                    }
                }
            }

            return(result);
        }