11using DiskCardGame ;
22using GBC ;
33using HarmonyLib ;
4+ using InscryptionAPI . Helpers ;
45using InscryptionAPI . Helpers . Extensions ;
56using System . Collections ;
67using UnityEngine ;
@@ -11,20 +12,34 @@ public abstract class ExtendedActivatedAbilityBehaviour : AbilityBehaviour
1112 public int bloodCostMod ;
1213 public int bonesCostMod ;
1314 public int energyCostMod ;
15+ public List < GemType > gemsCostMod = new ( ) ;
1416 public int healthCostMod ;
1517
1618 public virtual int StartingBloodCost { get ; }
1719 public virtual int StartingBonesCost { get ; }
1820 public virtual int StartingEnergyCost { get ; }
21+ public virtual List < GemType > StartingGemsCost { get ; }
1922 public virtual int StartingHealthCost { get ; }
2023 public virtual int OnActivateBloodCostMod { get ; set ; }
2124 public virtual int OnActivateBonesCostMod { get ; set ; }
2225 public virtual int OnActivateEnergyCostMod { get ; set ; }
26+ public virtual List < GemType > OnActivateGemsCostMod { get ; set ; }
27+ public virtual bool OnActivateGemsCostModRemovesGems { get ; set ; }
2328 public virtual int OnActivateHealthCostMod { get ; set ; }
2429
2530 public int BloodCost => Mathf . Max ( 0 , StartingBloodCost + bloodCostMod ) ;
2631 public int BonesCost => Mathf . Max ( 0 , StartingBonesCost + bonesCostMod ) ;
2732 public int EnergyCost => Mathf . Max ( 0 , StartingEnergyCost + energyCostMod ) ;
33+ public List < GemType > GemsCost {
34+ get {
35+ List < GemType > retval = new ( ) ;
36+ if ( StartingGemsCost != null && StartingGemsCost . Count > 0 ) {
37+ retval . AddRange ( StartingGemsCost ) ;
38+ }
39+ retval . AddRange ( gemsCostMod ) ;
40+ return retval ;
41+ }
42+ }
2843 public int HealthCost => Mathf . Max ( 0 , StartingHealthCost + healthCostMod ) ;
2944
3045 public Dictionary < CardInfo , CardSlot > currentSacrificedCardInfos = new ( ) ;
@@ -93,8 +108,9 @@ public sealed override IEnumerator OnActivatedAbility()
93108 }
94109 }
95110 }
96- if ( BonesCost > 0 )
111+ if ( BonesCost > 0 ) {
97112 yield return Singleton < ResourcesManager > . Instance . SpendBones ( BonesCost ) ;
113+ }
98114
99115 yield return new WaitForSeconds ( 0.1f ) ;
100116 yield return base . PreSuccessfulTriggerSequence ( ) ;
@@ -111,12 +127,28 @@ public sealed override IEnumerator OnActivatedAbility()
111127 yield break ;
112128 }
113129 }
114- if ( OnActivateEnergyCostMod != 0 )
115- energyCostMod += OnActivateEnergyCostMod ;
116- if ( OnActivateBonesCostMod != 0 )
117- bonesCostMod += OnActivateBonesCostMod ;
118- if ( OnActivateHealthCostMod != 0 )
119- healthCostMod += OnActivateHealthCostMod ;
130+ int energyMod = OnActivateEnergyCostMod ;
131+ int bonesMod = OnActivateBonesCostMod ;
132+ List < GemType > gemsMod = OnActivateGemsCostMod ;
133+ int healthMod = OnActivateHealthCostMod ;
134+
135+ if ( energyMod != 0 )
136+ energyCostMod += energyMod ;
137+
138+ if ( bonesMod != 0 )
139+ bonesCostMod += bonesMod ;
140+
141+ if ( gemsMod != null && gemsMod . Count > 0 ) {
142+ if ( OnActivateGemsCostModRemovesGems ) {
143+ gemsMod . ForEach ( x => gemsCostMod . Remove ( x ) ) ;
144+ }
145+ else {
146+ gemsCostMod . AddRange ( gemsMod ) ;
147+ }
148+ }
149+
150+ if ( healthMod != 0 )
151+ healthCostMod += healthMod ;
120152
121153 yield return PostActivate ( ) ;
122154 currentSacrificedCardInfos . Clear ( ) ;
@@ -220,14 +252,17 @@ private IEnumerator ChooseSacrifices()
220252 manager . currentSacrifices . Clear ( ) ;
221253 }
222254
223- private bool CanAfford ( )
224- {
225- if ( BloodCost <= 0 || SacrificeValue ( ) >= BloodCost )
226- {
227- if ( base . Card . Health >= HealthCost )
228- {
229- if ( Singleton < ResourcesManager > . Instance . PlayerEnergy >= EnergyCost )
230- return Singleton < ResourcesManager > . Instance . PlayerBones >= BonesCost ;
255+ private bool CanAfford ( ) {
256+ // if no blood cost or we can fulfill our blood cost
257+ if ( BloodCost < 1 || SacrificeValue ( ) >= BloodCost ) {
258+ // if we have enough health, Energy, and Bones
259+ if ( base . Card . Health >= HealthCost && ResourcesManager . Instance . PlayerEnergy >= EnergyCost && ResourcesManager . Instance . PlayerBones >= BonesCost ) {
260+ bool enoughOrange = ResourcesManagerHelpers . GemCount ( ! base . Card . OpponentCard , GemType . Orange ) >= GemsCost . Count ( x => x == GemType . Orange ) ;
261+ bool enoughGreen = ResourcesManagerHelpers . GemCount ( ! base . Card . OpponentCard , GemType . Green ) >= GemsCost . Count ( x => x == GemType . Green ) ;
262+ bool enoughBlue = ResourcesManagerHelpers . GemCount ( ! base . Card . OpponentCard , GemType . Blue ) >= GemsCost . Count ( x => x == GemType . Blue ) ;
263+
264+ // if we have enough gems
265+ return enoughOrange && enoughGreen && enoughBlue ;
231266 }
232267 }
233268 return false ;
0 commit comments