CardDataBuilder - rspforhp/WildfrostModdingDocumentation GitHub Wiki

CardDataBuilder

CardDataBuilder(WildfrostMod mod)

  • The builder for creating CardData: items, enemies, clunker, and companions.
  • All vanilla cards can be found in references.

Example

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.

Methods

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

AddPool(string pool) or AddPool(RewardPool pool)

  • Used to add your card to a pool (either unit pool or item pool)
  • pool is 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

CanBeHit(bool value = true)

  • Used to set whether or not your card can be hit.
  • value is equal to true by default (CreateItem changes this to false).

CanPlayOnBoard

CanBePlayedOnBoard(bool value = true)

  • Used to set whether or not your card can be played on empty board spaces.
  • value is equal to true by default for items (CreateItem changes this to false).

CanPlayOnEnemy

CanPlayOnEnemy(bool value = true)

  • Used to set whether or not your card can be played on enemies.
  • value is equal to true by default for items.

CanPlayOnFriendly

CanBePlayedOnFriendly(bool value = true)

  • Used to set whether or not your card can be played on friendly units (Companions, Leaders, Pets).
  • value is equal to true by default for items.

CanPlayOnHand

CanBePlayedOnHand(bool value = true)

  • Used to set whether or not your card can be played on cards in your hand.
  • value is equal to false by default for items.

CanShoveToOtherRow

CanShoveToOtherRow(bool value = true)

  • Used to set whether or not your card can push other cards to a different row when being played.
  • value is equal to true by default.

Clone

Clone()

  • Used to clone a CardData.

Create (Inherited from DataFileBuilder)

Create(string name)

  • Used to create an empty CardData
  • name is the internal name for your card the game uses.
  • It is recommended to use CreateUnit or CreateItem instead.

CreateItem

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.
  • name is the internal name for your card the game uses.
  • englishTitle is the in-game display title for your card in the english localization.
  • targetMode is the Target Mode that your card will use. Is "TargetModeBasic" by default, meaning the item will target the unit it's played on.
  • idleAnim is the Idle Animation your card will use. is "SwayAnimationProfile' by default. See references.

CreateUnit

CreateUnit(string name,string englishTitle, string targetMode="TargetModeBasic",string bloodProfile="BloodProfileNormal",string idleAnim="SwayAnimationProfile")

  • Generates a simple unit card that you can edit.
  • name is the internal name for your card the game uses.
  • englishTitle is the in-game display title for your card in the english localization.
  • targetMode is 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.
  • bloodProfile is the Blood Profile your card will use. is "Blood Profile Normal" by default. See references.
  • idleAnim is the Idle Animation your card will use. is "SwayAnimationProfile' by default. See references.

IsCompanion

IsCompanion(ChallengeData challenge, bool value)

  • Used to set your card as an unlockable companion.
  • challenge is the ChallengeData of the challenge the player must complete to unlock the companion.
  • value is set to true by default and determines whether the companion is unlocked from the beginning or not.

IsItem

IsItem(ChallengeData challenge, bool value)

  • Used to set your card as an unlockable item.
  • challenge is the ChallengeData of the challenge the player must complete to unlock the item.
  • value is set to true by default and determines whether the item is unlocked from the beginning or not.

IsPet

IsPet(string challenge, bool value) or IsPet(ChallengeData challenge, bool value)

  • Used to set your card as an unlockable pet.
  • challenge is 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 value to true will make the card a pet.
  • Setting the challenge to null will automatically unlock the pet (a cast may be necessary to avoid ambiguity).

SetAttackEffects and SetStartWithEffect [Don't use]

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 doing Get<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

SetNeedsTarget(bool value)

  • Used to set whether or not your card needs a target to be played.
  • value is equal to true by default.

SetSprites

SetSprites(string mainSprite, string backgroundSprite) or SetSprites(Sprite mainSprite, Sprite backgroundSprite)

  • Used to set your Card's card art and background art
  • mainSprite and backgroundSprite are 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

SetStats(int? health = null, int? damage = null, int counter = 0)

  • Used to set your card's stats (health, damage, counter).
  • health and damage correspond 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).
  • counter is 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, and SetCounter are used as intermediate methods (not listed).

SetTraits [Don't use]

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 doing new 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.

SubscribeToAfterAllBuildEvents (Inherited from DataFileBuilder)

SubscribeToAfterAllBuildEvent(AfterBuildDelegate d)

  • Assigns a delegate d that is executed after all builders have built and loaded their respective data into the game (so Get can now find them).
  • The build order is done alphabetically, so StatusEffects are built after CardData, warranting the need for this method.

WithBloodProfile

WithBloodProfile(string bp = "Blood Profile Normal") or WithBloodProfile(BloodProfile bp)

  • Used to set your card's Blood Profile.
  • bp is 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 semmiesem9

WithCardType

WithCardType(string type = "Friendly") or WithCardType(CardType type)

  • Used to set your card's type.
  • type is the card type. It is set to "Friendly" by default.
  • A list of card types can be found in References.

WithDescription [Unused]

WithDescription(string desc)

  • Used to set your card's internal description.
  • This will not be displayed anywhere. Use WithText instead.

WithFlavour

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.
  • lang is the language in which your flavour text will show up, and is equal to SystemLanguage.English by default.

WithIdleAnimationProfile

WithIdleAnimationProfile(string bp = "SwayAnimationProfile) or WithIdleAnimationProfile(CardAnimationProfile bp)

  • Used to set your card's animation profile.
  • bp is 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

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

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

WithTargetMode(string mode)

  • Used to set your card's default target mode, unaffected by ink.
  • mode is 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

WithTitle(string title, SystemLanguage lang)

  • Used to set your card's in-game title.
  • title is what the card's in-game display title will be.
  • lang defines what localization your card's title is to be used in and is equal to SystemLanguage.English by default.

WithText

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).
  • lang defines what localization your card's title is to be used in and is equal to SystemLanguage.English by default.

WithValue

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.
⚠️ **GitHub.com Fallback** ⚠️