public void EndWar(War war, bool informatAboutWarEnd = true) { war.Active = false; war.EndDay = GameHelper.CurrentDay; var attackerHero = GetWarHero(war, isAttacker: true); var defenderHero = GetWarHero(war, isAttacker: false); if (attackerHero != null) { citizenService.ReceiveWarHeroMedal(attackerHero.Citizen); } if (defenderHero != null) { citizenService.ReceiveWarHeroMedal(defenderHero.Citizen); } if (informatAboutWarEnd) { string warLink = WarLinkCreator.Create(war).ToHtmlString(); string message = $"{warLink.FirstUpper()} has ended."; using (NoSaveChanges) SendMessageToEveryoneInWar(war, message); } using (NoSaveChanges) warEventService.AddEvent(war, WarStatusEnum.Finished); ConditionalSaveChanges(warRepository); }
public void SendInformationAboutSurrenderAccept(War war, Country acceptingCountry) { var countryLink = EntityLinkCreator.Create(acceptingCountry.Entity); var warLink = WarLinkCreator.Create(war); string message = $"{countryLink} accepted surrender in {warLink}."; SendMessageToEveryoneInWar(war, message, acceptingCountry.ID); }
public void SendInformationAboutSideSurrender(War war, Country surrenderingCountry) { var countryLink = EntityLinkCreator.Create(surrenderingCountry.Entity); var warLink = WarLinkCreator.Create(war); string message = $"{countryLink} offered surrender in {warLink}."; SendMessageToEveryoneInWar(war, message, surrenderingCountry.ID); }
public virtual void SendMessageAboutAttack(War war, WarSideEnum attackingSide, Region region) { var attacker = attackingSide == WarSideEnum.Attacker ? war.Attacker.Entity : war.Defender.Entity; var attackerLink = EntityLinkCreator.Create(attacker).ToHtmlString(); var regionLink = RegionLinkCreator.Create(region).ToHtmlString(); var warLink = WarLinkCreator.Create(war).ToHtmlString(); string message = $"{attackerLink} attacked {regionLink} in {warLink}!"; warService.SendMessageToEveryoneInWar(war, message, attacker.EntityID); }
public void ReceiveRessistanceHeroMedal(Citizen citizen, War war, int battleWonCount, double goldAmount) { using (var trs = transactionScopeProvider.CreateTransactionScope()) { citizen.RessistanceHeroMedals += 1; var warLink = WarLinkCreator.Create(war); using (NoSaveChanges) warningService.AddWarning(citizen.ID, $"{warLink} has been won and you received {goldAmount} gold for winning {battleWonCount} battle{PluralHelper.S(battleWonCount)}."); ReceiveGoldForMedal(citizen, amount: goldAmount, medalName: "Battle hero"); trs?.Complete(); } }
public void CancelWar(War war, string warMessage = null) { using (NoSaveChanges) EndWar(war); var warLink = WarLinkCreator.Create(war); var attackerLink = EntityLinkCreator.Create(war.Attacker.Entity); var defenderLink = EntityLinkCreator.Create(war.Defender.Entity); if (warMessage == null) { warMessage = string.Format("{0} between {1} and {2} has ended", warLink.ToHtmlString(), attackerLink.ToHtmlString(), defenderLink.ToHtmlString()); } else { warMessage = string.Format(warMessage, warLink.ToHtmlString(), attackerLink.ToHtmlString(), defenderLink.ToHtmlString()); } SendMessageToEveryoneInWar(war, warMessage); warRepository.SaveChanges(); }
public void CancelSurrender(War war) { var warLink = WarLinkCreator.Create(war); if (war.AttackerOfferedSurrender == true) { var attackerLink = EntityLinkCreator.Create(war.Attacker.Entity); string message = $"{attackerLink} canceled surrender offer in {warLink}"; SendMessageToEveryoneInWar(war, message, war.AttackerCountryID); } else { var defenderLink = EntityLinkCreator.Create(war.Defender.Entity); string message = $"{defenderLink} canceled surrender offer in {warLink}"; SendMessageToEveryoneInWar(war, message, war.DefenderCountryID); } war.AttackerOfferedSurrender = null; popupService.AddSuccess("You canceled surrender offer."); warRepository.SaveChanges(); }