public async Task <IActionResult> PutGovernmentType(int id, GovernmentType governmentType) { if (id != governmentType.Id) { return(BadRequest()); } _context.Entry(governmentType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GovernmentTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//Ctors public Government(GovernmentType govType) { GovType = govType; switch (govType) { case GovernmentType.Monarchy: MilBonusStrength = 0; Description = "Political system based upon the undivided sovereignty or rule of a single person."; break; case GovernmentType.Fascism: MilBonusStrength = 15; Description = "Authorian ultranationalism with forcibile suppression of opposition."; break; case GovernmentType.Dictatorship: MilBonusStrength = 30; Description = "One person possesses absolute power without limitations."; break; case GovernmentType.Republic: MilBonusStrength = -10; Description = "Ruled by representatives of the citizen body."; break; case GovernmentType.Democracy: MilBonusStrength = 5; Description = "The people have the authority to choose their governing legislation."; break; default: break; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] GovernmentType governmentType) { if (id != governmentType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(governmentType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GovernmentTypeExists(governmentType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(governmentType)); }
public async Task <ActionResult <GovernmentType> > PostGovernmentType(GovernmentType governmentType) { _context.GovernmentTypes.Add(governmentType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGovernmentType", new { id = governmentType.Id }, governmentType)); }
public Government(GovernmentType type, string name, string capital, long population, long area) { Type = type; Name = name; Capital = capital; Population = population; Area = area; }
public async Task <IActionResult> Create([Bind("Id,Name")] GovernmentType governmentType) { if (ModelState.IsValid) { _context.Add(governmentType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(governmentType)); }
public void AddGovernment(GovernmentType type, string name, string capital, long population, long area) { var item = _builder .SetArea(area) .SetCapital(capital) .SetName(name) .SetPopulation(population) .SetCapital(capital) .SetType(type) .Build(); _governments.Add(item); }
public WebsiteCategoryDto GetWebsiteCategory(GovernmentType domainType, string agency, string organization, string city, string state) { var entity = (from websiteCategory in this.DbSet where websiteCategory.GovernmentType == (int)domainType && websiteCategory.Agency.Equals(agency, StringComparison.OrdinalIgnoreCase) && websiteCategory.Organization.Equals(organization, StringComparison.OrdinalIgnoreCase) && websiteCategory.State.Equals(state, StringComparison.OrdinalIgnoreCase) && websiteCategory.City.Equals(city, StringComparison.OrdinalIgnoreCase) select websiteCategory).SingleOrDefault(); if (entity == null) { return(null); } return(Mapper.Map <WebsiteCategoryDto>(entity)); }
private static int FreeSupport(this City city, GovernmentType government, CosmicRules constants) { return(government switch { GovernmentType.Anarchy => city.Size // Only units above city size cost 1 shield , GovernmentType.Despotism => city.Size // Only units above city size cost 1 shield , GovernmentType.Communism => constants.CommunismPaysSupport // First 3 units have no shield cost , GovernmentType.Monarchy => constants.MonarchyPaysSupport // First 3 units have no shield cost , GovernmentType.Fundamentalism => constants.FundamentalismPaysSupport // First 10 units have no shield cost , GovernmentType.Republic => 0 // Each unit costs 1 shield per turn , GovernmentType.Democracy => 0 // Each unit costs 1 shield per turn , _ => 0 });
public static void CalculateOutput(this City city, GovernmentType government, Game game) { var lowOrganisation = government <= GovernmentType.Despotism; var orgLevel = city.OrganizationLevel; // var hasSuperMarket = city.ImprovementExists(ImprovementType.Supermarket); // var hasSuperhighways = city.ImprovementExists(ImprovementType.Superhighways); var totalFood = 0; var totalSheilds = 0; var totalTrade = 0; city.WorkedTiles.ForEach(t => { totalFood += t.GetFood(lowOrganisation); totalSheilds += t.GetShields(lowOrganisation); totalTrade += t.GetTrade(orgLevel); }); city.Support = city.SupportedUnits.Count(u => u.NeedsSupport); var distance = ComputeDistanceFactor(city, government, game); if (distance == 0) { city.Waste = 0; city.Corruption = 0; } else { distance *= game.CurrentMap.ScaleFactor; var gov = (int)(city.WeLoveKingDay ? government + 1 : government); var corruptionTenTenFactor = 15d / (4 + gov); var wasteTenTenFactor = 15d / (4 + gov * 4); // https://apolyton.net/forum/miscellaneous/archives/civ2-strategy-archive/62524-corruption-and-waste var corruption = totalTrade * Math.Min(32, distance) * corruptionTenTenFactor / 100; var waste = (totalSheilds - city.Support) * Math.Min(16, distance) * wasteTenTenFactor / 100; if (city.ImprovementExists(ImprovementType.Courthouse)) { waste *= 0.5d; corruption *= 0.5d; } //TODO: Trade route to capital city.Waste = (int)Math.Floor(waste); city.Corruption = (int)Math.Floor(corruption); } city.TotalProduction = totalSheilds; city.Trade = totalTrade - city.Corruption; city.Production = totalSheilds - city.Support - city.Waste; city.FoodConsumption = city.Size * game.Rules.Cosmic.FoodEatenPerTurn + city.SupportedUnits.Count(u => u.AIrole == AIroleType.Settle) * (government <= GovernmentType.Monarchy ? game.Rules.Cosmic.SettlersEatTillMonarchy : game.Rules.Cosmic.SettlersEatFromCommunism); city.FoodProduction = totalFood; city.SurplusHunger = totalFood - city.FoodConsumption; }
public GovernmentBuilder SetType(GovernmentType type) { _government.Type = type; return(this); }
public static void AssertWebsiteEntry(WebsiteEntry websiteEntry, string hostname, GovernmentType governmentType, string agency, string organization, string city, string state, string contactEmail) { Assert.AreEqual(hostname, websiteEntry.Hostname); Assert.AreEqual(governmentType, websiteEntry.GovernmentType); Assert.AreEqual(agency, websiteEntry.Agency); Assert.AreEqual(organization, websiteEntry.Organization); Assert.AreEqual(city, websiteEntry.City); Assert.AreEqual(state, websiteEntry.State); Assert.AreEqual(contactEmail, websiteEntry.ContactEmail); }
public Government(GovernmentType iType, int iScoreModifier) : base((int)iType, iType.ToString(), iScoreModifier) { _type = iType; }