public bool CanPick(ConstructableInfo data)
        {
            var vars = this.Processor.LocalEffects(this.Game.Statics).
                       UnionWith(this.Game.Derivates[this.Player].TechLevels).Get;

            return(data.Project.Condition.Evaluate(vars) >= 0 &&
                   this.Processor.SpendingPlan.All(x => !x.Project.Equals(data.Project)));
        }
        //TODO(later) make only available in stellaris controller
        public virtual void Enqueue(ConstructableInfo data)
        {
            if (IsReadOnly || !this.CanPick(data))
            {
                return;
            }

            this.Game.Orders[this.Player].ConstructionPlans[Site].Queue.Add(data.Project);
            this.recalculateSpending();
        }
        //TODO(later) make only available in stellaris controller
        public virtual void Enqueue(ConstructableInfo data)
        {
            if (IsReadOnly)
            {
                return;
            }

            //TODO(v0.8) check if it can be picked
            this.Game.Orders[this.Player].ConstructionPlans[Site].Queue.Add(data.Project);
            this.recalculateSpending();
        }
        public static string ConstructionEstimation(ConstructableInfo construction, IText neverText, IText perTurnText, IText etaText)
        {
            var textVars = new TextVar();

            if (construction.CompletedCount >= 1)
            {
                var overflow = construction.Overflow / construction.Cost;

                if (construction.CompletedCount < 10)
                {
                    //TODO(v0.9) overflow gives too big estimation
                    textVars.And("count", new DecimalsFormatter(0, 1).Format(construction.CompletedCount + overflow, RoundingMethod.Floor, 1));
                }
                else
                {
                    textVars.And("count", new ThousandsFormatter().Format(construction.CompletedCount));
                }

                return(perTurnText.Text(null, textVars.Get));
            }

            if (construction.Investment <= 0 || (construction.Investment / construction.Cost) < MinimumPerTurnDone)
            {
                return(neverText.Text());
            }

            var eta     = (construction.Cost - construction.FromStockpile) / construction.Investment;
            var numVars = new Var("eta", eta).Get;

            if (eta < 10)
            {
                textVars.And("eta", new DecimalsFormatter(0, 1).Format(eta, RoundingMethod.Ceil, 1));
            }
            else
            {
                textVars.And("eta", new ThousandsFormatter().Format(Math.Ceiling(eta)));
            }

            return(etaText.Text(numVars, textVars.Get));
        }
Exemplo n.º 5
0
        public static string ConstructionEstimation(ConstructableInfo construction, IText neverText, IText perTurnText, IText perTurnPlusText, IText etaText, IText burstText)
        {
            if (construction.CompletedCount > 1)
            {
                if (construction.Investment < construction.Cost)
                {
                    return(burstText.Text(null, new TextVar("count", new ThousandsFormatter().Format(construction.CompletedCount)).Get));
                }

                var rate = (long)Math.Floor(construction.Investment / construction.Cost);
                if (rate < construction.CompletedCount)
                {
                    return(perTurnPlusText.Text(
                               null,
                               new TextVar("count", new ThousandsFormatter().Format(construction.CompletedCount)).
                               And("extra", new ThousandsFormatter().Format(construction.CompletedCount - rate)).Get
                               ));
                }

                return(perTurnText.Text(null, new TextVar("count", new ThousandsFormatter().Format(construction.CompletedCount)).Get));
            }

            if (construction.Investment <= 0 || (construction.Investment / construction.Cost) < MinimumPerTurnDone)
            {
                return(neverText.Text());
            }

            var eta = (construction.Cost - construction.FromStockpile) / construction.Investment;

            return(etaText.Text(
                       new Var("eta", eta).Get,
                       new TextVar("eta", (eta < 10) ?
                                   new DecimalsFormatter(0, 1).Format(eta, RoundingMethod.Ceil, 1) :
                                   new ThousandsFormatter().Format(Math.Ceiling(eta))
                                   ).Get
                       ));
        }
Exemplo n.º 6
0
 public override void Enqueue(ConstructableInfo data)
 {
     //no operation
 }