﻿using HarmonyLib;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Party;
using TaleWorlds.Localization;



namespace VsMod_NoPlayerPrisonerLimit
{
    internal class VsMod_NoPlayerPrisonerLimit_SubModule : MBSubModuleBase
    {

        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            new Harmony("no.idea.whatthisdoes").PatchAll();
        }

        protected override void OnBeforeInitialModuleScreenSetAsRoot()
        {
            base.OnBeforeInitialModuleScreenSetAsRoot();
            InformationManager.DisplayMessage(new InformationMessage("Vaeringjar's No Player Prisoner Limit"));
        }

    }

    [HarmonyPatch(typeof(DefaultPartySizeLimitModel), "CalculateMobilePartyPrisonerSizeLimitInternal")]
    internal class VsMod_NoPlayerPrisonerLimit_Override
    {
        public static void Postfix(PartyBase party, StatExplainer explanation, ref int __result)
        {

            TextObject _thisisatextobject = new TextObject("V's No Player Prisoner Limit");

            if (party.LeaderHero != null && party.LeaderHero == Hero.MainHero)
            {

                ExplainedNumber explainedNumberB = new ExplainedNumber(0f, explanation, null);
                explainedNumberB.Add(10000f, _thisisatextobject);

                __result = (int)explainedNumberB.ResultNumber;

            }
        }
    }
}
