예제 #1
0
파일: Game.cs 프로젝트: Amarinal/S3
        public void SetOptions(String optionString)
        {
            this.combatOptions = new CombatOptions();

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

            foreach (string option in options)
            {
                SetOption(option.ToLower());
            }
        }
예제 #2
0
파일: Combat.cs 프로젝트: Amarinal/S3
        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);
            }
        }
예제 #3
0
파일: Game.cs 프로젝트: Amarinal/S3
        public void SetOptions(String optionString)
        {
            this.combatOptions = new CombatOptions();

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

            foreach (string option in options)
            {
                SetOption(option.ToLower());
            }
        }
예제 #4
0
파일: Combat.cs 프로젝트: Amarinal/S3
        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;
        }
예제 #5
0
파일: Combat.cs 프로젝트: Amarinal/S3
        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); }
        }
예제 #6
0
파일: Combat.cs 프로젝트: Amarinal/S3
        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);
        }