11using System . Collections . Generic ;
2+ using System . Linq ;
23using CardLoaderPlugin . lib ;
34using DiskCardGame ;
45using UnityEngine ;
@@ -7,17 +8,21 @@ namespace APIPlugin
78{
89 public static class NewCard
910 {
10- public static List < CardInfo > cards = new List < CardInfo > ( ) ;
11- public static Dictionary < int , List < AbilityIdentifier > > abilityIds = new Dictionary < int , List < AbilityIdentifier > > ( ) ;
12- public static Dictionary < int , EvolveIdentifier > evolveIds = new Dictionary < int , EvolveIdentifier > ( ) ;
13- public static Dictionary < int , IceCubeIdentifier > iceCubeIds = new Dictionary < int , IceCubeIdentifier > ( ) ;
14- public static Dictionary < int , TailIdentifier > tailIds = new Dictionary < int , TailIdentifier > ( ) ;
15-
16- public static void Add ( CardInfo card , List < AbilityIdentifier > abilityIds = null , EvolveIdentifier evolveId = null ,
11+ public static List < CardInfo > cards = new ( ) ;
12+
13+ public static Dictionary < int , List < AbilityIdentifier > > abilityIds = new ( ) ;
14+ public static Dictionary < int , List < SpecialAbilityIdentifier > > specialAbilityIds = new ( ) ;
15+ public static Dictionary < int , EvolveIdentifier > evolveIds = new ( ) ;
16+ public static Dictionary < int , IceCubeIdentifier > iceCubeIds = new ( ) ;
17+ public static Dictionary < int , TailIdentifier > tailIds = new ( ) ;
18+
19+ public static void Add ( CardInfo card , List < AbilityIdentifier > abilityIdsParam = null ,
20+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam = null ,
21+ EvolveIdentifier evolveId = null ,
1722 IceCubeIdentifier iceCubeId = null , TailIdentifier tailId = null )
1823 {
1924 NewCard . cards . Add ( card ) ;
20- handleIdentifiers ( card , abilityIds , evolveId , iceCubeId , tailId ) ;
25+ HandleIdentifiers ( card , abilityIdsParam , specialAbilitiesIdsParam , evolveId , iceCubeId , tailId ) ;
2126 Plugin . Log . LogInfo ( $ "Loaded custom card { card . name } !") ;
2227 }
2328
@@ -30,7 +35,8 @@ public static void Add(string name, List<CardMetaCategory> metaCategories, CardC
3035 bool hideAttackAndHealth = false , int cost = 0 , int bonesCost = 0 , int energyCost = 0 ,
3136 List < GemType > gemsCost = null , SpecialStatIcon specialStatIcon = SpecialStatIcon . None ,
3237 List < Tribe > tribes = null , List < Trait > traits = null , List < SpecialTriggeredAbility > specialAbilities = null ,
33- List < Ability > abilities = null , List < AbilityIdentifier > abilityIds = null , EvolveParams evolveParams = null ,
38+ List < Ability > abilities = null , List < AbilityIdentifier > abilityIdsParam = null ,
39+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam = null , EvolveParams evolveParams = null ,
3440 string defaultEvolutionName = null , TailParams tailParams = null , IceCubeParams iceCubeParams = null ,
3541 bool flipPortraitForStrafe = false , bool onePerDeck = false ,
3642 List < CardAppearanceBehaviour . Appearance > appearanceBehaviour = null , Texture2D tex = null ,
@@ -133,33 +139,51 @@ public static void Add(string name, List<CardMetaCategory> metaCategories, CardC
133139
134140 NewCard . cards . Add ( card ) ;
135141
136- handleIdentifiers ( card , abilityIds , evolveId , iceCubeId , tailId ) ;
142+ HandleIdentifiers ( card , abilityIdsParam , specialAbilitiesIdsParam , evolveId , iceCubeId , tailId ) ;
137143
138144 Plugin . Log . LogInfo ( $ "Loaded custom card { name } !") ;
139145 }
140146
141- private static void handleIdentifiers ( CardInfo card , List < AbilityIdentifier > abilityIds , EvolveIdentifier evolveId ,
142- IceCubeIdentifier iceCubeId , TailIdentifier tailId )
147+ private static void HandleIdentifiers (
148+ CardInfo card ,
149+ List < AbilityIdentifier > abilityIdsParam ,
150+ List < SpecialAbilityIdentifier > specialAbilitiesIdsParam ,
151+ EvolveIdentifier evolveId ,
152+ IceCubeIdentifier iceCubeId ,
153+ TailIdentifier tailId )
143154 {
144155 // Handle AbilityIdentifier
145156 List < AbilityIdentifier > toRemove = new List < AbilityIdentifier > ( ) ;
146- if ( abilityIds is not null )
157+ if ( abilityIdsParam is not null )
147158 {
148- foreach ( AbilityIdentifier id in abilityIds )
159+ foreach ( var id in abilityIdsParam . Where ( id => id . id != 0 ) )
149160 {
150- if ( id . id != 0 )
151- {
152- card . abilities . Add ( id . id ) ;
153- }
161+ card . abilities . Add ( id . id ) ;
154162 }
163+
155164 foreach ( AbilityIdentifier id in toRemove )
156165 {
157- abilityIds . Remove ( id ) ;
166+ abilityIdsParam . Remove ( id ) ;
167+ }
168+
169+ if ( abilityIdsParam . Count > 0 )
170+ {
171+ NewCard . abilityIds [ NewCard . cards . Count - 1 ] = abilityIdsParam ;
158172 }
159173 }
160- if ( abilityIds is not null && abilityIds . Count > 0 )
174+
175+ // Handle SpecialAbilityIds
176+ if ( specialAbilitiesIdsParam is not null )
161177 {
162- NewCard . abilityIds [ NewCard . cards . Count - 1 ] = abilityIds ;
178+ foreach ( var id in specialAbilitiesIdsParam . Where ( id => id . id != 0 ) )
179+ {
180+ card . specialAbilities . Add ( id . id ) ;
181+ }
182+
183+ if ( specialAbilitiesIdsParam . Count > 0 )
184+ {
185+ NewCard . specialAbilityIds [ NewCard . cards . Count - 1 ] = specialAbilitiesIdsParam ;
186+ }
163187 }
164188
165189 // Handle EvolveIdentifier
@@ -209,9 +233,10 @@ private static void DetermineAndSetCardArt(
209233 pixelTex . name = newName ;
210234 pixelTex . filterMode = FilterMode . Point ;
211235
212- card . pixelPortrait = Sprite . Create ( pixelTex , CardUtils . DefaultCardPixelArtRect , CardUtils . DefaultVector2 ) ;
236+ card . pixelPortrait =
237+ Sprite . Create ( pixelTex , CardUtils . DefaultCardPixelArtRect , CardUtils . DefaultVector2 ) ;
213238 card . pixelPortrait . name = newName ;
214239 }
215240 }
216241 }
217- }
242+ }
0 commit comments