Пример #1
0
        private static VisualElement CreateStepCurrencyElement(StepRowDetails details)
        {
            var currencyContainer = new VisualElement();

            currencyContainer.AddToClassList("plan-step-currency-container");

            currencyContainer.Add(CreateCurrencyDiffElement(details.SupplyDifference, details.ProductionDifference, details.PopulationDifference));

            var currencyRunningLabel = new VisualElement();

            currencyRunningLabel.AddToClassList("plan-step-currency");
            currencyRunningLabel.Add(CreateCurrencyLabel(details.InitialSupplies + details.SupplyDifference, "s"));
            currencyRunningLabel.Add(CreateCurrencyLabel(details.InitialProduction + details.ProductionDifference, "pd"));
            currencyRunningLabel.Add(CreateCurrencyLabel(details.InitialPopulation + details.PopulationDifference, "pp"));

            currencyContainer.Add(currencyRunningLabel);
            return(currencyContainer);
        }
Пример #2
0
        public void ShowGamePlan(VisualElement container)
        {
            var gamePlan = turnCalculator.GetCalculatedPlan();

            if (gamePlan == null || !gamePlan.Any())
            {
                return;
            }

            var turnIndication = new VisualElement();
            var stepContainer  = new VisualElement();
            var turnNumber     = 1;

            while (gamePlan.Any())
            {
                var node = gamePlan.Dequeue();
                ShowNextTurnSteps(node, turnNumber, stepContainer);

                var numTurnsSinceLastAction = node.PlayerData.TurnNumber - turnNumber;
                var suppliesAtStartOfTurn   = node.InitialSupplies + node.SuppliesPerTurn * numTurnsSinceLastAction;

                turnNumber = node.PlayerData.TurnNumber;

                var details = new StepRowDetails
                {
                    TurnNumber           = turnNumber,
                    Label                = node.Action,
                    InitialSupplies      = suppliesAtStartOfTurn,
                    InitialProduction    = node.InitialProduction,
                    InitialPopulation    = node.InitialPopulation,
                    SupplyDifference     = node.PlayerData.CurrencyData.Supplies - suppliesAtStartOfTurn,
                    ProductionDifference = node.PlayerData.CurrencyData.Production.Available - node.InitialProduction,
                    PopulationDifference = node.PlayerData.CurrencyData.Population.Available - node.InitialPopulation,
                };
                var step = CreateStepRow(details);
                stepContainer.Add(step);
            }

            turnIndication.Add(new Label($"Optimal turns ({turnNumber}):"));
            turnIndication.Add(stepContainer);
            container.Add(turnIndication);
        }
Пример #3
0
        private void ShowNextTurnSteps(TurnCalculatorNode node, int turnNumber, VisualElement container)
        {
            var numTurnsSinceLastAction = node.PlayerData.TurnNumber - turnNumber;

            for (int i = 0; i < numTurnsSinceLastAction; i++)
            {
                var details = new StepRowDetails
                {
                    TurnNumber           = turnNumber + i + 1,
                    Label                = "Next turn",
                    StyleClass           = "plan-step-nextturn",
                    InitialSupplies      = node.InitialSupplies + node.SuppliesPerTurn * i,
                    InitialProduction    = node.InitialProduction,
                    SupplyDifference     = node.SuppliesPerTurn,
                    ProductionDifference = 0,
                    PopulationDifference = 0,
                };
                var step = CreateStepRow(details);

                container.Add(step);
            }
        }
Пример #4
0
        private static VisualElement CreateStepRow(StepRowDetails details)
        {
            var step = new VisualElement();

            step.AddToClassList("plan-step");
            if (!string.IsNullOrEmpty(details.StyleClass))
            {
                step.AddToClassList("plan-step-nextturn");
            }

            var turnLabel = new Label(details.TurnNumber.ToString());

            turnLabel.AddToClassList("plan-step-turn");
            step.Add(turnLabel);

            var stepLabel = new Label(details.Label);

            stepLabel.AddToClassList("plan-step-action");
            step.Add(stepLabel);

            step.Add(CreateStepCurrencyElement(details));

            return(step);
        }