- Defined in:
A Card Mod (short for "module" or "modification") is a discrete piece of Decko functionality. Mods are how the Decko community develops and shares code. If you want to customize a deck in a way that can't be done on the site itself, try a mod.
The simplest way to add a mod is to run this command in your deck:
decko generate card:mod MOD_NAME
This will create the following directories:
DECK_NAME/mod/MOD_NAME DECK_NAME/mod/MOD_NAME/lib DECK_NAME/mod/MOD_NAME/public DECK_NAME/mod/MOD_NAME/set
The lib directory contains libraries, of course. And files in the public directory are public and served directly.
But in most mods, the focal point is the set directory.
Set modules define methods for a given set of cards and their format objects. They are defined in a mod's set directory. For example, suppose you've created a mod that called biz, your deck has Company cards, and you want to extend the behavior of those cards.
You can add a set module like so:
decko generate set biz type company
This will create the following two files:
If you would like to break this code into smaller files, you can extend this pattern into another directory, eg:
The general pattern can be expressed as follows:
- introduces card objects
- provides an overview of how set modules work
- explains the basics of the format API
- explains the basics of the view definition API
- explains the basics of the event API
Other ways your mod can extend Decko functionality include:
- format for creating new formats (think file extensions)
- set_pattern for additional , or types of sets.
- chunk provides tools for finding new patterns in card content
- file for fixed initial card content
Defined Under Namespace
Classes:, , , ,
Class Method Summary collapse
Class Method Details
.dirs ⇒ Object
80 81 82
# File 'lib/card/mod.rb', line 80 def dirs @dirs ||= Dirs.new(Card.paths["mod"].existent) end
.load ⇒ Object
69 70 71 72 73 74 75 76 77
# File 'lib/card/mod.rb', line 69 def load return if ENV["CARD_MODS"] == "none" if Card.take Loader.load_mods else Rails.logger.warn "empty database" end end