コード例 #1
0
ファイル: Program.cs プロジェクト: thailyn/BrigadeRoulette
        public static double CalculateBrigadeFormationWinPercent(List <FamiliarWinPercent> familiarWinPercents,
                                                                 BrigadeFormation formation, bool includeReserve = true)
        {
            double formationWinPercent = 0;
            double totalWinPercent     = 0;

            int numFormationPositions = formation.Positions.Count;
            int currentFamiliarIndex  = 0;

            foreach (var position in formation.Positions)
            {
                totalWinPercent += familiarWinPercents[currentFamiliarIndex].WinPercents[position.VerticalPositionTypes];
                currentFamiliarIndex++;
            }
            if (includeReserve)
            {
                foreach (var position in formation.Positions)
                {
                    totalWinPercent += familiarWinPercents[currentFamiliarIndex].WinPercents[position.VerticalPositionTypes];
                    currentFamiliarIndex++;
                }
            }
            System.Console.WriteLine("Total win percent{0}: {1}", (includeReserve ? " (with reserve)" : string.Empty),
                                     totalWinPercent);

            formationWinPercent = totalWinPercent / (includeReserve ? numFormationPositions * 2 : numFormationPositions);
            return(formationWinPercent);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: thailyn/BrigadeRoulette
        public static string GetBrigadeFormationString(PhlebotomistRepository phlebotomistRepository,
                                                       BrigadeFormation formation)
        {
            StringBuilder output = new StringBuilder();
            var           rows   = phlebotomistRepository.Context.BrigadeFormationVerticalPositionTypes.OrderByDescending(x =>
                                                                                                                          x.DamageDealtModifier);

            output.AppendLine(string.Format("Brigade Formation: {0}", formation.Name));
            foreach (var row in rows)
            {
                // using the assumption that HorizontalPositionTypeId increases from left to right
                foreach (var horizontalPosition in formation.Positions.OrderBy(x => x.HorizontalPositionTypeId))
                {
                    if (horizontalPosition.VerticalPositionTypes.Id == row.Id)
                    {
                        output.Append("*");
                    }
                    else
                    {
                        output.Append(" ");
                    }
                }
                output.AppendLine();
            }

            return(output.ToString());
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: thailyn/BrigadeRoulette
        static IEnumerable <BrigadeFormationWithFamiliars> GetBrigadeFormationPermutations(
            PhlebotomistRepository phlebotomistRepository, List <FamiliarWinPercent> familiarWinPercents,
            BrigadeFormation formation, bool includeReserve)
        {
            if (formation == null)
            {
                throw new ArgumentNullException("formation", "The BrigadeFormation argument can not be null!");
            }

            var currentBrigadeInstace = new BrigadeFormationWithFamiliars(phlebotomistRepository,
                                                                          includeReserve);

            currentBrigadeInstace.Formation = formation;
            foreach (var brigadeFormation in GetBrigadeFormationPermutations(phlebotomistRepository,
                                                                             familiarWinPercents, currentBrigadeInstace, includeReserve))
            {
                yield return(brigadeFormation);
            }
        }