Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.23.4
- Fixed GemsDraw only considering the player's slots when determining how many cards to draw
- Fixed Act 2 Tutor sequence softlocking when there are no cards to display
- Fixed Act 2 Tutor sequence not displaying cards when you have less than 7 cards remaining in your deck
- Fixed Gemify affecting Blood cost when it shouldn't
- Added Gems Cost support for ExtendedActivatedAbilityBehaviour class
- Added extension AbilityManager.FullAbility.FlipYIfOpponent
- Add config option to prevent Act 1 card emissions from rendering above the play costs

# 2.23.3
- Fixed custom deck exhaust sequence not performing the requisite checks
- Added 'CanAppearRandomly' bool and associated extension method for custom regions
Expand Down
10 changes: 10 additions & 0 deletions InscryptionAPI/Card/AbilityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,16 @@ public static AbilityInfo SetFlipYIfOpponent(this AbilityInfo abilityInfo, bool
return abilityInfo;
}
/// <summary>
/// Sets whether or not the ability's icon should be flipped upside-down when it's on an opponent card.
/// </summary>
/// <param name="abilityInfo">The instance of AbilityInfo.</param>
/// <param name="flipY">If the icon should be flipped.</param>
/// <returns>The same AbilityInfo so a chain can continue.</returns>
public static FullAbility SetFlipYIfOpponent(this FullAbility fullAbility, bool flipY = true) {
fullAbility.Info.SetFlipYIfOpponent(flipY);
return fullAbility;
}
/// <summary>
/// Sets whether or not the ability's icon's colour should be overridden, and what the override colour should be.
/// The colour override only applies to the default ability icons; totem and merge icons are unaffected.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Card/CostProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static List<GemType> ImprovedGemsCost(CardInfo instance)

public static bool ReduceGemifiedBlood(PlayableCard card, int? bloodCost = null)
{
return (bloodCost ?? OriginalBloodCost(card.Info)) > 0 && !ReduceGemifiedMox(card) && !ReduceGemifiedBones(card) && !ReduceGemifiedMox(card);
return (bloodCost ?? OriginalBloodCost(card.Info)) > 0 && !ReduceGemifiedEnergy(card) && !ReduceGemifiedBones(card) && !ReduceGemifiedMox(card);
}
public static bool ReduceGemifiedMox(PlayableCard card, List<GemType> gemsCost = null)
{
Expand Down
64 changes: 50 additions & 14 deletions InscryptionAPI/Card/DamageShieldBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DiskCardGame;
using GBC;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using System.Collections;
using UnityEngine;
Expand Down Expand Up @@ -87,20 +88,34 @@ public abstract class ActivatedDamageShieldBehaviour : DamageShieldBehaviour
public int bloodCostMod;
public int bonesCostMod;
public int energyCostMod;
public List<GemType> gemsCostMod;
public int healthCostMod;

public virtual int StartingBloodCost { get; }
public virtual int StartingBonesCost { get; }
public virtual int StartingEnergyCost { get; }
public virtual List<GemType> StartingGemsCost { get; }
public virtual int StartingHealthCost { get; }
public virtual int OnActivateBloodCostMod { get; set; }
public virtual int OnActivateBonesCostMod { get; set; }
public virtual int OnActivateEnergyCostMod { get; set; }
public virtual List<GemType> OnActivateGemsCostMod { get; set; }
public virtual bool OnActivateGemsCostModRemovesGems { get; set; }
public virtual int OnActivateHealthCostMod { get; set; }

public int BloodCost => Mathf.Max(0, StartingBloodCost + bloodCostMod);
public int BonesCost => Mathf.Max(0, StartingBonesCost + bonesCostMod);
public int EnergyCost => Mathf.Max(0, StartingEnergyCost + energyCostMod);
public List<GemType> GemsCost {
get {
List<GemType> retval = new();
if (StartingGemsCost != null && StartingGemsCost.Count > 0) {
retval.AddRange(StartingGemsCost);
}
retval.AddRange(gemsCostMod);
return retval;
}
}
public int HealthCost => Mathf.Max(0, StartingHealthCost + healthCostMod);

public Dictionary<CardInfo, CardSlot> currentSacrificedCardInfos = new();
Expand Down Expand Up @@ -187,12 +202,29 @@ public sealed override IEnumerator OnActivatedAbility()
yield break;
}
}
if (OnActivateEnergyCostMod != 0)
energyCostMod += OnActivateEnergyCostMod;
if (OnActivateBonesCostMod != 0)
bonesCostMod += OnActivateBonesCostMod;
if (OnActivateHealthCostMod != 0)
healthCostMod += OnActivateHealthCostMod;

int energyMod = OnActivateEnergyCostMod;
int bonesMod = OnActivateBonesCostMod;
List<GemType> gemsMod = OnActivateGemsCostMod;
int healthMod = OnActivateHealthCostMod;

if (energyMod != 0)
energyCostMod += energyMod;

if (bonesMod != 0)
bonesCostMod += bonesMod;

if (gemsMod != null && gemsMod.Count > 0) {
if (OnActivateGemsCostModRemovesGems) {
gemsMod.ForEach(x => gemsCostMod.Remove(x));
}
else {
gemsCostMod.AddRange(gemsMod);
}
}

if (healthMod != 0)
healthCostMod += healthMod;

yield return PostActivate();
currentSacrificedCardInfos.Clear();
Expand Down Expand Up @@ -296,18 +328,22 @@ private IEnumerator ChooseSacrifices()
manager.currentSacrifices.Clear();
}

private bool CanAfford()
{
if (BloodCost <= 0 || SacrificeValue() >= BloodCost)
{
if (base.Card.Health >= HealthCost)
{
if (Singleton<ResourcesManager>.Instance.PlayerEnergy >= EnergyCost)
return Singleton<ResourcesManager>.Instance.PlayerBones >= BonesCost;
private bool CanAfford() {
// if no blood cost or we can fulfill our blood cost
if (BloodCost < 1 || SacrificeValue() >= BloodCost) {
// if we have enough health, Energy, and Bones
if (base.Card.Health >= HealthCost && ResourcesManager.Instance.PlayerEnergy >= EnergyCost && ResourcesManager.Instance.PlayerBones >= BonesCost) {
bool enoughOrange = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Orange) >= GemsCost.Count(x => x == GemType.Orange);
bool enoughGreen = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Green) >= GemsCost.Count(x => x == GemType.Green);
bool enoughBlue = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Blue) >= GemsCost.Count(x => x == GemType.Blue);

// if we have enough gems
return enoughOrange && enoughGreen && enoughBlue;
}
}
return false;
}

private bool LearnMechanic() => SaveManager.SaveFile.IsPart2 && !ProgressionData.LearnedMechanic(MechanicsConcept.GBCActivatedAbilities);
private int SacrificeValue()
{
Expand Down
65 changes: 50 additions & 15 deletions InscryptionAPI/Card/ExtendedActivatedAbilityBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DiskCardGame;
using GBC;
using HarmonyLib;
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using System.Collections;
using UnityEngine;
Expand All @@ -11,20 +12,34 @@ public abstract class ExtendedActivatedAbilityBehaviour : AbilityBehaviour
public int bloodCostMod;
public int bonesCostMod;
public int energyCostMod;
public List<GemType> gemsCostMod = new();
public int healthCostMod;

public virtual int StartingBloodCost { get; }
public virtual int StartingBonesCost { get; }
public virtual int StartingEnergyCost { get; }
public virtual List<GemType> StartingGemsCost { get; }
public virtual int StartingHealthCost { get; }
public virtual int OnActivateBloodCostMod { get; set; }
public virtual int OnActivateBonesCostMod { get; set; }
public virtual int OnActivateEnergyCostMod { get; set; }
public virtual List<GemType> OnActivateGemsCostMod { get; set; }
public virtual bool OnActivateGemsCostModRemovesGems { get; set; }
public virtual int OnActivateHealthCostMod { get; set; }

public int BloodCost => Mathf.Max(0, StartingBloodCost + bloodCostMod);
public int BonesCost => Mathf.Max(0, StartingBonesCost + bonesCostMod);
public int EnergyCost => Mathf.Max(0, StartingEnergyCost + energyCostMod);
public List<GemType> GemsCost {
get {
List<GemType> retval = new();
if (StartingGemsCost != null && StartingGemsCost.Count > 0) {
retval.AddRange(StartingGemsCost);
}
retval.AddRange(gemsCostMod);
return retval;
}
}
public int HealthCost => Mathf.Max(0, StartingHealthCost + healthCostMod);

public Dictionary<CardInfo, CardSlot> currentSacrificedCardInfos = new();
Expand Down Expand Up @@ -93,8 +108,9 @@ public sealed override IEnumerator OnActivatedAbility()
}
}
}
if (BonesCost > 0)
if (BonesCost > 0) {
yield return Singleton<ResourcesManager>.Instance.SpendBones(BonesCost);
}

yield return new WaitForSeconds(0.1f);
yield return base.PreSuccessfulTriggerSequence();
Expand All @@ -111,12 +127,28 @@ public sealed override IEnumerator OnActivatedAbility()
yield break;
}
}
if (OnActivateEnergyCostMod != 0)
energyCostMod += OnActivateEnergyCostMod;
if (OnActivateBonesCostMod != 0)
bonesCostMod += OnActivateBonesCostMod;
if (OnActivateHealthCostMod != 0)
healthCostMod += OnActivateHealthCostMod;
int energyMod = OnActivateEnergyCostMod;
int bonesMod = OnActivateBonesCostMod;
List<GemType> gemsMod = OnActivateGemsCostMod;
int healthMod = OnActivateHealthCostMod;

if (energyMod != 0)
energyCostMod += energyMod;

if (bonesMod != 0)
bonesCostMod += bonesMod;

if (gemsMod != null && gemsMod.Count > 0) {
if (OnActivateGemsCostModRemovesGems) {
gemsMod.ForEach(x => gemsCostMod.Remove(x));
}
else {
gemsCostMod.AddRange(gemsMod);
}
}

if (healthMod != 0)
healthCostMod += healthMod;

yield return PostActivate();
currentSacrificedCardInfos.Clear();
Expand Down Expand Up @@ -220,14 +252,17 @@ private IEnumerator ChooseSacrifices()
manager.currentSacrifices.Clear();
}

private bool CanAfford()
{
if (BloodCost <= 0 || SacrificeValue() >= BloodCost)
{
if (base.Card.Health >= HealthCost)
{
if (Singleton<ResourcesManager>.Instance.PlayerEnergy >= EnergyCost)
return Singleton<ResourcesManager>.Instance.PlayerBones >= BonesCost;
private bool CanAfford() {
// if no blood cost or we can fulfill our blood cost
if (BloodCost < 1 || SacrificeValue() >= BloodCost) {
// if we have enough health, Energy, and Bones
if (base.Card.Health >= HealthCost && ResourcesManager.Instance.PlayerEnergy >= EnergyCost && ResourcesManager.Instance.PlayerBones >= BonesCost) {
bool enoughOrange = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Orange) >= GemsCost.Count(x => x == GemType.Orange);
bool enoughGreen = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Green) >= GemsCost.Count(x => x == GemType.Green);
bool enoughBlue = ResourcesManagerHelpers.GemCount(!base.Card.OpponentCard, GemType.Blue) >= GemsCost.Count(x => x == GemType.Blue);

// if we have enough gems
return enoughOrange && enoughGreen && enoughBlue;
}
}
return false;
Expand Down
Loading
Loading