Exemplo n.º 1
0
 public StateMachine(string s, uint m, UpgradeID t, Feedback fee)
 {
     prompt = s;
     max    = m;
     type   = t;
     f      = fee;
 }
Exemplo n.º 2
0
 static IList <Upgrade> ic(UpgradeID i)
 {
     if (i.HasFlag(UpgradeID.ICFLAG))
     {
         return(icUpgrades[(int)i & 127]);
     }
     else if (i.HasFlag(UpgradeID.BSFLAG))
     {
         return(bsUpgrades[(int)i & 127]);
     }
     return(null);
 }
 public int this[UpgradeID i]
 {
     get
     {
         if (i.HasFlag(UpgradeID.BSFLAG))
         {
             return(blacksmith[(int)i & 127]);
         }
         if (i.HasFlag(UpgradeID.ICFLAG))
         {
             return(instant[(int)i & 127]);
         }
         throw new ArgumentException("i");
     }
     set { setter(i, value); }
 }
 /// <summary>
 /// Called by the public setters
 /// </summary>
 /// <param name="which">which blacksmith UpgradeID to set</param>
 /// <param name="value">how many of it</param>
 private void setter(UpgradeID which, int value)
 {
     if (which.HasFlag(UpgradeID.BSFLAG))
     {
         if (value > bsMaxes[(int)which & 127] && value != -1)
         {
             throw new ArgumentOutOfRangeException(String.Format("Value {0} is larger than max {1} for {2}", value, which, bsMaxes[(int)which & 127]));
         }
         blacksmith[(int)which & 127] = value;
     }
     else if (which.HasFlag(UpgradeID.ICFLAG))
     {
         if (value > icMaxes[(int)which & 127] && value != -1)
         {
             throw new ArgumentOutOfRangeException(String.Format("Value {0} is larger than max {1} for {2}", value, which, icMaxes[(int)which & 127]));
         }
         blacksmith[(int)which & 127] = value;
     }
 }
Exemplo n.º 5
0
 public ResponseDetail ActivateIdWithPackage(UpgradeID objModel)
 {
     return(objTransacAPI.ActivateIdWithPackage(objModel));
 }
Exemplo n.º 6
0
        internal void Simulate(WealthStatistics initialStats,
            UpgradeState upgradesWithoutGemfinder,
            UpgradeState upgradesWithGemfinder,
            WealthStatistics wealthWithoutGemfinder,
            IList<WealthStatistics> wealthWithGemfinderBoughtAfterIthUpgrade)
        {
            var retval = new UpgradeSimulationResult[UpgradeOrder.Count + 1];
            List<WealthStatistics> currentStatistics = { new WealthStatistics(initialStats) };
            UpgradeState usWithoutGemfinder = new UpgradeState(us);
            UpgradeState usWithGemfinder;
            bool gfMaxed = usWithoutGemfinder.gfLevel == Upgrade.ic(UpgradeID.ICGEMFINDER).Count - 1;
            int itemsBoughtSoFar = 0;
            double secondsPerClick = 1/Upgrade.ic(UpgradeID.ICAUTOSPEED)[usWithoutGemfinder.afLevel].value;
            double gemsForEachVictoryBefore = Upgrade.ic(UpgradeID.ICGEMFINDER)[usWithoutGemfinder.gfLevel].value;
            double gemsForEachVictoryAfter = gfMaxed ? 0 : Upgrade.ic(UpgradeID.ICGEMFINDER)[usWithoutGemfinder.gfLevel + 1].value;
            int ore = -1;
            uint clicksForEachVictory=0;
            double timeForEachVictory = 0;
            double valueOfEachVictory=0;
            while (itemsBoughtSoFar < UpgradeOrder.Count)
            {
                UpgradeID pendingItem = _upgradeOrder[itemsBoughtSoFar];
                int upgradeLevelOfPendingItem = usWithoutGemfinder.instant[(int)pendingItem&127];

                Upgrade nextUpgrade = Upgrade.ic(pendingItem)[upgradeLevelOfPendingItem];
                double nextLevelCost = nextUpgrade.nextLevelCost;
                foreach (
                while (currentStatistics.Any(x=>x.Gold < nextLevelCost))
                {
                    if (ore == -1)
                    {
                        RecomputeOre(x, usWithoutGemfinder, secondsPerClick, out clicksForEachVictory, out valueOfEachVictory, out ore, out timeForEachVictory);
                    } 
                    currentStatistics.ForEach(x=>
                    {
                        x.Gold += valueOfEachVictory;
                        x.Gems += something ? gemsForEachVictoryBefore : gemsForEachVictoryAfter;
                        x.dataXp += clicksForEachVictory;
                        x.dataAge.Add(timeForEachVictory);
                    timeSpent += timeForEachVictory;
                    if (currentStatistics.dataXp > currentStatistics.dataXpThreshold || currentStatistics.dataAge.Sum() > currentStatistics.dataAgeThreshold)
                    {
                        currentStatistics.setThresholds();
                        ore = -1; // or recompute now
                    }
                    if (ore == currentStatistics.HighestOre)
                    {
                        currentStatistics.HighestOre++;
                        ore = -1; // or recompute now
                    }
                    if (ore == -1 && currentStatistics.Gold < nextLevelCost)
                    {
                        RecomputeOre(currentStatistics, usWithoutGemfinder, secondsPerClick, out clicksForEachVictory, out valueOfEachVictory, out ore, out timeForEachVictory);
                    }
                }

                // TODO: Handle this with a dictionary or list of delegates
                switch (pendingItem)
                {
                    case UpgradeID.ICAUTOSPEED:
                        usWithoutGemfinder.afLevel++;
                        secondsPerClick = Upgrade.ic(UpgradeID.ICAUTOSPEED)[usWithoutGemfinder.afLevel].value;
                        timeForEachVictory = clicksForEachVictory * secondsPerClick;
                        break;
                    case UpgradeID.ICAUTOPOWER:
                        usWithoutGemfinder.apLevel++;
                        ore = Ore.ComputeMostLucrativeOre(usWithoutGemfinder.instant, currentStatistics, out clicksForEachVictory, out valueOfEachVictory);
                        timeForEachVictory = clicksForEachVictory * secondsPerClick;
                        break;
                    case UpgradeID.ICGEMFINDER:
                        usWithoutGemfinder.gfLevel++;
                        gemsForEachVictoryBefore = Upgrade.ic(UpgradeID.ICGEMFINDER)[usWithoutGemfinder.gfLevel].value;
                        break;
                }
                currentStatistics.Gold -= nextLevelCost;
                timeSpent += 1.0; // it takes some time to click
                itemsBoughtSoFar++;
            }
            foreach (UpgradeSimulationResult thing in retval)
            {
                thing.u = usWithGemfinder;
            }
            retval[retval.Length()-1].u = usWithoutGemfinder;
            retval[retval.Length()-1].w = currentStatistics;
            return Tuple.Create(currentStatistics,usWithoutGemfinder);
        }