private void MapEventEnded(MapEvent mapEvent)
        {
            var involvedParty = mapEvent.InvolvedParties.Intersect(RevoltManager.Instance.GetParties()).FirstOrDefault();

            if (involvedParty == null)
            {
                return;
            }

            var revolt = Managers.Revolt.GetRevoltByParty(involvedParty);

            var winnerSide = mapEvent.BattleState == BattleState.AttackerVictory ? mapEvent.AttackerSide : mapEvent.DefenderSide;

            if (winnerSide.PartiesOnThisSide.FirstOrDefault(party => party.Id == involvedParty.Id) == null)
            {
                RevoltBehavior.EndFailedRevolt(revolt);
            }
            else
            {
                RevoltBehavior.EndSucceededRevolt(revolt);
            }
        }
        internal static void StartRevolt(Settlement settlement)
        {
            var textObject = new TextObject(Localization.GameTexts.RevoltsRevoltStart);

            textObject.SetTextVariable("SETTLEMENT", settlement.Name);
            InformationManager.AddNotice(new SettlementRebellionMapNotification(settlement, textObject));
            InformationManager.AddQuickInformation(textObject);

            var settlementInfo        = Managers.Settlement.Get(settlement);
            var atWarWithLoyalFaction = settlementInfo.CurrentFaction.IsAtWarWith(settlementInfo.LoyalFaction);

            Hero leader;

            if (atWarWithLoyalFaction)
            {
                leader = Managers.Faction.GetLordWithLeastFiefs(settlementInfo.LoyalFaction).HeroObject;
            }
            else
            {
                leader = Managers.Character.CreateRandomLeader(settlementInfo.LoyalFaction?.Leader?.Clan ?? settlement.OwnerClan, settlementInfo);
                Managers.Character.Get(leader.CharacterObject).IsRevoltKingdomLeader = true;

                var bannerInfo = Managers.Banner.GetBanner(settlementInfo);
                var banner     = bannerInfo != null ? new Banner(bannerInfo.BannerId) : null;

                var clan = Managers.Clan.CreateClan(leader, null, null, banner);
                Managers.Clan.Get(leader.Clan).IsRevoltClan = true;

                textObject = new TextObject(Localization.GameTexts.RevoltsMinorFactionKingdom);
                textObject.SetTextVariable("SETTLEMENT", settlement.Name);
                Managers.Kingdom.CreateKingdom(leader, textObject, textObject, banner ?? clan.Banner, false);
                Managers.Kingdom.Get(leader.Clan.Kingdom).IsRevoltKingdom = true;
            }

            var mobileParty = Managers.Party.CreateMobileParty(leader, null, settlement.GatePosition, settlement, !atWarWithLoyalFaction, true);

            var amountOfTroops = (RevolutionsSettings.Instance.RevoltsGeneralBaseSize + (int)(settlement.Prosperity * RevolutionsSettings.Instance.RevoltsGeneralProsperityMulitplier)) / 3;
            var basicUnits     = new TroopRoster();

            basicUnits.AddToCounts(leader.Culture.RangedMilitiaTroop, amountOfTroops);
            basicUnits.AddToCounts(leader.Culture.MeleeMilitiaTroop, amountOfTroops * 2);
            mobileParty.MemberRoster.Add(basicUnits);

            if (settlement.MilitaParty != null && settlement.MilitaParty.CurrentSettlement == settlement && settlement.MilitaParty.MapEvent == null)
            {
                foreach (var troopRosterElement in settlement.MilitaParty.MemberRoster)
                {
                    mobileParty.AddElementToMemberRoster(troopRosterElement.Character, troopRosterElement.Number, false);
                }

                settlement.MilitaParty.RemoveParty();
            }

            mobileParty.ChangePartyLeader(mobileParty.Party.Owner.CharacterObject, false);

            if (!FactionManager.IsAtWarAgainstFaction(leader.MapFaction, settlement.MapFaction))
            {
                DeclareWarAction.Apply(leader.MapFaction, settlement.MapFaction);
            }

            var revolt = new Revolt(mobileParty.Party.Id, settlement, !atWarWithLoyalFaction);

            Managers.Revolt.Revolts.Add(revolt);
            settlementInfo.HasRebellionEvent = true;

            if (settlementInfo.Garrision == null || settlementInfo.Garrision.TotalStrength == 0)
            {
                RevoltBehavior.EndSucceededRevolt(revolt);
                return;
            }

            mobileParty.Ai.SetDoNotMakeNewDecisions(true);
            StartBattleAction.Apply(mobileParty.Party, settlementInfo.Garrision);
        }