private void testAddAllies(Entities.War war) { for (int i = 0; i < 10; ++i) { AttackerAllies.Add(new ShortWarCountryInfoViewModel(war.Attacker)); } for (int i = 0; i < 10; ++i) { AttackerAllies.Add(new ShortWarCountryInfoViewModel(war.Defender)); } }
public DeclareWarInformationsViewModel(Entities.Country declaringCountry, double goldNeeded, List <Entities.Country> attackerAllies, List <Entities.Country> defenderAllies) { GoldNeeded = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)goldNeeded); foreach (var ally in attackerAllies) { AttackerAllies.Add(new ShortCountryInfoViewModel(ally)); } foreach (var ally in defenderAllies) { DefenderAllies.Add(new ShortCountryInfoViewModel(ally)); } CountryGold = new MoneyViewModel(declaringCountry.Entity.Wallet.GetMoney(CurrencyTypeEnum.Gold, Persistent.Currencies.GetAll())); CountryName = declaringCountry.Entity.Name; }
public WarInfoViewModel(Entities.War war, IWarRepository warRepository, IWarService warService) { Info = new ShortWarInfoViewModel(war, warService); Active = war.Active; var countriesInWar = warRepository.GetCountriesInWar(war.ID); var countries = new { Attackers = countriesInWar. Where(ciw => ciw.IsAttacker) .Select(ciw => ciw.Country) .ToList(), Defenders = countriesInWar .Where(ciw => ciw.IsAttacker == false) .Select(ciw => ciw.Country) .ToList() }; IsRessistance = war.IsRessistanceWar; foreach (var attacker in countries.Attackers) { AttackerAllies.Add(new ShortWarCountryInfoViewModel(attacker)); } foreach (var defender in countries.Defenders) { DefendedAllies.Add(new ShortWarCountryInfoViewModel(defender)); } var entity = SessionHelper.CurrentEntity; var operatedCountry = warService.GetControlledCountryInWar(entity, war); CanInitiateBattle = warService.CanStartBattle(entity, operatedCountry, war).isSuccess; CanInitiateSurrender = warService.CanSurrenderWar(war, entity).isSuccess; if (Active) { WarStateText = "Active"; if (war.AttackerOfferedSurrender == true) { WarStateText = "Attacker offered surrender"; } else if (war.AttackerOfferedSurrender == false) { WarStateText = "Defender offered surrender"; } } else { WarStateText = "Inactive"; } var warSide = warService.GetWarSide(war, SessionHelper.CurrentEntity); if (war.AttackerOfferedSurrender.HasValue == false && CanInitiateSurrender) { SurrenderText = "Send surrender offer"; } if (((war.AttackerOfferedSurrender == true && warSide == WarSideEnum.Defender) || (war.AttackerOfferedSurrender == false && warSide == WarSideEnum.Attacker)) && CanInitiateSurrender) { SurrenderText = "Accept surrender"; } CanCancelSurrender = warService.CanCancelSurrender(war, SessionHelper.CurrentEntity).isSuccess; var attackerHero = warService.GetWarHero(war, true); var defenderHero = warService.GetWarHero(war, false); if (attackerHero != null) { AttackerHero = new ShortBattleParticipantViewModel(attackerHero); } if (defenderHero != null) { DefenderHero = new ShortBattleParticipantViewModel(defenderHero); } if (war.IsTrainingWar) { AttackerAllies = new List <ShortWarCountryInfoViewModel>(); DefendedAllies = new List <ShortWarCountryInfoViewModel>(); CanCancelSurrender = CanInitiateBattle = CanInitiateSurrender = false; } //testAddAllies(war); createMenu(); }