internal CapCalc GetNGUMagicCapCalc(int id, bool useInput, int offset)
        {
            var ret = new CapCalc
            {
                Num = 0,
                PPT = 1
            };
            var num1 = 0.0f;

            if (_character.settings.nguLevelTrack == difficulty.normal)
            {
                num1 = _character.NGU.magicSkills[id].level + 1L + offset;
            }
            else if (_character.settings.nguLevelTrack == difficulty.evil)
            {
                num1 = _character.NGU.magicSkills[id].evilLevel + 1L + offset;
            }
            else if (_character.settings.nguLevelTrack == difficulty.sadistic)
            {
                num1 = _character.NGU.magicSkills[id].sadisticLevel + 1L + offset;
            }

            var num2 = _character.totalMagicPower() * (double)_character.totalNGUSpeedBonus() * _character.adventureController.itopod.totalMagicNGUBonus() * _character.inventory.macguffinBonuses[5] * _character.NGUController.magicNGUBonus() * _character.allDiggers.totalMagicNGUBonus() * _character.hacksController.totalMagicNGUBonus() * _character.beastQuestPerkController.totalMagicNGUSpeed() * _character.wishesController.totalMagicNGUSpeed() * _character.cardsController.getBonus(cardBonus.magicNGUSpeed);

            if (_character.allChallenges.trollChallenge.completions() >= 1)
            {
                num2 *= 3.0;
            }
            if (_character.settings.nguLevelTrack >= difficulty.sadistic)
            {
                num2 /= _character.NGUController.NGUMagic[0].sadisticDivider();
            }
            var num3 = _character.NGUController.magicSpeedDivider(id) * (double)num1 / num2;

            if (num3 >= _character.hardCap())
            {
                num3 = _character.hardCap();
            }
            var num4 = num3 <= 1.0 ? 1L : (long)num3;
            var num  = (long)(num4 / (long)Math.Ceiling(num4 / (useInput ? (double)_character.energyMagicPanel.energyMagicInput : (double)_character.magic.idleMagic)) * 1.00000202655792);

            if (num + 1L <= long.MaxValue)
            {
                ++num;
            }
            if (num > _character.magic.idleMagic)
            {
                num = _character.magic.idleMagic;
            }
            if (num < 0L)
            {
                num = 0L;
            }

            var ppt = (double)num / num4;

            ret.Num = num;
            ret.PPT = ppt;
            return(ret);
        }
        private CapCalc CalculateATCap(int index, bool useInput, int offset)
        {
            var ret = new CapCalc
            {
                Num = 0,
                PPT = 1
            };
            var divisor = GetDivisor(index, offset);

            if (divisor == 0.0)
            {
                return(ret);
            }

            if (_character.wishes.wishes[190].level >= 1)
            {
                return(ret);
            }

            var formula = 50f * divisor /
                          (Mathf.Sqrt(_character.totalEnergyPower()) * _character.totalAdvancedTrainingSpeedBonus());

            if (formula >= _character.hardCap())
            {
                formula = _character.hardCap();
            }

            var num = (long)(formula / (long)Math.Ceiling(formula / (useInput ? (double)_character.energyMagicPanel.energyMagicInput : (double)_character.idleEnergy)) * 1.00000202655792);

            if (num + 1L <= long.MaxValue)
            {
                ++num;
            }
            if (num > _character.idleEnergy)
            {
                num = _character.idleEnergy;
            }
            if (num < 0L)
            {
                num = 0L;
            }

            ret.Num = num;
            ret.PPT = (double)num / formula;
            return(ret);
        }
        internal CapCalc CalculateTMMagicCapCalc(bool useInput, int offset)
        {
            var ret = new CapCalc
            {
                Num = 0,
                PPT = 1
            };
            var formula = 50000 * _character.timeMachineController.baseGoldMultiDivider() *
                          (1f + _character.machine.levelGoldMulti + offset) / (
                _character.totalMagicPower() * _character.hacksController.totalTMSpeedBonus() *
                _character.allChallenges.timeMachineChallenge.TMSpeedBonus() *
                _character.cardsController.getBonus(cardBonus.TMSpeed));

            if (_character.settings.rebirthDifficulty >= difficulty.sadistic)
            {
                formula *= _character.timeMachineController.sadisticDivider();
            }

            if (formula >= _character.hardCap())
            {
                formula = _character.hardCap();
            }


            var num4 = formula <= 1.0 ? 1L : (long)formula;
            var num  = (long)(num4 / (long)Math.Ceiling(num4 / (useInput ? (double)_character.energyMagicPanel.energyMagicInput : (double)_character.magic.idleMagic)) * 1.00000202655792);

            if (num + 1L <= long.MaxValue)
            {
                ++num;
            }
            if (num > _character.magic.idleMagic)
            {
                num = _character.magic.idleMagic;
            }
            if (num < 0L)
            {
                num = 0L;
            }
            ret.Num = num;
            ret.PPT = (double)num / num4;
            return(ret);
        }
        internal CapCalc CalculateAugCapCalc(int index, bool useInput, int offset)
        {
            var ret = new CapCalc
            {
                Num = 0,
                PPT = 1
            };
            var    augIndex = (int)Math.Floor((double)(index / 2));
            double formula  = 0;

            if (index % 2 == 0)
            {
                formula = 50000 * (1f + _character.augments.augs[augIndex].augLevel + offset) /
                          (_character.totalEnergyPower() *
                           (1 + _character.inventoryController.bonuses[specType.Augs]) *
                           _character.inventory.macguffinBonuses[12] *
                           _character.hacksController.totalAugSpeedBonus() *
                           _character.cardsController.getBonus(cardBonus.augSpeed) *
                           _character.adventureController.itopod.totalAugSpeedBonus() *
                           (1.0 + _character.allChallenges.noAugsChallenge.evilCompletions() * 0.0500000007450581));

                if (_character.allChallenges.noAugsChallenge.completions() >= 1)
                {
                    formula /= 1.10000002384186;
                }
                if (_character.allChallenges.noAugsChallenge.evilCompletions() >= _character.allChallenges.noAugsChallenge.maxCompletions)
                {
                    formula /= 1.25;
                }
                if (_character.settings.rebirthDifficulty >= difficulty.sadistic)
                {
                    formula *= _character.augmentsController.augments[augIndex].sadisticDivider();
                }
                if (_character.settings.rebirthDifficulty == difficulty.normal)
                {
                    formula *= _character.augmentsController.normalAugSpeedDividers[augIndex];
                }
                else if (_character.settings.rebirthDifficulty == difficulty.evil)
                {
                    formula *= _character.augmentsController.evilAugSpeedDividers[augIndex];
                }
                else if (_character.settings.rebirthDifficulty == difficulty.sadistic)
                {
                    formula *= _character.augmentsController.sadisticAugSpeedDividers[augIndex];
                }
            }
            else
            {
                formula = 50000 * (1f + _character.augments.augs[augIndex].upgradeLevel + offset) /
                          (_character.totalEnergyPower() *
                           (1 + _character.inventoryController.bonuses[specType.Augs]) *
                           _character.inventory.macguffinBonuses[12] *
                           _character.hacksController.totalAugSpeedBonus() *
                           _character.cardsController.getBonus(cardBonus.augSpeed) *
                           _character.adventureController.itopod.totalAugSpeedBonus() *
                           (1.0 + _character.allChallenges.noAugsChallenge.evilCompletions() * 0.0500000007450581));

                if (_character.allChallenges.noAugsChallenge.completions() >= 1)
                {
                    formula /= 1.10000002384186;
                }
                if (_character.allChallenges.noAugsChallenge.evilCompletions() >= _character.allChallenges.noAugsChallenge.maxCompletions)
                {
                    formula /= 1.25;
                }
                if (_character.settings.rebirthDifficulty >= difficulty.sadistic)
                {
                    formula *= _character.augmentsController.augments[augIndex].sadisticDivider();
                }
                if (_character.settings.rebirthDifficulty == difficulty.normal)
                {
                    formula *= _character.augmentsController.normalUpgradeSpeedDividers[augIndex];
                }
                else if (_character.settings.rebirthDifficulty == difficulty.evil)
                {
                    formula *= _character.augmentsController.evilUpgradeSpeedDividers[augIndex];
                }
                else if (_character.settings.rebirthDifficulty == difficulty.sadistic)
                {
                    formula *= _character.augmentsController.sadisticUpgradeSpeedDividers[augIndex];
                }
            }

            if (formula >= _character.hardCap())
            {
                formula = _character.hardCap();
            }

            var num4 = formula <= 1.0 ? 1L : (long)formula;
            var num  = (long)(num4 / (long)Math.Ceiling(num4 / (useInput ? (double)_character.energyMagicPanel.energyMagicInput : (double)_character.idleEnergy)) * 1.00000202655792);

            if (num + 1L <= long.MaxValue)
            {
                ++num;
            }
            if (num > _character.idleEnergy)
            {
                num = _character.idleEnergy;
            }
            if (num < 0L)
            {
                num = 0L;
            }
            var ppt = (double)num / num4;

            ret.Num = num;
            ret.PPT = ppt;
            return(ret);
        }