Exemple #1
0
        public DrawResult Draw(int atk)
        {
            var drawn = new List <Card>();

            do
            {
                drawn.Add(Cards[_CurrentIndex++]);
            } while (drawn.Last().IsRolling);

            var result = new DrawResult {
                Value = atk
            };

            //rolling
            var rolling = drawn.Where(c => c.IsRolling).ToArray();

            if (rolling.Length + 1 != drawn.Count)
            {
                throw new Exception($"rolling.Count() + 1 = {rolling.Length} drawn.Count = {drawn.Count}!"); //shouldn't happen unless I screwed up
            }
            foreach (var card in rolling)
            {
                result.ApplyCard(card);
            }

            result.ApplyCard(drawn.First(c => !c.IsRolling)); //should be exactly one.

            //we'll never actually get to the end since we have both *0 & *2
            if (drawn.Any(c => c.IsShuffle))
            {
                Shuffle(); //strictly, we wouldn't do this til the round end, but how often to I hit multiple targets anyway.
            }
            return(result);
        }
Exemple #2
0
        public DrawResult Disadvantage(int atk)
        {
            var card1  = Cards[_CurrentIndex++];
            var card2  = Cards[_CurrentIndex++];
            var result = new DrawResult {
                Value = atk
            };
            var sawMultiply = card1.IsMultiply || card2.IsMultiply;

            if (!card1.IsRolling && !card2.IsRolling)
            {
                result.ApplyCard(card1.IsBetterThan(card2) ? card2 : card1);
            }
            else if (card1.IsRolling && !card2.IsRolling)
            {
                result.ApplyCard(card2);
            }
            else if (!card1.IsRolling && card2.IsRolling)
            {
                result.ApplyCard(card1);
            }
            else //2 rollings
            {
                do
                {
                    card1       = Cards[_CurrentIndex++];
                    sawMultiply = sawMultiply || card1.IsMultiply;
                } while (card1.IsRolling);
                result.ApplyCard(card1);
            }

            if (sawMultiply)
            {
                Shuffle();
            }

            return(result);
        }
Exemple #3
0
        public DrawResult Advantage(int atk)
        {
            var card1  = Cards[_CurrentIndex++];
            var card2  = Cards[_CurrentIndex++];
            var result = new DrawResult {
                Value = atk
            };

            if (!card1.IsRolling && !card2.IsRolling)
            {
                result.ApplyCard(card1.IsBetterThan(card2) ? card1 : card2);
            }
            else if (card1.IsRolling && !card2.IsRolling)
            {
                result.ApplyCard(card1);
                result.ApplyCard(card2);
            }
            else if (!card1.IsRolling && card2.IsRolling)
            {
                result.ApplyCard(card2);
                result.ApplyCard(card1);
            }
            else //2 rollings
            {
                result = Draw(atk); //takes into account further rolling
                result.ApplyCard(card1);
                result.ApplyCard(card2);
            }

            if (card1.IsShuffle || card2.IsShuffle)
            {
                Shuffle();
            }

            return(result);
        }