public bool HasJobsFor(PopType popType, Province province) { return(popType.HasJobsFor(popType, here)); }
public Soldiers(int iamount, Culture iculture, Province where) : base(iamount, PopType.Soldiers, iculture, where) { }
static List <Province> getSeaProvinces() { List <Province> res = new List <Province>(); if (!readMapFormFile) { Province seaProvince; for (int x = 0; x < map.getWidth(); x++) { seaProvince = Province.find(map.GetPixel(x, 0)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } seaProvince = Province.find(map.GetPixel(x, map.getHeight() - 1)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } for (int y = 0; y < map.getHeight(); y++) { seaProvince = Province.find(map.GetPixel(0, y)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } seaProvince = Province.find(map.GetPixel(map.getWidth() - 1, y)); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } seaProvince = Province.find(map.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } if (Game.Random.Next(3) == 1) { seaProvince = Province.find(map.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } if (Game.Random.Next(20) == 1) { seaProvince = Province.find(map.getRandomPixel()); if (!res.Contains(seaProvince)) { res.Add(seaProvince); } } } } else { foreach (var item in Province.allProvinces) { var color = item.getColorID(); if (color.g + color.b >= 200f / 255f + 200f / 255f && color.r < 96f / 255f) { //if (color.g + color.b + color.r > 492f / 255f) res.Add(item); } } } return(res); }
public bool IsSelectedProvince(Province province) { return(showingProvince == province); }
public void OnMoveArmy(object sender, EventArgs e) { if (getSize() > 0) { if (Path != null) { if (Path.nodes.Count > 0) { var oldProvince = Province; Province = Path.nodes[0].Province; Path.nodes.RemoveAt(0); oldProvince.RemoveArmy(this); if (!Province.AllStandingArmies().Contains(this)) { Province.AddArmy(this); } if (Game.selectedArmies.Contains(this)) { ArmiesSelectionWindow.Get.Refresh();// need that ti check if units Ok to merge } if (Path.nodes.Count == 0) { Path = null; //if (owner == Game.Player && !Game.isPlayerSurrended()) // Message.NewMessage(this.FullName + " arrived!", "Commander, " + this.FullName + " arrived to " + Province + " province", "Fine", false, Province.getPosition()); } if (owner != Province.Country) // thats attacking { if (Province.Country.isAI()) { if (Province.Country == World.UncolonizedLand) { Province.Country.mobilize(Province.Yield()); } else { Province.Country.mobilize(Province.Country.AllProvinces()); Province.Country.AllArmies().PerformAction(x => x.SetPathTo(Province.Country.Capital)); } } var attackerIsCountry = owner as Country; if (attackerIsCountry != null) { Province.Country.changeRelation(attackerIsCountry, -0.5f); if (attackerIsCountry.LastAttackDate.ContainsKey(Province.Country)) { attackerIsCountry.LastAttackDate[Province.Country].set(Date.Today); } else { attackerIsCountry.LastAttackDate.Add(Province.Country, Date.Today.Copy()); } } } foreach (var enemyArmy in Province.AllStandingArmies().Where(x => x.owner != owner && (x.owner is Country || owner is Country)).ToList()) { if (enemyArmy.getSize() > 0) { this.attack(enemyArmy).createMessage(); } } if (getSize() > 0) // todo change to alive check { var isCountryOwner = owner as Country; if (isCountryOwner != null && isCountryOwner != Province.Country) { if (Province.Country == Game.Player && !Game.isPlayerSurrended()) { Message.NewMessage("Province lost!", "Commander, " + isCountryOwner + " took " + Province, "Fine", false, Province.getPosition()); } isCountryOwner.TakeProvince(Province, true); } } Game.provincesToRedrawArmies.Add(oldProvince); Game.provincesToRedrawArmies.Add(Province); } } if (owner.isAI()) { // auto merge armies for AI var sameCountryArmies = Province.AllStandingArmies().Where(x => x.owner == owner).ToList(); while (sameCountryArmies.Count > 1) { sameCountryArmies[0].JoinIn(sameCountryArmies[1]); sameCountryArmies.Remove(sameCountryArmies[1]); } } } }
public Aristocrats(PopUnit pop, int sizeOfNewPop, Province where, Culture culture, IWayOfLifeChange oldLife) : base(pop, sizeOfNewPop, PopType.Aristocrats, where, culture, oldLife) { }
internal override void invest() { // Aristocrats invests only in resource factories (and banks) if (Province.getResource() != null) { // if AverageFactoryWorkforceFulfilling isn't full you can get more workforce by raising salary (implement it later) var projects = Province.getAllInvestmentProjects(this).Where(x => x.CanProduce(Province.getResource())); var project = projects.MaxByRandom(x => x.GetMargin().Multiply(getBusinessSecurity(x)).get()); if (project != null && project.GetMargin().Multiply(getBusinessSecurity(project)).isBiggerThan(Options.minMarginToInvest)) { var factoryProject = project as NewFactoryProject; // build new one if (factoryProject != null) { // todo remove connection to grain Storage resourceToBuild = factoryProject.Type.GetBuildNeeds().GetFirstSubstituteStorage(Product.Grain); // try to build for grain if (storage.has(resourceToBuild)) { var factory = Province.BuildFactory(this, factoryProject.Type, Game.market.getCost(resourceToBuild)); storage.send(factory.getInputProductsReserve(), resourceToBuild); factory.constructionNeeds.setZero(); } else // build for money { ReadOnlyValue investmentCost = Game.market.getCost(resourceToBuild); if (!CanPay(investmentCost)) { Bank.GiveLackingMoneyInCredit(this, investmentCost); } if (CanPay(investmentCost)) { var factory = Province.BuildFactory(this, factoryProject.Type, investmentCost); // build new one PayWithoutRecord(factory, investmentCost); } } } else { var factory = project as Factory;// existing one if (factory != null) { Value investmentCost = factory.GetInvestmentCost(); if (!CanPay(investmentCost)) { Bank.GiveLackingMoneyInCredit(this, investmentCost); } if (CanPay(investmentCost)) { if (factory.IsOpen) { factory.upgrade(this); } else { factory.open(this, true); } } } else { Owners buyShare = project as Owners; if (buyShare != null) // buy part of existing factory { Value investmentCost = buyShare.GetInvestmentCost(); if (!CanPay(investmentCost)) { Bank.GiveLackingMoneyInCredit(this, investmentCost); } if (CanPay(investmentCost)) { buyShare.BuyStandardShare(this); } } else { Debug.Log("Unknown investment type"); } } } } } base.invest(); }
protected Producer(Province province) : base(province.Country) { this.province = province; }
public Workers(PopUnit pop, int sizeOfNewPop, Province where, Culture culture) : base(pop, sizeOfNewPop, PopType.Workers, where, culture) { }
public Artisans(int amount, Culture culture, Province where) : base(amount, PopType.Artisans, culture, where) { //changeProductionType(); }
/// <summary> /// Enterprise rises salary if labor demand is bigger than labor supply (assuming enterprise is profitable). And vice versa - enterprise lowers salary if labor demand is lower than labor supply. ///More profitable enterprise rises salary faster. /// </summary> public void ChangeSalary() { //Should be rise salary if: small unemployment, has profit, need has other resources if (IsOpen && Economy.isMarket.checkIfTrue(Country)) { var unemployment = Province.GetAllPopulation().Where(x => x.Type == PopType.Workers).GetAverageProcent(x => x.getUnemployment()); var margin = GetMargin(); // rise salary to attract workforce, including workforce from other factories if (margin.isBiggerThan(Options.minMarginToRiseSalary) && unemployment.isSmallerThan(Options.ProvinceLackWorkforce) && //demand >= supply GetVacancies() > 10) // && getInputFactor() == 1) { // cant catch up salaries like that. Check for zero workforce? float salaryRaise = 0.001f; //1% if (margin.get() > 10f) //1000% { salaryRaise = 0.012f; } else if (margin.get() > 1f) //100% { salaryRaise = 0.006f; } else if (margin.get() > 0.3f) //30% { salaryRaise = 0.003f; } else if (margin.get() > 0.1f) //10% { salaryRaise = 0.002f; } salary.add(salaryRaise); } // Reduce salary on non-profit if (margin.isZero() && daysUnprofitable >= Options.minDaysBeforeSalaryCut && !isJustHiredPeople() && !isSubsidized()) { salary.Subtract(0.01f, false); } // if supply > demand if (unemployment.isBiggerThan(Options.ProvinceExcessWorkforce)) { salary.Subtract(0.001f, false); } if (getWorkForce() == 0)// && getInputFactor() == 1) { salary.set(Province.getLocalMinSalary()); } // to help factories catch up other factories salaries // salary.set(province.getLocalMinSalary()); // freshly built factories should rise salary to concurrency with old ones //if (getWorkForce() < 100 && Province.getUnemployedWorkers() == 0 && this.Cash.get() > 10f)// && getInputFactor() == 1) // //salary.set(province.getLocalMinSalary()); // salary.add(0.09f); // limit salary country's min wage var minSalary = Country.getMinSalary(); if (salary.isSmallerThan(minSalary)) { salary.set(minSalary); } } }
public Artisans(PopUnit pop, int sizeOfNewPop, Province where, Culture culture, IWayOfLifeChange oldLife) : base(pop, sizeOfNewPop, PopType.Artisans, where, culture, oldLife) { changeProductionType(); }
//internal Army split(Procent howMuchShouldBeInSecondArmy) //{ // if (personal.Count > 0) // { // Army newArmy = new Army(); // int newArmyExpectedSize = howMuchShouldBeInSecondArmy.getProcent(this.getSize()); // //personal= personal.OrderBy((x) => x.getSize()).ToList(); // personal.Sort((x, y) => x == null ? (y == null ? 0 : -1) // : (y == null ? 1 : x.getSize().CompareTo(y.getSize()))); // while (newArmy.getSize() < newArmyExpectedSize) // personal.move(this.personal[0], newArmy.personal); // return newArmy; // } // else // return null; //} internal void sendTo(Province province) { destination = province; }
internal bool isNeighbor(Province province) { return(neighbors.Contains(province)); }
public Tribesmen(PopUnit pop, int sizeOfNewPop, Province where, Culture culture, IWayOfLifeChange oldLife) : base(pop, sizeOfNewPop, PopType.Tribesmen, where, culture, oldLife) { }
protected Agent(float inAmount, Bank bank, Province province) { cash.set(inAmount); this.bank = bank; this.province = province; }
public NewFactoryProject(Province province, ProductionType type) { this.Type = type; this.province = province; }
public Aristocrats(PopUnit pop, int sizeOfNewPop, Province where, Culture culture) : base(pop, sizeOfNewPop, PopType.Aristocrats, where, culture) { }
public Aristocrats(int iamount, Culture iculture, Province where) : base(iamount, PopType.Aristocrats, iculture, where) { }
//private readonly Artisans owner; public ArtisanProduction(FactoryType type, Province province, Artisans artisan) : base(type, province) { base.setOwner(artisan); }
public void ClearAllFiltres() // show all button { showingProvince = null; table.ClearAllFiltres(); Refresh(); }
protected Investor(PopUnit source, int sizeOfNewPop, PopType newPopType, Province where, Culture culture, IWayOfLifeChange oldLife) : base(source, sizeOfNewPop, newPopType, where, culture, oldLife) { }
private void CheckPathOnProvinceOwnerChanged(object sender, Province.OwnerChangedEventArgs e) { if (e.oldOwner == Province.Country && Path != null && Path.nodes.Any(x => x.Province == sender))//changed owner, probably, on our way { Path = null; Game.provincesToRedrawArmies.Add(Province); //Province.RedrawLocalArmies(); Message.NewMessage(this.FullName + " arrived!", "Commander, " + this.FullName + " stopped at " + Province + " province", "Fine", false, Province.getPosition()); } }
protected Investor(int amount, PopType popType, Culture culture, Province where) : base(amount, popType, culture, where) { }
public Farmers(int iamount, Culture iculture, Province where) : base(iamount, PopType.Farmers, iculture, where) { }
internal virtual void sendAllArmies(Province possibleTarget) { allArmies.PerformAction(x => x.SetPathTo(possibleTarget)); //consolidateArmies().balance(procent).sendTo(possibleTarget); }
public Soldiers(PopUnit pop, int sizeOfNewPop, Province where, Culture culture, IWayOfLifeChange oldLife) : base(pop, sizeOfNewPop, PopType.Soldiers, where, culture, oldLife) { }
public Tribesmen(int iamount, Culture iculture, Province where) : base(iamount, PopType.Tribesmen, iculture, where) { }
public ArtisanProduction(ProductionType type, Province province, Artisans artisan) : base(type, province) { this.artisan = artisan; }
protected GrainGetter(PopUnit source, int sizeOfNewPop, PopType newPopType, Province where, Culture culture, IWayOfLifeChange oldLife) : base(source, sizeOfNewPop, newPopType, where, culture, oldLife) { changeProductionType(Product.Grain); //sentToMarket = new Storage(Product.Grain); }