Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private static void DrawAndReport(string style, Func <int, DrawResult> drawStyle)
        {
            var res = new DrawResult[DRAWS];

            Console.Write(style);

            for (int i = 0; i < DRAWS; i++)
            {
                res[i] = drawStyle(ATK);
            }
            var tmp = res.Select(r => (double)r.Value).ToList();

            var stats = res.Where(r => r.Status.Any()).SelectMany(r => r.Status).Distinct().OrderBy(s => s);

            Console.WriteLine($"Average: {tmp.Mean():F2}, StdDev: {tmp.StandardDeviation():F2} - " +
                              string.Join(", ", stats.Select(stat => $"{stat} - {res.Count(r => r.Status.Contains(stat)) * 100.0 / DRAWS:F2} % ")));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }