// Copyright (c) Strange Loop Games. All rights reserved.
// See LICENSE file in the project root for full license information.
// <auto-generated />
namespace Eco.Mods.TechTree
{
    using Eco.Gameplay.EcopediaRoot;
    using Eco.Gameplay.Players;
    using Eco.Gameplay.Systems.TextLinks;
    using Eco.Gameplay.Utils;
    using Eco.Shared.Utils;
    using System.Collections.Generic;
    using System.Linq;
    using Eco.Gameplay.Civics;
    using System.Text;
    using Eco.Shared.Localization;
    using Eco.Gameplay.GameActions;
    using Eco.Gameplay.Economy;
    using Eco.Gameplay.Housing.Internal;

    //Various classes that append dynamic data into Ecopedia pages.
    public class EcopediaConstitutionSettings : IEcopediaGeneratedData
    {
        public IEnumerable<EcopediaPageReference> PagesWeSupplyDataFor() => new EcopediaPageReference("CivicObjectComponent", "World Index", "Current Government", Localizer.DoStr("Current Government")).SingleItemAsEnumerable();

        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var cur            = ConstitutionManager.Obj.Current;
            var valToOverthrow = Text.StyledNum(CivicsPlugin.Obj.Config.ValueAdditionToOverthrow);
            var curVal         = Text.StyledNum(cur?.RoomValue.Get ?? 0f);
            var newVal          = Text.StyledNum(ConstitutionManager.Obj.Current?.RoomValue.Get ?? 0);

            var sb = new StringBuilder();
            sb.AppendLine(TextLoc.HeaderLocStr("World Settings"));
            sb.AppendLineLoc($"Constitutions can be overthrown when their value is exceeded by {valToOverthrow}%.");
            sb.AppendLocStr("Current constituion:");
            sb.Append(" ");
            if (cur == null) sb.AppendLine(TextLoc.BoldLocStr("None."));
            else             sb.AppendLineLoc($"{cur.UILink()} with room value {curVal}");
            return sb.ToString();
        }
    }

    //Various classes that append dynamic data into Ecopedia pages.
    public class EcopediaHousingData : IEcopediaGeneratedData
    {
        public IEnumerable<EcopediaPageReference> PagesWeSupplyDataFor() => new EcopediaPageReference(null, null, "Residency", Localizer.DoStr("Residency")).SingleItemAsEnumerable();

        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var i = 0;
            var penalties = HousingCalculation.OccupancyPenalties;
            if (penalties == null) return string.Empty;
            var list = penalties.Skip(1).Select(x => $"{i++} {Localizer.Plural("Occupant", i-1)}: {Text.StyledPercent(x)}");
            return list.MakeListLoc($"Occupancy Penalties:", false);
        }
    }


    //Various classes that append dynamic data into Ecopedia pages.
    public class EcopediaLawData : IEcopediaGeneratedData
    {
        public IEnumerable<EcopediaPageReference> PagesWeSupplyDataFor() => new EcopediaPageReference(null, "Government", "Laws", Localizer.DoStr("Laws")).SingleItemAsEnumerable();

        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var sb = new StringBuilder();
            sb.AppendLine(typeof(GameAction).DerivedTypes().Where(x=>!x.IsAbstract).OrderBy(x=>x.GetLocDisplayName()).Select(x=>x.UILink()).MakeListLoc($"Available Causes"));
            sb.AppendLine(typeof(LegalAction).DerivedTypes().Where(x=>!x.IsAbstract).OrderBy(x => x.GetLocDisplayName()).Select(x => x.UILink()).MakeListLoc($"Available Effects"));
            return sb.ToString();
        }
    }

    public class EcopediaReputationData : IEcopediaGeneratedData
    {
        public IEnumerable<EcopediaPageReference> PagesWeSupplyDataFor() => new EcopediaPageReference(null, null, "Reputation", Localizer.DoStr("Reputation")).SingleItemAsEnumerable();

        public string GetEcopediaData(Player player, EcopediaPage page)
        {
            var sb = new StringBuilder();
            sb.AppendLineLoc($"A citizen may grant reputation to others with a limit of {Text.StyledNum(Reputation.MaxGivableRep)} points (positive or negative) per day.");
            sb.AppendLine();
            var reps = UserManager.Config.Reputations.Select(x=>x.ToString());
            sb.AppendListLoc($"Reputation Titles", reps, false, false);
            return sb.ToString();
        }
    }
}

