protected override void ExecuteInternal(ParameterSet parameters)
        {
            var sheetName   = parameters.Get(Sheet);
            var expr        = parameters.Get(Expression);
            var balanceData = BalanceLibrary.GetBalanceData(sheetName);

            var evaluator = new BalanceStringEvaluator(balanceData);
            var result    = evaluator.Evaluate(expr);

            Console.WriteLine(result);
        }
        protected override void ExecuteInternal(ParameterSet parameters)
        {
            var sheet       = parameters.Get(Sheet);
            var balanceData = BalanceLibrary.GetBalanceData(sheet);

            List <Tuple <int, int> > crops = new List <Tuple <int, int> >()
            {
                new Tuple <int, int>(2, 2),
                new Tuple <int, int>(3, 3),
                new Tuple <int, int>(5, 4),
                new Tuple <int, int>(7, 5),
            };

            foreach (Tuple <int, int> crop in crops)
            {
                int cropHand = crop.Item1;
                int cropDew  = crop.Item2;

                Console.WriteLine();
                Console.WriteLine($"Sim with cropHand={cropHand} cropDew={cropDew} cropNet={FormatDouble(balanceData.Data[$"cropnet{cropHand}_{cropDew}"])}");

                var sum   = 0;
                var turns = new double[] { 5, 5, 5, 4, 4, 4, 3, 3, 3 };

                for (int i = 0; i < turns.Length; i++)
                {
                    var income = turns[i];
                    sum += (int)income;

                    if (i != turns.Length - 1)
                    {
                        var net = balanceData.Data[$"cropnet{cropHand}_{cropDew}"];
                        net *= income / cropHand;
                        Console.WriteLine($"Turn {i}: {FormatDouble(income)} nets {FormatDouble(net)}");

                        if (i + cropDew < turns.Length)
                        {
                            turns[i + cropDew] += net;
                        }
                        else
                        {
                            turns[turns.Length - 1] += net;
                        }
                    }
                    else
                    {
                        Console.WriteLine($"Turn {i}: {FormatDouble(income)} (no net on last turn)");
                    }
                }

                Console.WriteLine($"Sum: {FormatDouble(sum)}");
            }
        }
Exemple #3
0
        protected override void ExecuteInternal(ParameterSet parameters)
        {
            var sheetName             = parameters.Get(Sheet);
            var balanceData           = BalanceLibrary.GetBalanceData(sheetName);
            CardDataSpreadsheet sheet = this.Context.SpreadsheetManager.Load(sheetName);

            var evaluator = new BalanceStringEvaluator(balanceData);
            List <BalancedCard> balanced = new List <BalancedCard>();

            List <Tuple <double, string> > spells = new List <Tuple <double, string> >();
            List <Tuple <double, string> > crops  = new List <Tuple <double, string> >();

            foreach (var card in sheet.Cards)
            {
                if (card.Id.Contains("blank"))
                {
                    continue;
                }

                if (card.Type == "spell")
                {
                    var    spellCard = (SpellCardData)card;
                    double budget    = balanceData.Data[$"spellbudget{spellCard.PlantValue}"];
                    double effectest = evaluator.Evaluate(spellCard.EffectPowerEstimate);
                    double vp        = spellCard.Offerings;

                    double opness = budget - effectest - vp;
                    Tuple <double, string> output = new Tuple <double, string>(
                        opness,
                        $"{spellCard.Title}: budget={FormatDouble(budget)} est={FormatDouble(effectest)} vp={vp} sum={FormatDouble(effectest + vp)} delta={FormatDouble(opness)}");

                    spells.Add(output);
                }
                else if (card.Type == "crop")
                {
                    var cropCard = (CropCardData)card;

                    double budget = balanceData.Data[$"cropbudget{cropCard.PlantCost}_{cropCard.HarvestCost}"];
                    double effectsingleturnest = evaluator.Evaluate(cropCard.EffectPowerEstimate);
                    double effectest           = balanceData.CostCropEffect(cropCard.PlantCost, cropCard.HarvestCost, cropCard.EffectCost, effectsingleturnest);
                    double harvestest          = evaluator.Evaluate(cropCard.HarvestPowerEstimate);
                    double vp = cropCard.Offerings;

                    double totalpower             = effectest + harvestest + vp;
                    double opness                 = budget - totalpower;
                    Tuple <double, string> output = new Tuple <double, string>(
                        opness,
                        $"{cropCard.Title}: budget={FormatDouble(budget)} harvestest={FormatDouble(harvestest)} effectest={FormatDouble(effectest)} vp={vp} sum={FormatDouble(totalpower)} delta={FormatDouble(opness)}");

                    crops.Add(output);
                }
            }

            Console.WriteLine("Spells");
            foreach (var s in spells.OrderBy(x => x.Item1).Select(x => x.Item2))
            {
                Console.WriteLine(s);
            }

            Console.WriteLine();
            Console.WriteLine("Crops");
            foreach (var s in crops.OrderBy(x => x.Item1).Select(x => x.Item2))
            {
                Console.WriteLine(s);
            }
        }