11using System . Collections . Generic ;
2+ using System . Linq ;
3+ using CardLoaderPlugin . lib ;
24using DiskCardGame ;
35using UnityEngine ;
46
57namespace APIPlugin
68{
79 public static class NewCard
810 {
9- public static List < CardInfo > cards = new List < CardInfo > ( ) ;
11+ public static List < CardInfo > cards = new ( ) ;
1012
1113 public static Dictionary < int , List < AbilityIdentifier > > abilityIds = new ( ) ;
14+ public static Dictionary < int , List < SpecialAbilityIdentifier > > specialAbilityIds = new ( ) ;
1215 public static Dictionary < int , EvolveIdentifier > evolveIds = new ( ) ;
1316 public static Dictionary < int , IceCubeIdentifier > iceCubeIds = new ( ) ;
1417 public static Dictionary < int , TailIdentifier > tailIds = new ( ) ;
15-
18+
1619 public static void Add ( CardInfo card , List < AbilityIdentifier > abilityIdsParam = null ,
17- EvolveIdentifier evolveId = null , IceCubeIdentifier iceCubeId = null , TailIdentifier tailId = null
18- )
20+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam = null ,
21+ EvolveIdentifier evolveId = null ,
22+ IceCubeIdentifier iceCubeId = null , TailIdentifier tailId = null )
1923 {
2024 NewCard . cards . Add ( card ) ;
21- handleIdentifiers ( abilityIdsParam , evolveId , iceCubeId , tailId ) ;
25+ HandleIdentifiers ( card , abilityIdsParam , specialAbilitiesIdsParam , evolveId , iceCubeId , tailId ) ;
2226 Plugin . Log . LogInfo ( $ "Loaded custom card { card . name } !") ;
2327 }
2428
@@ -32,8 +36,8 @@ public static void Add(string name, string displayedName, int baseAttack, int ba
3236 int bloodCost = 0 , int bonesCost = 0 , int energyCost = 0 ,
3337 List < GemType > gemsCost = null , SpecialStatIcon specialStatIcon = SpecialStatIcon . None ,
3438 List < Tribe > tribes = null , List < Trait > traits = null , List < SpecialTriggeredAbility > specialAbilities = null ,
35- List < Ability > abilities = null , List < AbilityIdentifier > abilityIdsParam = null ,
36- EvolveParams evolveParams = null ,
39+ List < Ability > abilities = null , List < AbilityIdentifier > abilityIdsParam = null ,
40+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam = null , EvolveParams evolveParams = null ,
3741 string defaultEvolutionName = null , TailParams tailParams = null , IceCubeParams iceCubeParams = null ,
3842 bool flipPortraitForStrafe = false , bool onePerDeck = false ,
3943 List < CardAppearanceBehaviour . Appearance > appearanceBehaviour = null , Texture2D defaultTex = null ,
@@ -134,28 +138,60 @@ public static void Add(string name, string displayedName, int baseAttack, int ba
134138 card . titleGraphic = titleGraphic ;
135139 }
136140
137- NewCard . Add ( card , abilityIdsParam , evolveId , iceCubeId , tailId ) ;
141+ NewCard . cards . Add ( card ) ;
142+
143+ HandleIdentifiers ( card , abilityIdsParam , specialAbilitiesIdsParam , evolveId , iceCubeId , tailId ) ;
144+
145+ Plugin . Log . LogInfo ( $ "Loaded custom card { name } !") ;
138146 }
139147
140- private static void handleIdentifiers (
141- List < AbilityIdentifier > abilityIdsParam = null , EvolveIdentifier evolveId = null ,
142- IceCubeIdentifier iceCubeId = null , TailIdentifier tailId = null
143- )
148+ private static void HandleIdentifiers (
149+ CardInfo card ,
150+ List < AbilityIdentifier > abilityIdsParam ,
151+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam ,
152+ EvolveIdentifier evolveId ,
153+ IceCubeIdentifier iceCubeId ,
154+ TailIdentifier tailId )
144155 {
145- List < AbilityIdentifier > toRemove = new List < AbilityIdentifier > ( ) ;
156+ List < AbilityIdentifier > abilitiesToRemove = new List < AbilityIdentifier > ( ) ;
146157 if ( abilityIdsParam is not null )
147158 {
148- foreach ( AbilityIdentifier id in toRemove )
159+ foreach ( var id in abilityIdsParam . Where ( id => id . id != 0 ) )
160+ {
161+ card . abilities . Add ( id . id ) ;
162+ abilitiesToRemove . Add ( id ) ;
163+ }
164+
165+ foreach ( AbilityIdentifier id in abilitiesToRemove )
149166 {
150167 abilityIdsParam . Remove ( id ) ;
151168 }
169+
170+ if ( abilityIdsParam . Count > 0 )
171+ {
172+ NewCard . abilityIds [ NewCard . cards . Count - 1 ] = abilityIdsParam ;
173+ }
152174 }
153175
154- // Handle AbilityIdentifier
155-
156- if ( abilityIdsParam is not null && abilityIdsParam . Count > 0 )
176+ // Handle SpecialAbilityIds
177+ List < SpecialAbilityIdentifier > specialAbilitiesToRemove = new List < AbilityIdentifier > ( ) ;
178+ if ( specialAbilitiesIdsParam is not null )
157179 {
158- NewCard . abilityIds [ NewCard . cards . Count - 1 ] = abilityIdsParam ;
180+ foreach ( var id in specialAbilitiesIdsParam . Where ( id => id . id != 0 ) )
181+ {
182+ card . specialAbilities . Add ( id . id ) ;
183+ specialAbilitiesToRemove . Add ( id ) ;
184+ }
185+
186+ foreach ( SpecialAbilityIdentifier id in specialAbilitiesToRemove )
187+ {
188+ specialAbilitiesIdsParam . Remove ( id ) ;
189+ }
190+
191+ if ( specialAbilitiesIdsParam . Count > 0 )
192+ {
193+ NewCard . specialAbilityIds [ NewCard . cards . Count - 1 ] = specialAbilitiesIdsParam ;
194+ }
159195 }
160196
161197 // Handle EvolveIdentifier
0 commit comments