コード例 #1
0
        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);
        }