Пример #1
0
        private static LeaderPipResult DistributePips(double averageBasePips, LeaderPipModifiers leaderPipModifiers)
        {
            double remainingPips = averageBasePips;
            var    result        = new LeaderPipResult();

            while (remainingPips > 10)
            {
                remainingPips -= 4;
                result.Fire++;
                result.Shock++;
                result.Maneuver++;
                result.Siege++;
            }

            result.AddGuaranteedPips(leaderPipModifiers ?? new LeaderPipModifiers());

            // The approximation here is that these percentages don't reflect pip overflow from maxed out categories
            result.Fire     += Math.Round(0.3 * remainingPips, 2);
            result.Shock    += Math.Round(0.3 * remainingPips, 2);
            result.Maneuver += Math.Round(0.3 * remainingPips, 2);
            result.Siege    += Math.Round(0.1 * remainingPips, 2);

            result.Fire     = result.Fire > LeaderConstants.MaxPipsInCategory ? LeaderConstants.MaxPipsInCategory : result.Fire;
            result.Shock    = result.Shock > LeaderConstants.MaxPipsInCategory ? LeaderConstants.MaxPipsInCategory : result.Shock;
            result.Maneuver = result.Maneuver > LeaderConstants.MaxPipsInCategory ? LeaderConstants.MaxPipsInCategory : result.Maneuver;
            result.Siege    = result.Siege > LeaderConstants.MaxPipsInCategory ? LeaderConstants.MaxPipsInCategory : result.Siege;
            return(result);
        }
Пример #2
0
        private static LeaderPipResult DistributePipsSimulation(double averageBasePips, LeaderPipModifiers leaderPipModifiers, Random random)
        {
            double remainingPips = averageBasePips;
            var    result        = new LeaderPipResult();

            while (remainingPips > 10)
            {
                remainingPips -= 4;
                result.Fire++;
                result.Shock++;
                result.Maneuver++;
                result.Siege++;
            }

            result.AddGuaranteedPips(leaderPipModifiers ?? new LeaderPipModifiers());

            while (remainingPips > 0)
            {
                int    which  = random.Next(0, 10);
                double amount = remainingPips >= 1 ? 1 : remainingPips;

                if (which == 0 && result.Siege < LeaderConstants.MaxPipsInCategory)
                {
                    result.Siege  += amount;
                    remainingPips -= amount;
                }
                else if (which < 4 && result.Shock < LeaderConstants.MaxPipsInCategory)
                {
                    result.Shock  += amount;
                    remainingPips -= amount;
                }
                else if (which < 7 && result.Fire < LeaderConstants.MaxPipsInCategory)
                {
                    result.Fire   += amount;
                    remainingPips -= amount;
                }
                else if (result.Maneuver < LeaderConstants.MaxPipsInCategory)
                {
                    result.Maneuver += amount;
                    remainingPips   -= amount;
                }
                // else go back to generating new which
            }

            return(result);
        }