public Dictionary <PopType, int> getYesVotesByType(IReformValue reform, ref Dictionary <PopType, int> divisionPopulationResult) { // division by pop types Dictionary <PopType, int> divisionVotersResult = new Dictionary <PopType, int>(); foreach (PopType popType in PopType.getAllPopTypes()) { divisionVotersResult.Add(popType, 0); divisionPopulationResult.Add(popType, 0); foreach (Province province in ownedProvinces) { foreach (PopUnit pop in province.AllPops.Where(x => x.Type == popType)) { if (pop.getSayingYes(reform)) { divisionPopulationResult[popType] += pop.population.Get();// * pop.getVotingPower(); if (pop.CanVoteInOwnCountry()) { divisionVotersResult[popType] += pop.population.Get();// * pop.getVotingPower(); } } } } } return(divisionVotersResult); }
protected CattleGetter(int amount, PopType popType, Culture culture, Province where) : base(amount, popType, culture, where) { //storage = new Storage(Product.Cattle); //gainGoodsThisTurn = new Storage(Product.Cattle); //sentToMarket = new Storage(Product.Cattle); changeProductionType(Product.Cattle); }
/// <summary> /// If type is null than return average value for ALL Pops /// </summary> public Value getAverageNeedsFulfilling(PopType type) { Value result = new Value(0); int allPopulation = 0; IEnumerable <PopUnit> selector; if (type == null) { selector = getAllPopUnits(); } else { selector = getAllPopUnits(type); } foreach (PopUnit pop in getAllPopUnits(type)) // get middle needs fulfilling according to pop weight { allPopulation += pop.getPopulation(); result.add(pop.needsFulfilled.multiplyOutside(pop.getPopulation())); } if (allPopulation > 0) { return(result.divideOutside(allPopulation)); } else { return(Procent.HundredProcent); } }
protected CattleGetter(PopUnit source, int sizeOfNewPop, PopType newPopType, Province where, Culture culture, IWayOfLifeChange oldLife) : base(source, sizeOfNewPop, newPopType, where, culture, oldLife) { //storage = new Storage(Product.Cattle); //gainGoodsThisTurn = new Storage(Product.Cattle); //sentToMarket = new Storage(Product.Cattle); changeProductionType(Product.Cattle); }
private void RefreshInfoAboutVotes(Procent procentVotersSayedYes, Procent procentPopulationSayedYes, Dictionary <PopType, int> divisionVotersResult, Dictionary <PopType, int> divisionPopulationResult) { if (Game.Player.government == Government.Despotism) { descriptionText.text += "\nNobody to vote - Despot rules everything"; } else { descriptionText.text += "\n" + procentVotersSayedYes + " of voters want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionVotersResult[type] > 0) { Procent res = new Procent(divisionVotersResult[type] / (float)Game.Player.Provinces.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionPopulationResult[type] > 0) { Procent res = new Procent(divisionPopulationResult[type] / (float)Game.Player.Provinces.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; }
public int getPopulationAmountByType(PopType popType) { int result = 0; foreach (Province province in ownedProvinces) { result += province.AllPops.Where(x => x.Type == popType).Sum(x => x.population.Get()); } return(result); }
public IEnumerable <PopUnit> getAllPopUnits(PopType ipopType) { foreach (PopUnit pop in allPopUnits) { if (pop.popType == ipopType) { yield return(pop); } } }
public bool HasJobsFor(PopType type, Province province) { if (this == Workers || this == Farmers || this == Tribesmen) { return(province.getUnemployment(x => x == Workers).isSmallerThan(MigrationUnemploymentLimit)); } else { return(true); } }
public override bool canThisPromoteInto(PopType targetType) { if (targetType == PopType.Capitalists && getCountry().isInvented(Invention.Manufactures)) { return(true); } else { return(false); } }
public override bool canThisDemoteInto(PopType targetType) { if (targetType == PopType.Tribesmen || targetType == PopType.Soldiers && getCountry().isInvented(Invention.ProfessionalArmy)) { return(true); } else { return(false); } }
public override bool canThisPromoteInto(PopType targetType) { if (targetType == PopType.Aristocrats || targetType == PopType.Capitalists && Country.Science.IsInvented(Invention.Manufactures) ) { return(true); } else { return(false); } }
public int getPopulationAmountByType(PopType ipopType) { int result = 0; foreach (PopUnit pop in getAllPopUnits(ipopType)) { if (pop.popType == ipopType) { result += pop.getPopulation(); } } return(result); }
public List <PopUnit> getAllPopUnitsList(PopType ipopType) { List <PopUnit> result = new List <PopUnit>(); foreach (PopUnit pop in allPopUnits) { if (pop.popType == ipopType) { result.Add(pop); } } return(result); }
public override bool canThisDemoteInto(PopType targetType) { if (targetType == PopType.Workers //|| targetType == PopType.Farmers && getCountry().isInvented(Invention.Farming) // commented this to get more workers & more ec. growth || targetType == PopType.Soldiers && GetCountry().Invented(Invention.ProfessionalArmy)) { return(true); } else { return(false); } }
public override bool canThisPromoteInto(PopType targetType) { if (targetType == PopType.Farmers && Country.Science.IsInvented(Invention.Farming) || targetType == PopType.Artisans ) { return(true); } else { return(false); } }
public override bool canThisDemoteInto(PopType targetType) { if (targetType == PopType.Farmers && getCountry().isInvented(Invention.Farming) || targetType == PopType.Soldiers && getCountry().isInvented(Invention.ProfessionalArmy) || targetType == PopType.Artisans ) { return(true); } else { return(false); } }
public override bool canThisPromoteInto(PopType targetType) { if (targetType == PopType.Aristocrats || // should be officers targetType == PopType.Artisans || targetType == PopType.Farmers && getCountry().isInvented(Invention.Farming) ) { return(true); } else { return(false); } }
public override bool canThisPromoteInto(PopType targetType) { if (targetType == PopType.Aristocrats //|| targetType == PopType.Farmers && getCountry().isInvented(Invention.Farming) //|| targetType == PopType.Soldiers && !getCountry().isInvented(Invention.ProfessionalArmy)) ) { return(true); } else { return(false); } }
public override bool canThisDemoteInto(PopType targetType) { if (//targetType == PopType.Farmers && getCountry().isInvented(Invention.Farming) //|| targetType == PopType.Tribesmen || targetType == PopType.Workers ) { return(true); } else { return(false); } }
public bool HasJobsFor(PopType type, Province province) { //if (this == Workers || this == Farmers || this == Tribesmen) if (this == Workers) { return(province.getUnemployment(x => x == Workers).isSmallerThan(MigrationUnemploymentLimit)); } else if (this == Farmers || this == Tribesmen) { return(province.GetOverpopulation().isSmallerThan(Procent.HundredProcent)); } else { return(true); } }
internal bool hasAnotherPop(PopType type) { int result = 0; foreach (PopUnit pop in allPopUnits) { if (pop.popType == type) { result++; if (result == 2) { return(true); } } } return(false); }
//private static void calcBattles() //{ // foreach (Staff attacker in Staff.getAllStaffs().ToList()) // { // foreach (var attackerArmy in attacker.getAttackingArmies().ToList()) // { // var movement = attacker as Movement; // if (movement == null || movement.isValidGoal()) // movements attack only if goal is still valid // { // var result = attackerArmy.attack(attackerArmy.getDestination()); // if (result.isAttackerWon()) // { // if (movement == null) // (attacker as Country).TakeProvince(attackerArmy.getDestination(), true); // //attackerArmy.getDestination().secedeTo(attacker as Country, true); // else // { // if (movement.getReformType() == null)//separatists // movement.onRevolutionWon(); // else // movement.getReformType().setValue(movement.getGoal()); // } // } // else if (result.isDefenderWon()) // { // if (movement != null) // movement.onRevolutionLost(); // } // if (result.getAttacker() == Game.Player || result.getDefender() == Game.Player) // result.createMessage(); // } // attackerArmy.sendTo(null); // go home // } // //attacker.consolidateArmies(); // } //} public static void prepareForNewTick() { AllMarkets.PerformAction(x => x.SetStatisticToZero()); foreach (Country country in World.AllExistingCountries()) { country.SetStatisticToZero(); foreach (Province province in country.AllProvinces) { foreach (var item in province.AllAgents) { item.SetStatisticToZero(); } } } PopType.sortNeeds(Market.TemporalSingleMarket); //getAllExistingCountries().Random().market Product.sortSubstitutes(Market.TemporalSingleMarket); //getAllExistingCountries().Random().market }
/// <summary> /// If type is null than return average value for ALL Pops. New value /// </summary> public Value getAverageNeedsFulfilling(PopType type) { var list = AllPops.Where(x => x.Type == type).ToList(); if (list.Count == 0) { if (Rand.Chance(Options.PopMigrationToUnknowAreaChance)) { return(Procent.HundredProcent.Copy()); } else { return(Procent.ZeroProcent.Copy()); } } else { return(list.GetAverageProcent(x => x.needsFulfilled)); } }
/// <summary> /// Returns true if seeking for less than Options.PopMigrationUnemploymentLimit /// </summary> public bool HasJobsFor(PopType popType) { if (popType == PopType.Workers) { if (!allFactories.Any(x => x.IsOpen)) { return(false); } return(AllPops.Where(x => x.Type == PopType.Workers) .GetAverageProcent(x => x.GetSeekingJob()).isSmallerThan(Options.PopMigrationUnemploymentLimit)); } else if (popType == PopType.Farmers || popType == PopType.Tribesmen) { return(GetOverpopulation().isSmallerThan(Procent.HundredProcent)); } else { return(true); } }
public static void prepareForNewTick() { Game.market.sentToMarket.setZero(); foreach (Country country in Country.getAllExisting()) { country.SetStatisticToZero(); foreach (Province province in country.ownedProvinces) { province.BalanceEmployableWorkForce(); { foreach (var item in province.getAllAgents()) { item.SetStatisticToZero(); } } } } PopType.sortNeeds(); Product.sortSubstitutes(); }
protected Investor(PopUnit source, int sizeOfNewPop, PopType newPopType, Province where, Culture culture, IWayOfLifeChange oldLife) : base(source, sizeOfNewPop, newPopType, where, culture, oldLife) { }
protected Investor(int amount, PopType popType, Culture culture, Province where) : base(amount, popType, culture, where) { }
private void refresh(bool callRebuildDropDown) { table.Refresh(); //if (Game.Player.movements != null) movementsText.text = Game.Player.movements.getString(); if (movementsText.preferredHeight > 90 && movementsText.preferredHeight < 130) { movementsText.text += "\n\n\n\n"; } movementsHorizontalScrollBar.value = 0; if (selectedReform == null) { voteButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Select reform"; descriptionText.text = "Select reform from left"; forceDecisionButton.GetComponent <ToolTipHandler>().SetText(""); voteButton.GetComponent <ToolTipHandler>().SetText(""); } //did selected reform else { if (callRebuildDropDown) // meaning changed whole reform { rebuildDropDown(); } descriptionText.text = selectedReform + " reforms " + selectedReform.getDescription() + "\nCurrently: " + selectedReform.getValue() + " " + selectedReform.getValue().getDescription() + "\nSelected: "; //if (selectedReformValue != null) if (selectedReformValue != selectedReform.getValue()) { descriptionText.text += selectedReformValue + " " + selectedReformValue.getDescription(); } else { descriptionText.text += "current"; } //// Procent procentPopulationSayedYes = new Procent(0f); Procent procentVotersSayedYes = Game.Player.getYesVotes(selectedReformValue, ref procentPopulationSayedYes); Dictionary <PopType, int> divisionPopulationResult = new Dictionary <PopType, int>(); Dictionary <PopType, int> divisionVotersResult = Game.Player.getYesVotesByType(selectedReformValue, ref divisionPopulationResult); if (selectedReformValue != selectedReform.getValue()) { if (Game.Player.government.getValue() != Government.Despotism) { descriptionText.text += "\n" + procentVotersSayedYes + " of voters want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionVotersResult[type] > 0) { Procent res = new Procent(divisionVotersResult[type] / (float)Game.Player.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } else { descriptionText.text += "\nNobody to vote - Despot rule everything"; } descriptionText.text += "\n" + procentPopulationSayedYes + " of population want this reform ( "; foreach (PopType type in PopType.getAllPopTypes()) { if (divisionPopulationResult[type] > 0) { Procent res = new Procent(divisionPopulationResult[type] / (float)Game.Player.getPopulationAmountByType(type)); descriptionText.text += res + " of " + type + "; "; } } descriptionText.text += ")"; } if (selectedReformValue != null)// && selectedReformValue != selectedReform.getValue()) { if (procentVotersSayedYes.get() >= Options.votingPassBillLimit || Game.Player.government.getValue() == Government.Despotism) { // has enough voters voteButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out voteButton.GetComponent <ToolTipHandler>().text); forceDecisionButton.GetComponent <ToolTipHandler>().SetText(voteButton.GetComponent <ToolTipHandler>().GetText()); forceDecisionButton.interactable = false; voteButton.GetComponentInChildren <Text>().text = "Vote for " + selectedReformValue; } else // not enough voters { voteButton.interactable = false; forceDecisionButton.interactable = selectedReformValue.allowed.isAllTrue(Game.Player, selectedReformValue, out forceDecisionButton.GetComponent <ToolTipHandler>().text); voteButton.GetComponent <ToolTipHandler>().SetText(forceDecisionButton.GetComponent <ToolTipHandler>().GetText()); voteButton.GetComponentInChildren <Text>().text = "Not enough votes"; forceDecisionButton.GetComponent <ToolTipHandler>().text += "\n\nForcing decision against people's desires will drop loyalty!"; } } } }
public bool CanDemoteTo(PopType targetType, Country Country) { if (this == Aristocrats) { if (targetType == Farmers && Country.Invented(Invention.Farming) || targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy) || targetType == Tribesmen) { return(true); } else { return(false); } } else if (this == Artisans) { if (//|| targetType == PopType.Farmers && !Country.isInvented(Invention.Farming) targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy) || targetType == Workers ) { return(true); } else { return(false); } } else if (this == Capitalists) { if (targetType == Farmers && Country.Invented(Invention.Farming) || targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy) || targetType == Artisans ) { return(true); } else { return(false); } } else if (this == Farmers) { if (targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy) || targetType == Tribesmen || targetType == Workers ) { return(true); } else { return(false); } } else if (this == Soldiers) { if (//targetType == PopType.Farmers && Country.isInvented(Invention.Farming) //|| targetType == Tribesmen || targetType == Workers ) { return(true); } else { return(false); } } else if (this == Tribesmen) { if (targetType == Workers || targetType == Farmers && Country.Invented(Invention.Farming) || targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy)) { return(true); } else { return(false); } } else if (this == Workers) { if (targetType == Tribesmen || targetType == Soldiers && Country.Invented(Invention.ProfessionalArmy)) { return(true); } else { return(false); } } else { Debug.Log("Unknown pop type"); return(false); } }
static PopType() // can't be private { var militaryNeeds = 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 List <Storage> { new Storage(Product.Food, 1) }; var tribemenEveryDayNeeds = new List <Storage> { new Storage(Product.Food, 2) }; var tribemenLuxuryNeeds = 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 List <Storage> { new Storage(Product.Food, 1) }; var aristocratsEveryDayNeeds = 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), new Storage(Product.Education, 1f) }; var aristocratsLuxuryNeeds = 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 List <Storage> { new Storage(Product.Food, 1) }; var capitalistsEveryDayNeeds = new List <Storage> { new Storage(Product.Clothes, 1f), new Storage(Product.Furniture, 1f), new Storage(Product.Tobacco, 2f), new Storage(Product.Fruit, 1f), new Storage(Product.Education, 1f) }; var capitalistsLuxuryNeeds = 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 List <Storage> { new Storage(Product.Food, 1) }; var artisansEveryDayNeeds = new List <Storage> { new Storage(Product.Fish, 1f), new Storage(Product.Clothes, 1f), new Storage(Product.Furniture, 1f), new Storage(Product.Metal, 1f), new Storage(Product.Education, 1f) }; var artisansLuxuryNeeds = 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 List <Storage> { new Storage(Product.Food, 1) }; var farmersEveryDayNeeds = 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 List <Storage> { new Storage(Product.Clothes, 1), new Storage(Product.Furniture, 1), new Storage(Product.Liquor, 2), new Storage(Product.Education, 1f) //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 List <Storage> { new Storage(Product.Food, 1) }; var workersEveryDayNeeds = 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 List <Storage> { new Storage(Product.Cars, 0.5f), new Storage(Product.Tobacco, 1f), new Storage(Product.MotorFuel, 0.5f), new Storage(Product.Electronics, 1f), new Storage(Product.Education, 1f) }; Workers = new PopType("Workers", null, 1f, militaryNeeds, workersLifeNeeds, workersEveryDayNeeds, workersLuxuryNeeds); //***************************************next type*************************** var soldiersLifeNeeds = new List <Storage> { new Storage(Product.Food, 2) }; var soldiersEveryDayNeeds = 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 List <Storage> { new Storage(Product.Tobacco, 1f), new Storage(Product.Cars, 1f), // temporally new Storage(Product.MotorFuel, 1f), // temporally new Storage(Product.Education, 1f) }; Soldiers = new PopType("Soldiers", null, 2f, militaryNeeds, soldiersLifeNeeds, soldiersEveryDayNeeds, soldiersLuxuryNeeds); }