Skip to content
Merged
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 2.23.2
- Fixed error when trying to create cards that evolve/transform in 4 or more turns
- Fixed Fledgling and Transformer sigil appearing as black boxes when a card evolves/transform in 4 or more turns
- Fixed Part2VanillaCardCost event not being invoked
- Added 'UpdatePlayableCardCosts' event to community patch's Part1CardCostRender and Part2CardCostRender classes
- Added extension methods for PlayableCard and CardInfo: ProvidesBlueGem, ProvidesGreenGem, ProvidesOrangeGem
- Evolve and Transformer icons now support cards that evolve in 4 or more turns
- Wiki: added articles 'Other Features' and 'Triggers and the Order of Operations'
- Wiki: modified starting section of 'Custom Triggers' article
- Documentation: fixed description for IPostCardGettingAttacked stating it triggers before CardGettingAttacked

# 2.23.1
- Fixed non-CardModificationInfo shields not breaking
- Fixed ShieldGeneratorItem not correclty updating visuals
Expand Down
Binary file added InscryptionAPI/Assets/ability_evolve_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_evolve_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_evolve_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_transformer_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_transformer_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_transformer_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 32 additions & 6 deletions InscryptionAPI/Card/AbilityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private static List<FullAbility> GenBaseGameAbilityList()
}

List<FullAbility> baseGame = new();
var gameAsm = typeof(AbilityInfo).Assembly;
Assembly gameAsm = typeof(AbilityInfo).Assembly;
foreach (var ability in Resources.LoadAll<AbilityInfo>("Data/Abilities"))
{
string name = ability.ability.ToString();
Expand Down Expand Up @@ -719,18 +719,44 @@ private static IEnumerable<CodeInstruction> EvolveOnUpkeepPatches(IEnumerable<Co

return codes;
}
[HarmonyPrefix, HarmonyPatch(typeof(AbilityIconInteractable), nameof(AbilityIconInteractable.LoadIcon))]
private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInteractable __instance, CardInfo info, AbilityInfo ability) {
if (ability.ability == Ability.Transformer && info?.evolveParams?.turnsToEvolve > 1) {
__result = TextureHelper.GetImageAsTexture($"ability_transformer_{Mathf.Min(info.evolveParams.turnsToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly);
return false;
}
if (ability.ability == Ability.Evolve && info?.evolveParams?.turnsToEvolve > 3) {
__result = TextureHelper.GetImageAsTexture($"ability_evolve_{Mathf.Min(info.evolveParams.turnsToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly);
return false;
}
return true;
}
//[HarmonyPrefix, HarmonyPatch(typeof(AbilitiesUtil), nameof(AbilitiesUtil.LoadAbilityIcon))]
//private static bool OverrideEvolveAndTransformerIcon(ref Texture __result, string abilityName) {
// if (abilityName.StartsWith("Evolve") || abilityName.StartsWith("Transformer")) {
// return false;
// }
// return true;
//}
private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve)
{
if (evolve.Ability == Ability.Evolve)
{
evolve.Card.RenderInfo.OverrideAbilityIcon(
Ability.Evolve, ResourceBank.Get<Texture>("Art/Cards/AbilityIcons/ability_evolve_" + turnsLeftToEvolve)
);
if (turnsLeftToEvolve > 3) {
evolve.Card.RenderInfo.OverrideAbilityIcon(
Ability.Evolve, TextureHelper.GetImageAsTexture($"ability_evolve_{Mathf.Min(turnsLeftToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly)
);
}
else {
evolve.Card.RenderInfo.OverrideAbilityIcon(
Ability.Evolve, ResourceBank.Get<Texture>("Art/Cards/AbilityIcons/ability_evolve_" + turnsLeftToEvolve)
);
}
}
else if (evolve.Ability == Ability.Transformer && (evolve.Card.Info.evolveParams?.turnsToEvolve ?? 1) != 1)
{
evolve.Card.RenderInfo.OverrideAbilityIcon(
Ability.Transformer, TextureHelper.GetImageAsTexture($"ability_transformer_{turnsLeftToEvolve}.png", typeof(AbilityManager).Assembly)
Ability.Transformer, TextureHelper.GetImageAsTexture($"ability_transformer_{Mathf.Min(turnsLeftToEvolve, 6)}.png", InscryptionAPIPlugin.APIAssembly)
);
}
}
Expand Down Expand Up @@ -808,7 +834,7 @@ private static void LoadTransformerIcon(ref Texture __result, CardInfo info, Abi
if (turnsToEvolve <= 1)
return;

__result = TextureHelper.GetImageAsTexture($"ability_transformer_{turnsToEvolve}.png", typeof(AbilityManager).Assembly);
__result = TextureHelper.GetImageAsTexture($"ability_transformer_{turnsToEvolve}.png", InscryptionAPIPlugin.APIAssembly);
}
#endregion

Expand Down
5 changes: 3 additions & 2 deletions InscryptionAPI/Card/CardAppearanceBehaviourManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DiskCardGame;
using InscryptionAPI.Guid;
using System.Collections.ObjectModel;
using System.Reflection;

namespace InscryptionAPI.Card;

Expand Down Expand Up @@ -36,10 +37,10 @@ static CardAppearanceBehaviourManager()
private static List<FullCardAppearanceBehaviour> GenBaseGameAppearanceList()
{
List<FullCardAppearanceBehaviour> baseGame = new();
var gameAsm = typeof(CardAppearanceBehaviour).Assembly;
Assembly gameAsm = typeof(CardAppearanceBehaviour).Assembly;
foreach (CardAppearanceBehaviour.Appearance ability in Enum.GetValues(typeof(CardAppearanceBehaviour.Appearance)))
{
var name = ability.ToString();
string name = ability.ToString();
baseGame.Add(new FullCardAppearanceBehaviour(ability, gameAsm.GetType($"DiskCardGame.{name}")));
}
return baseGame;
Expand Down
50 changes: 50 additions & 0 deletions InscryptionAPI/Card/CardExtensionsCosts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,54 @@ public static bool OwnerHasBlueGem(this PlayableCard card)
return card.OpponentCard ? OpponentGemsManager.Instance.HasGem(GemType.Blue) : ResourcesManager.Instance.HasGem(GemType.Blue);
}
public static bool IsUsingBlueGem(this PlayableCard card) => card.IsGemified() && card.OwnerHasBlueGem();

/// <summary>
/// Determines if this card provides its owner with a blue gem.
/// </summary>
/// <param name="card">Card to check</param>
public static bool ProvidesBlueGem(this PlayableCard card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemBlue);
}
/// <summary>
/// Determines if this card provides its owner with a green gem.
/// </summary>
/// <param name="card">Card to check</param>
public static bool ProvidesGreenGem(this PlayableCard card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemGreen);
}
/// <summary>
/// Determines if this card provides its owner with a orange gem.
/// </summary>
/// <param name="card">Card to check</param>
public static bool ProvidesOrangeGem(this PlayableCard card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemOrange);
}

/// <summary>
/// Determines if this card provides its owner with a blue gem.
/// </summary>
/// <param name="card">CardInfo to check</param>
public static bool ProvidesBlueGem(this CardInfo card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemBlue);
}
/// <summary>
/// Determines if this card provides its owner with a green gem.
/// </summary>
/// <param name="card">CardInfo to check</param>
public static bool ProvidesGreenGem(this CardInfo card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemGreen);
}
/// <summary>
/// Determines if this card provides its owner with a orange gem.
/// </summary>
/// <param name="card">CardInfo to check</param>
public static bool ProvidesOrangeGem(this CardInfo card)
{
return card.HasAbility(Ability.GainGemTriple) || card.HasAbility(Ability.GainGemOrange);
}
}
72 changes: 36 additions & 36 deletions InscryptionAPI/Card/ShieldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public static class ShieldManager
public static List<FullAbility> AllShieldAbilities { get; internal set; } = new(AllAbilities);
public static List<AbilityInfo> AllShieldInfos { get; internal set; } = AllShieldAbilities.Select(x => x.Info).ToList();

/// <summary>
/// IEnumerator method that wraps BreakShield. Also contains code for triggering IShieldPreventedDamage and IShieldPreventedDamageInHand.
/// </summary>
/// <param name="target">Card getting attacked.</param>
/// <param name="damage">Damage being dealt.</param>
/// <param name="attacker">Card attacking the target.</param>
public static IEnumerator TriggerBreakShield(PlayableCard target, int damage, PlayableCard attacker)
{
//InscryptionAPIPlugin.Logger.LogDebug("[TriggerBreakShield] Begin");
Expand Down Expand Up @@ -51,6 +57,9 @@ public static IEnumerator TriggerBreakShield(PlayableCard target, int damage, Pl
/// The method used for when a shielded card is damaged. Includes extra parameters for modders looking to modify this further.
/// This method is only called when damage > 0 and the target has a shield.
/// </summary>
/// <param name="target">Card getting attacked.</param>
/// <param name="damage">Damage being dealt.</param>
/// <param name="attacker">Card attacking the target.</param>
public static void BreakShield(PlayableCard target, int damage, PlayableCard attacker)
{
DamageShieldBehaviour shield = Array.Find(target.GetComponents<DamageShieldBehaviour>(), x => x.HasShields());
Expand Down Expand Up @@ -189,42 +198,33 @@ private static List<Ability> HiddensOnlyRemoveStacks(List<Ability> abilities, Li
}
private static void CorrectHiddenAbilityRender(PlayableCard card)
{
//foreach (DamageShieldBehaviour com in card.GetComponents<DamageShieldBehaviour>().Where(x => x.initialised))
//{
// if (com.HasShields())
// {
// if (com.Ability.GetHideSingleStacks())
// {
// // if there are more hidden shields than there should be
// while (card.Status.hiddenAbilities.Count(x => x == com.Ability) > com.NumShields)
// {
// card.Status.hiddenAbilities.Remove(com.Ability);
// }
// }
// else
// {
// card.Status.hiddenAbilities.RemoveAll(x => x == com.Ability);
// }
// break;
// }
// else
// {
// if (com.Ability.GetHideSingleStacks())
// {
// int shieldsLost = com.StartingNumShields - com.NumShields;
// while (card.Status.hiddenAbilities.Count(x => x == com.Ability) < shieldsLost)
// {
// //Debug.Log($"{com.StartingNumShields} {com.NumShields} {shieldsLost} Add hidden");
// card.Status.hiddenAbilities.Add(com.Ability);
// }
// }
// else if (!card.Status.hiddenAbilities.Contains(com.Ability))
// {
// card.Status.hiddenAbilities.Add(com.Ability);
// }
// break;
// }
//}
/* foreach (DamageShieldBehaviour com in card.GetComponents<DamageShieldBehaviour>().Where(x => x.initialised)) {
if (com.HasShields()) {
if (com.Ability.GetHideSingleStacks()) {
// if there are more hidden shields than there should be
while (card.Status.hiddenAbilities.Count(x => x == com.Ability) > com.NumShields) {
card.Status.hiddenAbilities.Remove(com.Ability);
}
}
else {
card.Status.hiddenAbilities.RemoveAll(x => x == com.Ability);
}
break;
}
else {
if (com.Ability.GetHideSingleStacks()) {
int shieldsLost = com.StartingNumShields - com.NumShields;
while (card.Status.hiddenAbilities.Count(x => x == com.Ability) < shieldsLost) {
//Debug.Log($"{com.StartingNumShields} {com.NumShields} {shieldsLost} Add hidden");
card.Status.hiddenAbilities.Add(com.Ability);
}
}
else if (!card.Status.hiddenAbilities.Contains(com.Ability)) {
card.Status.hiddenAbilities.Add(com.Ability);
}
break;
}
}*/

if (card.Info.HasBrokenShieldPortrait() && card.RenderInfo.portraitOverride == card.Info.BrokenShieldPortrait() && card.HasShield())
{
Expand Down
5 changes: 3 additions & 2 deletions InscryptionAPI/Card/SpecialStatIconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using InscryptionAPI.Guid;
using InscryptionAPI.RuleBook;
using System.Collections.ObjectModel;
using System.Reflection;
using UnityEngine;

namespace InscryptionAPI.Card;
Expand Down Expand Up @@ -84,10 +85,10 @@ static StatIconManager()
private static List<FullStatIcon> GenBaseGameStatIconList()
{
List<FullStatIcon> baseGame = new();
var gameAsm = typeof(AbilityInfo).Assembly;
Assembly gameAsm = typeof(AbilityInfo).Assembly;
foreach (var staticon in Resources.LoadAll<StatIconInfo>("Data/staticons"))
{
var name = staticon.iconType.ToString();
string name = staticon.iconType.ToString();
SpecialTriggeredAbility ab = BASE_GAME_ABILITIES.ContainsKey(staticon.iconType) ? BASE_GAME_ABILITIES[staticon.iconType] : (SpecialTriggeredAbility)Enum.Parse(typeof(SpecialTriggeredAbility), staticon.iconType.ToString());
baseGame.Add(new FullStatIcon(staticon.iconType, ab, staticon, gameAsm.GetType($"DiskCardGame.{name}")));
}
Expand Down
5 changes: 3 additions & 2 deletions InscryptionAPI/Card/SpecialTriggeredAbilityManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DiskCardGame;
using InscryptionAPI.Guid;
using System.Collections.ObjectModel;
using System.Reflection;

namespace InscryptionAPI.Card;

Expand Down Expand Up @@ -45,10 +46,10 @@ static SpecialTriggeredAbilityManager()
private static List<FullSpecialTriggeredAbility> GenBaseGameSpecialTriggersList()
{
List<FullSpecialTriggeredAbility> baseGame = new();
var gameAsm = typeof(AbilityInfo).Assembly;
Assembly gameAsm = typeof(AbilityInfo).Assembly;
foreach (SpecialTriggeredAbility ability in Enum.GetValues(typeof(SpecialTriggeredAbility)))
{
var name = ability.ToString();
string name = ability.ToString();
baseGame.Add(new(null, name, ability, gameAsm.GetType($"DiskCardGame.{name}")));
}
return baseGame;
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Card/TribeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static Tribe Add(string guid, string name, Texture2D tribeIcon = null, bo
}
private static Texture2D MakePlaceholderCardback(Texture2D tribeIcon)
{
Texture2D emptyCardback = TextureHelper.GetImageAsTexture("empty_rewardCardBack.png", typeof(TribeManager).Assembly);
Texture2D emptyCardback = TextureHelper.GetImageAsTexture("empty_rewardCardBack.png", InscryptionAPIPlugin.APIAssembly);
if (tribeIcon == null) // if no tribe icon, return the empty card texture
return emptyCardback;

Expand Down
3 changes: 2 additions & 1 deletion InscryptionAPI/Encounters/AIManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DiskCardGame;
using InscryptionAPI.Guid;
using System.Collections.ObjectModel;
using System.Reflection;

namespace InscryptionAPI.Encounters;

Expand Down Expand Up @@ -36,7 +37,7 @@ static AIManager()
private static List<FullAI> GenBaseGameAIsList()
{
List<FullAI> baseGame = new();
var gameAsm = typeof(AI).Assembly;
Assembly gameAsm = typeof(AI).Assembly;
foreach (Type aiType in gameAsm.GetTypes().Where(type => type.IsSubclassOf(typeof(AI))))
{
baseGame.Add(new(aiType.Name, aiType));
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/Encounters/OpponentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}

List<FullOpponent> baseGame = new();
var gameAsm = typeof(Opponent).Assembly;
Assembly gameAsm = typeof(Opponent).Assembly;
foreach (Opponent.Type opponent in Enum.GetValues(typeof(Opponent.Type)))
{
string specialSequencerId = useReversePatch ? OriginalGetSequencerIdForBoss(opponent) : BossBattleSequencer.GetSequencerIdForBoss(opponent);
Expand Down Expand Up @@ -223,7 +223,7 @@
CodeInstruction codeInstruction = codes[i];
if (codeInstruction.opcode == OpCodes.Stfld)
{
if (codeInstruction.operand == bossTypeField)

Check warning on line 226 in InscryptionAPI/Encounters/OpponentManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'FieldInfo'
{
codes.Insert(++i, new CodeInstruction(OpCodes.Ldloc_0));
codes.Insert(++i, new CodeInstruction(OpCodes.Call, ProcessMethodInfo));
Expand Down Expand Up @@ -329,7 +329,7 @@

for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode == OpCodes.Ldstr && codes[i].operand == "knives_table_exit")

Check warning on line 332 in InscryptionAPI/Encounters/OpponentManager.cs

View workflow job for this annotation

GitHub Actions / build

Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string'
{

// ldstr "knives_table_exit"
Expand Down
3 changes: 2 additions & 1 deletion InscryptionAPI/Encounters/SpecialSequenceManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DiskCardGame;
using InscryptionAPI.Guid;
using System.Collections.ObjectModel;
using System.Reflection;

namespace InscryptionAPI.Encounters;

Expand Down Expand Up @@ -38,7 +39,7 @@ static SpecialSequenceManager()
private static List<FullSpecialSequencer> GenBaseGameSpecialSequencersList()
{
List<FullSpecialSequencer> baseGame = new();
var gameAsm = typeof(SpecialBattleSequencer).Assembly;
Assembly gameAsm = typeof(SpecialBattleSequencer).Assembly;
foreach (Type sequencer in gameAsm.GetTypes().Where(type => type.IsSubclassOf(typeof(SpecialBattleSequencer))))
{
baseGame.Add(new(sequencer.Name, sequencer));
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/InscryptionAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DebugType>full</DebugType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<Version>2.23.1</Version>
<Version>2.23.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
Loading
Loading