Implement miracle unlock management and update tooltip logic for MiracleButton
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user