Implement miracle unlock management and update tooltip logic for MiracleButton

This commit is contained in:
2025-08-23 14:25:35 +02:00
parent 83b89e3099
commit a6c6bde622
4 changed files with 26 additions and 6 deletions

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using Godot;
using ParasiticGod.Scripts.Core;
using ParasiticGod.Scripts.Core.Effects;
using ParasiticGod.Scripts.Singletons;
namespace ParasiticGod.Scenes.Main;
@@ -79,6 +80,11 @@ public partial class MiracleButton : Button
{
missingRequirements.Add($"Not enough Production ({state.Get(Stat.Production):F0} / {_miracle.ProductionRequired})");
}
if (AreAllUnlocksAlreadyPresent(state))
{
missingRequirements.Add("Already unlocked subsequent powers.");
}
if (missingRequirements.Any())
{
@@ -127,4 +133,16 @@ public partial class MiracleButton : Button
}
return tooltip.TrimEnd();
}
private bool AreAllUnlocksAlreadyPresent(GameState state)
{
var unlockEffect = _miracle.Effects.OfType<UnlockMiracleEffect>().FirstOrDefault();
if (unlockEffect == null || unlockEffect.MiraclesToUnlock.Count == 0)
{
return false;
}
return unlockEffect.MiraclesToUnlock.All(state.IsMiracleUnlocked);
}
}