/// <summary> /// Constructor for resource processing FactoryType /// </summary> internal FactoryType(string name, Storage basicProduction, StorageSet resourceInput) : this(name, basicProduction, false) { //if (resourceInput == null) // this.resourceInput = new PrimitiveStorageSet(); //else this.resourceInput = resourceInput; }
/// <summary> /// Buying PrimitiveStorageSet, subsidizations allowed /// </summary> //internal void SellList(Consumer buyer, StorageSet buying, Country subsidizer) //{ // foreach (Storage item in buying) // if (item.isNotZero()) // buy(buyer, item, subsidizer); //} /// <summary> /// Buying needs in circle, by Procent in time /// return true if buying is zero (bought all what it wanted) /// </summary> internal bool Sell(Producer buyer, StorageSet stillHaveToBuy, Procent buyInTime, List <Storage> ofWhat) { bool buyingIsFinished = true; foreach (Storage what in ofWhat) { Storage consumeOnThisIteration = new Storage(what.Product, what.get() * buyInTime.get()); if (consumeOnThisIteration.isZero()) { return(true); } // check if consumeOnThisIteration is not bigger than stillHaveToBuy if (!stillHaveToBuy.has(consumeOnThisIteration)) { consumeOnThisIteration = stillHaveToBuy.getBiggestStorage(what.Product); } var reallyBought = Sell(buyer, consumeOnThisIteration, null); stillHaveToBuy.Subtract(reallyBought); if (stillHaveToBuy.getBiggestStorage(what.Product).isNotZero()) { buyingIsFinished = false; } } return(buyingIsFinished); }
override public List <Storage> getRealAllNeeds() { StorageSet res = new StorageSet(); foreach (var item in allArmies) { res.add(item.getNeeds()); } return(res.getContainer()); }
public StorageSet getNeeds() { StorageSet res = new StorageSet(); foreach (var item in personal) { res.add(item.Value.getRealNeeds(getOwner().getPlaceDejure())); } return(res); }
/// <summary> /// Buying PrimitiveStorageSet, subsidizations allowed /// </summary> internal void buy(Consumer buyer, StorageSet buying, Country subsidizer) { foreach (Storage item in buying) { if (item.isNotZero()) { buy(buyer, item, subsidizer); } } }
public List <Storage> getNeeds() { // StorageSet used for faster calculation StorageSet res = new StorageSet(); foreach (var item in personal) { res.Add(item.Value.getRealNeeds(getOwner().Country)); } return(res.ToList()); }
internal bool canAfford(StorageSet need) { foreach (Storage stor in need) { if (howMuchCanAfford(stor).get() < stor.get()) { return(false); } } return(true); }
public bool CanAfford(StorageSet need) { foreach (Storage stor in need) { if (!CanAfford(stor)) { //if (HowMuchCanAfford(stor).get() < stor.get()) return(false); } } return(true); }
internal StorageSet getBuildNeeds() { //return new Storage(Product.Food, 40f); // thats weird place StorageSet result = new StorageSet(); result.set(new Storage(Product.Grain, 40f)); //TODO!has connection in pop.invest!! //if (whoCanProduce(Product.Gold) == this) // result.Set(new Storage(Product.Wood, 40f)); return(result); }
internal Factory(Province province, Agent factoryOwner, FactoryType type) : base(type, province) { //assuming this is level 0 building constructionNeeds = getType().getBuildNeeds(); province.allFactories.Add(this); setOwner(factoryOwner); salary.set(province.getLocalMinSalary()); if (getCountry().economy.getValue() == Economy.PlannedEconomy) { setPriorityAutoWithPlannedEconomy(); } }
internal Value getCost(StorageSet need) { Value cost = new Value(0f); // float price; foreach (Storage stor in need) { //price = Game.market.findPrice(stor.getProduct()).get(); cost.add(getCost(stor)); } return(cost); }
/// <summary> /// new value /// </summary> /// <param name="need"></param> /// <returns></returns> internal MoneyView getCost(StorageSet need) { Money cost = new Money(0m); // float price; foreach (Storage stor in need) { //price = World.market.findPrice(stor.Product).get(); cost.Add(getCost(stor)); } return(cost); }
private PopType(string name, Storage produces, float strenght, StorageSet militaryNeeds, StorageSet lifeNeeds, StorageSet everyDayNeeds, StorageSet luxuryNeeds) { this.militaryNeeds = militaryNeeds; this.strenght = strenght; this.name = name; basicProduction = produces; this.lifeNeeds = lifeNeeds; this.everyDayNeeds = everyDayNeeds; this.luxuryNeeds = luxuryNeeds; allPopTypes.Add(this); }
internal bool isProducingOnEnterprises(StorageSet resourceInput) { foreach (Storage inputNeed in resourceInput) { foreach (Factory provinceFactory in allFactories) { if (provinceFactory.getGainGoodsThisTurn().isNotZero() && provinceFactory.getType().basicProduction.getProduct().isSameProduct(inputNeed.getProduct()) ) { return(true); } } } return(false); }
private StorageSet getConsumption() { var consumption = new StorageSet(); foreach (var item in personal) { consumption.Add(item.Value.getConsumption()); } // Procent res = new Procent(0f); //int calculatedSize = 0; //foreach (var item in personal) //{ // res.addPoportionally(calculatedSize, item.Value.getSize(), item.Value.getConsumption()); // calculatedSize += item.Value.getSize(); //} //return res; return(consumption); }
/// <summary> /// Don't call it directly /// </summary> public Factory(Province province, IShareOwner investor, FactoryType type, Value cost) : base(type, province) { //this.buildByPlannedEconomy = buildByPlannedEconomy; ownership = new Owners(this); if (investor != null) // that mean that factory is a fake { currentInvestor = investor; //assuming this is level 0 building constructionNeeds = new StorageSet(getType().GetBuildNeeds()); ownership.Add(investor, cost); salary.set(province.getLocalMinSalary()); if (GetCountry().economy.getValue() == Economy.PlannedEconomy) { setPriorityAutoWithPlannedEconomy(); } //else // Debug.Log(investor + " invested " + cost + " in building new " + this); } }
static PopType() // can't be private { var militaryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 0.2f), new Storage(Product.Cattle, 0.2f), new Storage(Product.ColdArms, 0.2f), new Storage(Product.Firearms, 0.4f), new Storage(Product.Ammunition, 0.6f), new Storage(Product.Artillery, 0.2f), new Storage(Product.Cars, 0.2f), new Storage(Product.Tanks, 0.2f), new Storage(Product.Airplanes, 0.2f), new Storage(Product.MotorFuel, 0.6f) }); var tribemenLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var tribemenEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 2) }); var tribemenLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 3) }); Tribesmen = new PopType("Tribesmen", new Storage(Product.Cattle, 1.0f), 2f, militaryNeeds, tribemenLifeNeeds, tribemenEveryDayNeeds, tribemenLuxuryNeeds); //***************************************next type*************************** var aristocratsLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var aristocratsEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.ColdArms, 1f), new Storage(Product.Clothes, 1f), new Storage(Product.Furniture, 1f), new Storage(Product.Liquor, 2f), new Storage(Product.Electronics, 1f) , }); var aristocratsLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Fruit, 1), new Storage(Product.Cars, 1f), new Storage(Product.MotorFuel, 1f), new Storage(Product.Airplanes, 1f) }); Aristocrats = new PopType("Aristocrats", null, 4f, militaryNeeds, aristocratsLifeNeeds, aristocratsEveryDayNeeds, aristocratsLuxuryNeeds); //***************************************next type*************************** var capitalistsLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var capitalistsEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.Clothes, 1f), new Storage(Product.Furniture, 1f), new Storage(Product.Tobacco, 2f), new Storage(Product.Fruit, 1f) }); var capitalistsLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Liquor, 2f), new Storage(Product.Firearms, 1f), new Storage(Product.Ammunition, 0.5f), new Storage(Product.Cars, 1f), new Storage(Product.MotorFuel, 1f), new Storage(Product.Airplanes, 1f) }); Capitalists = new PopType("Capitalists", null, 1f, militaryNeeds, capitalistsLifeNeeds, capitalistsEveryDayNeeds, capitalistsLuxuryNeeds); //***************************************next type*************************** { var artisansLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var artisansEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.Fish, 1f), new Storage(Product.Clothes, 1f), new Storage(Product.Furniture, 1f), new Storage(Product.Metal, 1f) }); var artisansLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Liquor, 1f), //new Storage(Product.Cars, 1f), //new Storage(Product.MotorFuel, 1f), new Storage(Product.Electronics, 1f), new Storage(Product.Tobacco, 1f) }); Artisans = new PopType("Artisans", null, 1f, militaryNeeds, artisansLifeNeeds, artisansEveryDayNeeds, artisansLuxuryNeeds); } //***************************************next type*************************** var farmersLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var farmersEveryDayNeeds = new StorageSet(new List <Storage> { //everyDayNeeds.Set(new Storage(Product.Fruit, 1), new Storage(Product.Stone, 1f), new Storage(Product.Wood, 1f), //everyDayNeeds.set(new Storage(Product.Wool, 1), new Storage(Product.Lumber, 1f), new Storage(Product.Cars, 0.5f), new Storage(Product.Fish, 1f), new Storage(Product.MotorFuel, 0.5f) }); var farmersLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Clothes, 1), new Storage(Product.Furniture, 1), new Storage(Product.Liquor, 2) //new Storage(Product.Metal, 1), //new Storage(Product.Cement, 0.5f) }); Farmers = new PopType("Farmers", new Storage(Product.Grain, 1.5f), 1f, militaryNeeds, farmersLifeNeeds, farmersEveryDayNeeds, farmersLuxuryNeeds); //***************************************next type*************************** var workersLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 1) }); var workersEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.Clothes, 1f), new Storage(Product.Liquor, 2f), new Storage(Product.Furniture, 1f), new Storage(Product.Cattle, 1) }); var workersLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Cars, 0.5f), new Storage(Product.Tobacco, 1f), new Storage(Product.MotorFuel, 0.5f), new Storage(Product.Electronics, 1f) }); Workers = new PopType("Workers", null, 1f, militaryNeeds, workersLifeNeeds, workersEveryDayNeeds, workersLuxuryNeeds); //***************************************next type*************************** var soldiersLifeNeeds = new StorageSet(new List <Storage> { new Storage(Product.Food, 2) }); var soldiersEveryDayNeeds = new StorageSet(new List <Storage> { new Storage(Product.Fruit, 2), new Storage(Product.Liquor, 5), new Storage(Product.Clothes, 4), new Storage(Product.Furniture, 2), //new Storage(Product.Wood, 1) }); var soldiersLuxuryNeeds = new StorageSet(new List <Storage> { new Storage(Product.Tobacco, 1f), new Storage(Product.Cars, 1f), // temporally new Storage(Product.MotorFuel, 1f), // temporally }); Soldiers = new PopType("Soldiers", null, 2f, militaryNeeds, soldiersLifeNeeds, soldiersEveryDayNeeds, soldiersLuxuryNeeds); }
/// <summary> /// Basic constructor for resource getting FactoryType /// </summary> internal FactoryType(string name, Storage basicProduction, bool shaft) { this.name = name; if (name == "Gold pit") { GoldMine = this; } if (name == "Furniture factory") { Furniture = this; } if (name == "Metal pit") { MetalDigging = this; } if (name == "Metal smelter") { MetalSmelter = this; } if (name == "Barnyard") { Barnyard = this; } allTypes.Add(this); this.basicProduction = basicProduction; //upgradeResource.Set(new Storage(Product.Wood, 10f)); upgradeResourceLowTier = new StorageSet(new List <Storage> { new Storage(Product.Stone, 2f), new Storage(Product.Wood, 10f) }); upgradeResourceMediumTier = new StorageSet(new List <Storage> { new Storage(Product.Stone, 10f), new Storage(Product.Lumber, 3f), new Storage(Product.Cement, 2f), new Storage(Product.Metal, 1f) }); upgradeResourceHighTier = new StorageSet(new List <Storage> { new Storage(Product.Cement, 10f), new Storage(Product.Metal, 4f), new Storage(Product.Machinery, 2f) }); enoughMoneyOrResourcesToBuild = new Condition( delegate(object forWhom) { var agent = forWhom as Agent; if (agent.getCountry().economy.getValue() == Economy.PlannedEconomy) { return(agent.getCountry().countryStorageSet.has(this.getBuildNeeds())); } else { //Value cost = Game.market.getCost(this.getBuildNeeds()); //cost.add(Options.factoryMoneyReservPerLevel); Value cost = getInvestmentsCost(); return(agent.canPay(cost)); } }, delegate { var sb = new StringBuilder(); //Value cost = Game.market.getCost(this.getBuildNeeds()); //cost.add(Options.factoryMoneyReservPerLevel); Value cost = getInvestmentsCost(); sb.Append("Have ").Append(cost).Append(" coins"); sb.Append(" or (with ").Append(Economy.PlannedEconomy).Append(") have ").Append(this.getBuildNeeds()); return(sb.ToString()); }, true); conditionsBuild = new ConditionsListForDoubleObjects(new List <Condition>() { Economy.isNotLF, enoughMoneyOrResourcesToBuild, Province.doesCountryOwn }); // can build this.shaft = shaft; }
static ProductionType() { new ProductionType("Forestry", new Storage(Product.Wood, 2f), false); new ProductionType("Gold pit", new Storage(Product.Gold, 2f * Options.goldToCoinsConvert), true); new ProductionType("Metal pit", new Storage(Product.MetalOre, 2f), true); new ProductionType("Coal pit", new Storage(Product.Coal, 6f), true); new ProductionType("Cotton farm", new Storage(Product.Cotton, 2f), false); new ProductionType("Quarry", new Storage(Product.Stone, 2f), true); new ProductionType("Orchard", new Storage(Product.Fruit, 2f), false); new ProductionType("Fishery", new Storage(Product.Fish, 2f), false); new ProductionType("Tobacco farm", new Storage(Product.Tobacco, 2f), false); new ProductionType("Oil rig", new Storage(Product.Oil, 2f), true); new ProductionType("Rubber plantation", new Storage(Product.Rubber, 1f), false); StorageSet resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Grain, 1f)); new ProductionType("Barnyard", new Storage(Product.Cattle, 2f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Lumber, 1f)); new ProductionType("Furniture factory", new Storage(Product.Furniture, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Wood, 1f)); new ProductionType("Sawmill", new Storage(Product.Lumber, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Fuel, 0.5f)); resourceInput.Set(new Storage(Product.MetalOre, 2f)); new ProductionType("Metal smelter", new Storage(Product.Metal, 8f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Fibers, 1f)); new ProductionType("Weaver factory", new Storage(Product.Clothes, 4f), resourceInput); //resourceInput = new StorageSet(); //resourceInput.Set(new Storage(Product.Fuel, 0.5f)); //resourceInput.Set(new Storage(Product.Stone, 2f)); //new ProductionType("Cement factory", new Storage(Product.Cement, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Sugar, 1f)); new ProductionType("Distillery", new Storage(Product.Liquor, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Metal, 1f)); new ProductionType("Smithery", new Storage(Product.ColdArms, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Stone, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); new ProductionType("Ammunition factory", new Storage(Product.Ammunition, 8f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Lumber, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); new ProductionType("Firearms factory", new Storage(Product.Firearms, 8f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Lumber, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); new ProductionType("Artillery factory", new Storage(Product.Artillery, 8f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Oil, 1f)); new ProductionType("Oil refinery", new Storage(Product.MotorFuel, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Metal, 1f)); new ProductionType("Machinery factory", new Storage(Product.Machinery, 4f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Machinery, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); resourceInput.Set(new Storage(Product.Rubber, 1f)); new ProductionType("Car factory", new Storage(Product.Cars, 12f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Machinery, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); resourceInput.Set(new Storage(Product.Artillery, 1f)); new ProductionType("Tank factory", new Storage(Product.Tanks, 12f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Lumber, 1f)); resourceInput.Set(new Storage(Product.Metal, 1f)); resourceInput.Set(new Storage(Product.Machinery, 1f)); new ProductionType("Airplane factory", new Storage(Product.Airplanes, 12f), resourceInput); resourceInput = new StorageSet(); resourceInput.Set(new Storage(Product.Metal, 1f)); resourceInput.Set(new Storage(Product.Oil, 1f)); resourceInput.Set(new Storage(Product.Rubber, 1f)); new ProductionType("Electronics factory", new Storage(Product.Electronics, 12f), resourceInput); University = new ProductionType("University", new Storage(Product.Education, 4f), new StorageSet()); }
/// <summary> /// Constructor for resource processing FactoryType /// </summary> internal ProductionType(string name, Storage basicProduction, StorageSet resourceInput) : this(name, basicProduction, false) { this.resourceInput = resourceInput; }
public Education(StorageSet numerator, List <Storage> denominator, bool showMessageAboutOperationFails = true) : base(numerator, denominator, showMessageAboutOperationFails) { }
/// <summary> /// Constructor for resource processing FactoryType /// </summary> public ProductionType(string name, Storage basicProduction, StorageSet resourceInput, params Invention[] requiredInventions) : this(name, basicProduction, false, requiredInventions) { this.resourceInput = resourceInput; }