18 Making a card type
LunarTides edited this page 2026-01-12 08:59:05 +01:00

Warning

Most of this no longer applies as of 4.0.0. An updated version of this wiki is in progress: https://hs.lunartides.dev (#447)

Creating a card type:

This page is likely outdated since it hasn't been updated in a while.

This is one of the most complicated things you can do.

See c4cb7b3 for an example of a card type being added.

Updating types

  1. Add the card type to the CardType type in src/types.ts.
  2. Add any card type specific fields to the Blueprint type in src/types.ts. E.g. example?: number after hpCost?: number
  3. Add any card type specific abilities to the CardAbilityReal in src/types.ts

Updating card creators

  1. Add a default ability for the card type in cardcreator/lib.ts:getCardAbility
  2. Add a function for creating the card type in cardcreator/custom.ts:cardTypeFunctions. Just copy an existing one, like Location() and change it. (make sure it follows the naming convention. the name of the type, capitalized.)
  3. If the card type exists in vanilla Hearthstone, add code for it in cardcreator/vanilla.ts:create.

Other

  1. Add any card type specific fields to the Card class in src/core/card.ts. For example, example?: number after cooldown?: number = 2.
  2. Add code for playing the card in src/core/game.ts:playCard:typeSpecific. Copy and paste, for example, Minion and change it to do the code you want. (make sure it follows the naming convention. the name of the type, capitalized.)
  3. If the card is going on the board, update src/core/card.ts:canBeOnBoard
  4. Add it to src/helper/validator.ts:requiredFieldsTable. If your type has no specific required field, just add "[name of type]": [],. Otherwise, something like this: "Test": ["stats", "example"],. (Only include "stats" if the card type has stats)
  5. Add code for it in src/core/interact/card.ts:getReadable.

Optional

  1. Add an example card for it.
  2. Add a card type specific command. See the use command for an example of how to do this.
  3. Add code for it in src/core/ai.ts. (This is optional since it is hard. By default, the ai will treat the type as a Minion if it is in canBeOnBoard, and as a Spell otherwise.)

Conclusion

Congratulations! You now have a basic card type. Of course, at this state the type doesn't do anything special. If you want the type to do more special things, you will have to basically mod the game. Feel free to use the discussions tab to ask for help.