Beispiel #1
0
    internal bool CanBuildNewFactory(FactoryType ft)
    {
        if (HaveFactory(ft))
        {
            return(false);
        }
        if ((ft.isResourceGathering() && ft.basicProduction.getProduct() != this.resource) || !owner.isInvented(ft.basicProduction.getProduct()))
        {
            return(false);
        }

        return(true);
    }
Beispiel #2
0
    internal Factory(Province iprovince, Owner inowner, FactoryType intype)
    { //assuming this is level 0 building
        type           = intype;
        needsToUpgrade = type.getBuildNeeds();
        iprovince.allFactories.Add(this);
        factoryOwner = inowner;
        province     = iprovince;

        gainGoodsThisTurn = new Storage(type.basicProduction.getProduct());
        storageNow        = new Storage(type.basicProduction.getProduct());
        sentToMarket      = new Storage(type.basicProduction.getProduct());

        salary.set(province.getLocalMinSalary());


        modifierHasResourceInProvince = new Modifier(delegate(Country forWhom)
        {
            return(!type.isResourceGathering() && province.isProducingOnFactories(type.resourceInput));
        },
                                                     "Has input resource in thst province", true, 20f);
        modifierLevelBonus = new Modifier(delegate() { return(this.getLevel()); }, "High production concetration bonus", true, 5f);
        modifierInventedMiningAndIsShaft = new Modifier(
            delegate(Country forWhom)
        {
            return(forWhom.isInvented(InventionType.mining) && type.isShaft());
        },
            new StringBuilder("Invented ").Append(InventionType.mining.ToString()).ToString(), false, 50f);
        modifierBelongsToCountry = new Modifier(
            delegate(Country forWhom)
        {
            return(factoryOwner is Country);
        },
            "Belongs to government", false, -20f);

        modifierNotBelongsToCountry = new Condition(
            (Country x) => !(factoryOwner is Country),
            "Doesn't belongs to government", false);
        modifierIsSubsidised = new Modifier((x) => isSubsidized(), "Is subsidized", false, -10f);
        modifierEfficiency   = new ModifiersList(new List <Condition>()
        {
            new Modifier(InventionType.steamPower, true, 25f),
            modifierInventedMiningAndIsShaft,
            new Modifier(Economy.StateCapitalism, true, 10f),
            new Modifier(Economy.Interventionism, true, 30f),
            new Modifier(Economy.LaissezFaire, true, 50f),
            new Modifier(Economy.PlannedEconomy, true, -10f),
            modifierHasResourceInProvince, modifierLevelBonus,
            modifierBelongsToCountry, modifierIsSubsidised
        });

        conditionsUpgrade = new ConditionsList(new List <Condition>()
        {
            new Condition(delegate(Owner forWhom) { return(province.owner.economy.status != Economy.LaissezFaire || forWhom is PopUnit); }, "Economy policy is not Laissez Faire", true),
            new Condition(delegate(Owner forWhom) { return(!isUpgrading()); }, "Not upgrading", false),
            new Condition(delegate(Owner forWhom) { return(!isBuilding()); }, "Not building", false),
            new Condition(delegate(Owner forWhom) { return(isWorking()); }, "Open", false),
            new Condition(delegate(Owner forWhom) { return(level != Game.maxFactoryLevel); }, "Max level not achieved", false),
            new Condition(delegate(Owner forWhom) {
                Value cost = this.getUpgradeCost();
                return(forWhom.wallet.canPay(cost));
            }, delegate() {
                Game.threadDangerSB.Clear();
                Game.threadDangerSB.Append("Have ").Append(getUpgradeCost()).Append(" coins");
                return(Game.threadDangerSB.ToString());
            }, true)
        });

        conditionsClose = new ConditionsList(new List <Condition>()
        {
            new Condition(delegate(Owner forWhom) { return(province.owner.economy.status != Economy.LaissezFaire || forWhom is PopUnit); }, "Economy policy is not Laissez Faire", true),
            new Condition(delegate(Owner forWhom) { return(!isBuilding()); }, "Not building", false),
            new Condition(delegate(Owner forWhom) { return(isWorking()); }, "Open", false),
        });
        conditionsReopen = new ConditionsList(new List <Condition>()
        {
            new Condition(delegate(Owner forWhom) { return(province.owner.economy.status != Economy.LaissezFaire || forWhom is PopUnit); }, "Economy policy is not Laissez Faire", true),
            new Condition(delegate(Owner forWhom) { return(!isBuilding()); }, "Not building", false),
            new Condition(delegate(Owner forWhom) { return(!isWorking()); }, "Close", false),
            new Condition(delegate(Owner forWhom) {
                return(forWhom.wallet.canPay(getReopenCost()));
            }, delegate() {
                Game.threadDangerSB.Clear();
                Game.threadDangerSB.Append("Have ").Append(getReopenCost()).Append(" coins");
                return(Game.threadDangerSB.ToString());
            }, true)
        });
        conditionsDestroy = new ConditionsList(new List <Condition>()
        {
            Economy.isNotLF
        });
        //status == Economy.LaissezFaire || status == Economy.Interventionism || status == Economy.NaturalEconomy
        conditionsSell = ConditionsList.IsNotImplemented; // !Planned and ! State

        //(status == Economy.StateCapitalism || status == Economy.Interventionism || status == Economy.NaturalEconomy)
        conditionsBuy = ConditionsList.IsNotImplemented; // ! LF and !Planned

        // (status == Economy.PlannedEconomy || status == Economy.NaturalEconomy || status == Economy.StateCapitalism)
        conditionsNatinalize = new ConditionsList(new List <Condition>()
        {
            Economy.isNotLF, Economy.isNotInterventionism, modifierNotBelongsToCountry
        }); //!LF and ! Inter


        conditionsSubsidize = new ConditionsList(new List <Condition>()
        {
            Economy.isNotLF, Economy.isNotNatural
        });

        conditionsDontHireOnSubsidies = new ConditionsList(new List <Condition>()
        {
            Economy.isNotLF, Economy.isNotNatural, Condition.IsNotImplemented
        });

        conditionsChangePriority = new ConditionsList(new List <Condition>()
        {
            Economy.isNotLF, Condition.IsNotImplemented
        });
    }