public string GetInitialDomainInfo() { if (_initialCityDomain == null) { _initialCityDomain = XmlGameInitializer.GetInitialCityDomain(); } return(GetDomainInfo(_initialCityDomain)); }
private void InitializeFromXml() { var xDoc = XDocument.Load(StringConstants.SettingsPath); var xSettings = xDoc.Element("game")?.Element("options"); _maxYears = Convert.ToInt32(xSettings.Element("years").Value); _normFoodForPerson = Convert.ToInt32(xSettings.Element("bushels").Attribute("norm").Value); _cityDomain = XmlGameInitializer.GetInitialCityDomain(); }
private string PeopleDeadAnalysis(CityDomain currentCityDomain) { var sb = new StringBuilder() .Append($"You starved so many people!!!{_lineSeparator}") .Append(currentCityDomain.CurrentYear >= 7 ? "You are still an inexperienced ruler" : "You are a bloodthirsty tyrant!") .Append(_lineSeparator); return(sb.ToString()); }
public ValidationResultModel Validate(CityDomain cityDomain, PlayerTurnModel turnModel) { ValidationResultModel valid = new ValidationResultModel() { HasErrors = false }; StringBuilder sb = new StringBuilder(); if (turnModel.BushelsToFeed > cityDomain.BushelsCount) { sb.Append("You do not have as many bushels").Append(_separator); valid.HasErrors = true; } if (turnModel.AcrChange < 0 && -turnModel.AcrChange > cityDomain.AcresCount) { sb.Append("You do not have as many acres for sale!").Append(_separator); valid.HasErrors = true; } if (turnModel.AcrChange > 0 && cityDomain.BushelsCount / cityDomain.AcrCost < turnModel.AcrChange) { sb.Append("You do not have as many bushels to buy as many acres!").Append(_separator); valid.HasErrors = true; } if (turnModel.AcresToPlant > cityDomain.AlivePeople * 10) { sb.Append("You do not have so many people to sow such a count of acres!").Append(_separator); valid.HasErrors = true; } if (turnModel.BushelsToFeed < 0) { sb.Append("You can not enter a negative value in the field for food!").Append(_separator); valid.HasErrors = true; } if (turnModel.AcresToPlant < 0) { sb.Append("You can not enter a negative value in the field for sowing acres!").Append(_separator); valid.HasErrors = true; } if (valid.HasErrors) { valid.ErrorMessage = sb.ToString(); } return(valid); }
public string GetDomainInfo(CityDomain domain) { var domainSb = new StringBuilder(); domainSb .Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") .Append(_lineSeparator) .Append($"I beg to report you about {domain.CurrentYear} year:{_lineSeparator}") .Append(GetStarvedPeopleReport(domain.StarvedPeople)) .Append(GetPeopleComeToCityReport(domain.ComingInCurrentYearPeople)) .Append(GetCityPopulationReport(domain.AlivePeople)) .Append(GetAcrsOwningReport(domain.AcresCount)) .Append(GetRatsReport(domain.EatenByRats)) .Append(GetHarvestedBushelsReport(domain.HarvestedBushelsPerAcr)) .Append(GetBushelsInStoreReport(domain.BushelsCount)) .Append(GetLandCostReport(domain.AcrCost)) .Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") .Append(_lineSeparator); return(domainSb.ToString()); }
public string MakeAnalysis(GameOverCause cause, CityDomain intialCityDomain, CityDomain currentCityDomain) { var sb = new StringBuilder() .Append("GAME OVER!") .Append(_lineSeparator); switch (cause) { case GameOverCause.PeopleDead: sb.Append(PeopleDeadAnalysis(currentCityDomain)); break; case GameOverCause.CameLastYear: sb.Append(LastYearCameAnalysis(intialCityDomain, currentCityDomain)); break; default: throw new ArgumentException("Need cause to over the game"); } return(sb.ToString()); }
private void FillViewBag() { ViewBag.Genders = GenderDomain.ListGenders().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }); ViewBag.Cities = CityDomain.ListCities().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }); ViewBag.Regions = RegionDomain.ListRegions().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }); ViewBag.Classifications = ClassificationDomain.ListClassifications().Select(g => new SelectListItem() { Text = g.Name, Value = g.Id.ToString() }); ViewBag.Sellers = UserDomain.ListUsers().Select(g => new SelectListItem() { Text = g.Login, Value = g.Id.ToString() }); }
public string LastYearCameAnalysis(CityDomain intialCityDomain, CityDomain currentCityDomain) { var sb = new StringBuilder($"Congratulations!!! You have live to the last year!{_lineSeparator}"); int compareResult = currentCityDomain.CompareTo(intialCityDomain); switch (compareResult) { case 1: sb.Append("You could exaggerate the wealth of your city!!! You are a great ruler!"); break; case -1: sb.Append("But you failed to maintain the stability of the city("); break; default: sb.Append("Stability is a sign of skill! The state of the city did not change in any way"); break; } sb.Append(_lineSeparator); return(sb.ToString()); }