using System.Collections.Generic;
using HarmonyLib;

namespace WalleyeFix.Patches
{
    [HarmonyPatch(typeof(PlayerFishingController), "pickFish")]
    public static class PlayerFishingControllerPatches
    {
        [HarmonyPrefix]
        public static void PickFishPrefix()
        {
            List<FishConfig> allFish = ConfigManager.GetAllByType<FishConfig>();
            if (allFish == null)
            {
                return;
            }

            for (int i = 0; i < allFish.Count; i++)
            {
                FishConfig fishConfig = allFish[i];
                if (fishConfig == null)
                {
                    continue;
                }

                if (fishConfig._FishName != "Walleye")
                {
                    continue;
                }

                List<TierWeight> newWeights = new List<TierWeight>
                {
                    new TierWeight
                    {
                        _Tier = 1,
                        _Weight = 3
                    },
                    new TierWeight
                    {
                        _Tier = 2,
                        _Weight = 3
                    },
                    new TierWeight
                    {
                        _Tier = 3,
                        _Weight = 3
                    }
                };

                Traverse.Create(fishConfig).Field("_spawnWeights").SetValue(newWeights);
                break;
            }
        }
    }
}