CardDataBuilder - rspforhp/WildfrostModdingDocumentation GitHub Wiki
CardDataBuilder(WildfrostMod mod)
- The builder for creating CardData: items, enemies, clunker, and companions.
- All vanilla cards can be found in references.
Below is how Wort could be coded using CardDataBuilder
//'this' refers to an instance of a WildfrostMod class
CardDataBuilder wort = new CardDataBuilder(this)
.CreateUnit(name: "Wort", englishTitle: "Wort", bloodProfile: "Blood Profile Fungus") // Only the first two parameters are necessary
.SetStats(6, 0, 3)
.SetSprites("Wort_mainSprite.png", "Wort_BG.png") // Images must be placed in a subfolder of the mod folder called "Images"
.WithPools("BasicUnitPool") // The "Basic" pools are actually the Snowdwellers' pools
.WithValue(45) // Gold dropped as an enemy is 1/36th of this, so `(int)(45/36) = 1` gold
.SubscribeToAfterAllBuildEvent(data =>
{
data.attackEffects = new CardData.StatusEffectStacks[]
{
new CardData.StatusEffectStacks(Get<StatusEffectData>("Shroom"), 2), // Applies 2 stacks of Shroom
};
data.startWithEffects = new CardData.StatusEffectStacks[]
{
new CardData.StatusEffectStacks(Get<StatusEffectData>("MultiHit"), 1), // Starts with 1 (additional) stack of Frenzy
};
data.traits = new CardData.TraitStacks[]
{
new CardData.TraitStacks(Get<TraitData>("Aimless"), 1), // Starts with Aimless. (Aimless doesn't stack so "1" can be any number)
};
});
//Note: making the builder is not the same as loading the CardData into the game. There is an additional step.
//See Tutorial 2.Typically, modded effects don't start loaded into the game -- SubscribeToAllAfterBuildEvent needs to be used when that is the case. The following code assumes the only effects on this card are base-game / were already forcefully loaded. You should rarely use these.
//'this' refers to an instance of a WildfrostMod class
CardDataBuilder wort = new CardDataBuilder(this)
.CreateUnit(name: "Wort", englishTitle: "Wort", bloodProfile: "Blood Profile Fungus") // Only the first two parameters are necessary
.SetStats(6, 0, 3)
.SetSprites("wort.png", "wortBG.png") // Images must be placed in a subfolder of the mod folder called "Images"
.WithValue(45) // Gold dropped as an enemy is 1/36th of this, so `(int)(45/36) = 1` gold
.SetAttackEffect(new CardData.StatusEffectStacks(Get<StatusEffectData>("Shroom"), 2))
.SetStartWithEffects(new CardData.StatusEffectStacks(Get<StatusEffectData>("MultiHit"),1))
.SetTraits(new CardData.TraitStacks(Get<TraitData>("Aimless"), 1))
.AddPool("BasicUnitPool"); // The "Basic" pools are actually the Snowdwellers' pools
//Note: making the builder is not the same as loading the CardData into the game. There is an additional step.
//See Tutorial 2.Some methods inherited from DataFileBuilder are not shown. They can be found on the Builders page. In addition, intermediate methods such as AsUnit, AsItem, SetHealth, SetAttack, and SetCounter are not listed here.
AddPool(string pool) or AddPool(RewardPool pool)
- Used to add your card to a pool (either unit pool or item pool)
-
poolis equal to "GeneralUnitPool" by default. General format is "[classname][datatype]Pool". - Available classname's are "General", "Snow", "Basic", "Magic", and "Clunk". (Snowdwellers is "Basic"!).
- Available datatype's are "Unit", "Item", and "Charm" .
- There is a variant that uses RewardPool as its first parameter.
CanBeHit(bool value = true)
- Used to set whether or not your card can be hit.
-
valueis equal to true by default (CreateItemchanges this to false).
CanBePlayedOnBoard(bool value = true)
- Used to set whether or not your card can be played on empty board spaces.
-
valueis equal to true by default for items (CreateItemchanges this to false).
CanPlayOnEnemy(bool value = true)
- Used to set whether or not your card can be played on enemies.
-
valueis equal to true by default for items.
CanBePlayedOnFriendly(bool value = true)
- Used to set whether or not your card can be played on friendly units (Companions, Leaders, Pets).
-
valueis equal to true by default for items.
CanBePlayedOnHand(bool value = true)
- Used to set whether or not your card can be played on cards in your hand.
-
valueis equal to false by default for items.
CanShoveToOtherRow(bool value = true)
- Used to set whether or not your card can push other cards to a different row when being played.
-
valueis equal to true by default.
Clone()
- Used to clone a CardData.
Create(string name)
- Used to create an empty CardData
-
nameis the internal name for your card the game uses. - It is recommended to use
CreateUnitorCreateIteminstead.
CreateItem(string name,string englishTitle, string targetMode="TargetModeBasic",string idleAnim="SwayAnimationProfile")
- Generates a simple item card that you can edit.
- By default, this item can be played on cards on the board but not in hand.
-
nameis the internal name for your card the game uses. -
englishTitleis the in-game display title for your card in the english localization. -
targetModeis the Target Mode that your card will use. Is "TargetModeBasic" by default, meaning the item will target the unit it's played on. -
idleAnimis the Idle Animation your card will use. is "SwayAnimationProfile' by default. See references.
CreateUnit(string name,string englishTitle, string targetMode="TargetModeBasic",string bloodProfile="BloodProfileNormal",string idleAnim="SwayAnimationProfile")
- Generates a simple unit card that you can edit.
-
nameis the internal name for your card the game uses. -
englishTitleis the in-game display title for your card in the english localization. -
targetModeis the target mode that your card will use. Is "TargetModeBasic" by default, meaning the unit will target the front-most enemy. Add certain traits to change the target mode. -
bloodProfileis the Blood Profile your card will use. is "Blood Profile Normal" by default. See references. -
idleAnimis the Idle Animation your card will use. is "SwayAnimationProfile' by default. See references.
IsCompanion(ChallengeData challenge, bool value)
- Used to set your card as an unlockable companion.
-
challengeis the ChallengeData of the challenge the player must complete to unlock the companion. -
valueis set to true by default and determines whether the companion is unlocked from the beginning or not.
IsItem(ChallengeData challenge, bool value)
- Used to set your card as an unlockable item.
-
challengeis the ChallengeData of the challenge the player must complete to unlock the item. -
valueis set to true by default and determines whether the item is unlocked from the beginning or not.
IsPet(string challenge, bool value) or IsPet(ChallengeData challenge, bool value)
- Used to set your card as an unlockable pet.
-
challengeis the name of the ChallengeData of the challenge the player must complete to unlock the pet. - There is a version of this method that uses the ChallengeData instead of its name as the first parameter.
- Setting the
valueto true will make the card a pet. - Setting the
challengeto null will automatically unlock the pet (a cast may be necessary to avoid ambiguity).
SetAttackEffect(params CardData.StatusEffectStacks[] stacks) or SetStartWithEffect(params CardData.StatusEffectStacks[] stacks)
- Warning: This cannot be used for or in conjunction with modded effects.
- Used to set the status effects your card applies (
SetAttackEffect) or the status effects currently applied to your card (SetStartWithEffect). - You can access a StatusEffectData by using
Get<StatusEffectData>(string name), from which you can get stacks by doingGet<StatusEffectData>(string name).StatusEffectStacks(int stacks). - You can assign several StatusEffectStacks by separating them with a comma (",").
- A list of status effects can be found in references.
SetNeedsTarget(bool value)
- Used to set whether or not your card needs a target to be played.
-
valueis equal to true by default.
SetSprites(string mainSprite, string backgroundSprite) or SetSprites(Sprite mainSprite, Sprite backgroundSprite)
- Used to set your Card's card art and background art
-
mainSpriteandbackgroundSpriteare the path to the main card art and background art respectively - Directory format for using this: Mods/ModName/images/test.png and Mods/ModName/images/testBackground.png ,
SetSprites(test.png, testBackground.png) - There is a variant that uses Sprites rather than their path strings.
- If your images folder is called something other than "images" you can reference them manually and use the version that uses Sprites instead of strings.
SetStats(int? health = null, int? damage = null, int counter = 0)
- Used to set your card's stats (health, damage, counter).
-
healthanddamagecorrespond to the Health and Attack stats of your card. They are set to null by default. Null Health means the card will have no Health stat (Useful for adding Scrap Health), Null Damage means the card will have no Attack stat (Useful for adding Teeth allies). -
counteris the Counter stat of your card. It is set to 0 by default. 0 Counter means the card will not trigger on a turn timer (Useful for adding event triggers). - The methods
SetHealth,SetAttack, andSetCounterare used as intermediate methods (not listed).
SetTraits(params CardData.TraitStacks[] stacks)
- Warning: This cannot be used for or in conjunction with modded traits.
- Used to set your card's traits.
- You can access a TraitData by using
Get<TraitData>(string name), from which you can get stacks by doingnew TraitStacks(Get<TraitData>(string name), int stacks. - You can assign several TraitStacks by separating them with a comma (",").
- A list of traits may be found in references.
SubscribeToAfterAllBuildEvent(AfterBuildDelegate d)
- Assigns a delegate
dthat is executed after all builders have built and loaded their respective data into the game (soGetcan now find them). - The build order is done alphabetically, so StatusEffects are built after CardData, warranting the need for this method.
WithBloodProfile(string bp = "Blood Profile Normal") or WithBloodProfile(BloodProfile bp)
- Used to set your card's Blood Profile.
-
bpis the Blood Profile your card will use, and is equal to "Blood Profile Normal" by default. - There is a variant that uses BloodProfile as its parameter.
- A list of blood profiles can be found in references.
- You can also create custom blood profiles, below is example code for creating a blood profile.
BloodProfile bloodProfileExample = ScriptableObject.CreateInstance<BloodProfile>();
bloodProfileExample.color = new Color(0.4f, 0.8f, 0.3f) //Put in whatever color you desire;
bloodProfileExample.splatterParticlePrefab = GetAsset<BloodProfile>("Blood Profile Normal").splatterParticlePrefab; //Copy from an existing Blood Profile
//Example code by semmiesem9WithCardType(string type = "Friendly") or WithCardType(CardType type)
- Used to set your card's type.
-
typeis the card type. It is set to "Friendly" by default. - A list of card types can be found in References.
WithDescription(string desc)
- Used to set your card's internal description.
- This will not be displayed anywhere. Use WithText instead.
WithFlavour(string flavour, SystemLanguage lang)
- Used to set your card's flavour text. Flavour text only appears if the card has no text or effects with descriptions.
-
langis the language in which your flavour text will show up, and is equal to SystemLanguage.English by default.
WithIdleAnimationProfile(string bp = "SwayAnimationProfile) or WithIdleAnimationProfile(CardAnimationProfile bp)
- Used to set your card's animation profile.
-
bpis equal to "SwayAnimationProfile" by default. - There is a variant that uses CardAnimationProfile as its parameter.
- A list of blood profiles can be found in references.
WithPlayType(Card.PlayType type)
- Used to set your card's play type.
- Card.PlayType is an enum which is defined as [None, Play, Place].
- The correct syntax for setting a playtype to Play would be .WithPlayType(Card.PlayType.Play).
WithPools(string[] pools) or WithPools(RewardPool[] pools)
- Used to add your card to a reward pool.
- You can input more than one pool, separated by a comma ",".
- There is a variant that uses RewardPool[] as its parameter.
WithTargetMode(string mode)
- Used to set your card's default target mode, unaffected by ink.
-
modeis set to "TargetModeBasic" by default. - There is a variant that uses TargetMode as its parameter.
- The base game never uses this and only applies the corresponding trait instead.
WithTitle(string title, SystemLanguage lang)
- Used to set your card's in-game title.
-
titleis what the card's in-game display title will be. -
langdefines what localization your card's title is to be used in and is equal to SystemLanguage.English by default.
WithText(string text, SystemLanguage lang)
- Used to manually add text to your card. (Some cards such as Ice Forge have effects without descriptions and use text instead).
-
langdefines what localization your card's title is to be used in and is equal to SystemLanguage.English by default.
WithValue(int price)
- Used to set your item's average price in the shop.
- On enemies, determines the amount of bling they drop when killed, calculated as 1/36th of their price rounded down.