@flesh-and-blood/types 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,184 +1,65 @@
1
- # Flesh and Blood cards
1
+ # @flesh-and-blood/types
2
2
 
3
- - [Overview & installation](#overview-and-installation)
4
- - [Card interfaces](#card-interfaces)
5
- - [Enums](#enums)
6
- - [Working with this project](#working-with-this-project)
3
+ TypeScript enums, interfaces, and pure helper functions for **Flesh and Blood** cards. This is the base
4
+ package that [`@flesh-and-blood/cards`](../cards) and [`@flesh-and-blood/search`](../search) depend on.
5
+ It has no runtime dependencies.
7
6
 
8
- # 8.0 breaking changes
7
+ ## Installation
9
8
 
10
- - `card.images` has been deprecated in favor of `card.printings`
11
- - `defaultImageName` has been renamed `defaultImage` for brevity
12
- - `specialImageName` has been renamed `specialImage` for brevity
13
-
14
- # 7.0 breaking changes
15
-
16
- - `card.rarity` has been deprecated in favor of `card.rarities`
17
-
18
- ## Overview and installation
19
-
20
- A library of all Flesh and Blood cards, available as a bundled TypeScript file with matching interfaces. Source data comes from the amazing [the-fab-cube/flesh-and-blood-cards](https://github.com/the-fab-cube/flesh-and-blood-cards) repository maintained by [Tyler Luce](https://github.com/luceleaftea) - all credit goes to him, and all errors are probably added by me in this project 😅.
21
-
22
- To install run `npm i --save fab-cards`.
23
-
24
- Access the card data in your project:
25
-
26
- ```ts
27
- import { cards } from "fab-cards";
28
-
29
- cards.forEach((card) => {
30
- // do stuff with the card data
31
- });
9
+ ```bash
10
+ npm i @flesh-and-blood/types
32
11
  ```
33
12
 
34
- ## Card interfaces
35
-
36
- **`Card`** contains all of the fields that could show up for any particular card. Required fields can be found on every card, while optional fields may or may not exist on any given card.
37
-
38
- ### Required
39
-
40
- | Field | Data type | Examples |
41
- | -------------- | -------------------- | ------------------------------------------ |
42
- | artists | `string` array | `[ "Riordan Delmiro" ]` |
43
- | cardIdentifier | `string` | `"snatch-red"`, `"aether-wildfire-red"` |
44
- | classes | `Class` enum array | `["Generic"]`, `["Warrior","Wizard"]` |
45
- | defaultImage | `string` | `"1HP001.width-450"` |
46
- | printings | `Printing` array | see **`Printing`** |
47
- | name | `string` | `"Rain Razors"`, `"Pummel"` |
48
- | rarities | `Rarity` enum array | `["Super Rare"]`, `["Token", "Majestic"]` |
49
- | setIdentifiers | `string` array | `[ "1HP009", "CRU006" ]` |
50
- | sets | `Release` enum array | `[ "History Pack 1", "Crucible of War" ]` |
51
- | specialImage | `string` | `"1HP001.width-450"` |
52
- | subtypes | `Subtype` enum array | `["OneHanded", "Dagger"]`, `["Aura"]` |
53
- | types | `Type` enum array | `["Action"]`, `["Hero"]` |
54
- | typeText | `string` | `"Elemental Ranger Action – Arrow Attack"` |
55
-
56
- ### Optional
57
-
58
- | Field | Data type | Examples |
59
- | -------------------------- | -------------------- | ------------------------------------ |
60
- | cost | `number` | `0`, `10` |
61
- | defense | `number` | `3`, `4` |
62
- | functionalText | `string` | `"If Snatch hits, draw a card."` |
63
- | fusions | `Fusion` enum array | `[ "Earth", "Ice" ]` |
64
- | hero | `Hero` enum | `"Rhinar"`, `"Dori"` |
65
- | intellect | `number` | `3`, `4` |
66
- | isCardBack | `boolean` | `true` |
67
- | keywords | `Keyword` enum array | `[ "Boost" ]` |
68
- | life | `number` | `18`, `40` |
69
- | oppositeSideCardIdentifier | `string` | `"invoke-kyloria-red"`, `"tomeltai"` |
70
- | pitch | `number` | `1`, `2`, `3` |
71
- | power | `number` | `3`, `14` |
72
- | restrictedFormats | `Format` enum array | `[ "Blitz" ]` |
73
- | specialCost | `string` | `"XX"`, `"3X"` |
74
- | specialDefense | `string` | `"*"` |
75
- | specialPower | `string` | `"*"` |
76
- | specializations | `Hero` enum array | `["Dromai","Fai"]` |
77
- | talents | `Talent` enum array | `[ "Draconic" ]` |
78
- | young | `boolean` | `true` |
79
-
80
- **`Printing`** contains information about the different printings a card has had (e.g. different sets, foilings)
81
-
82
- | Field | Data type | Examples |
83
- | ---------- | --------------------------------- | ----------------------------------- |
84
- | edition | `string` of `ReleaseEdition` enum | `"Alpha"`, `"Unlimited"` |
85
- | foiling | `string` of `Foiling` enum | `"Cold"`, `"Rainbow"` |
86
- | identifier | `string` | `"1HP001"` |
87
- | image | `string` | `"1HP001.width-450"` |
88
- | set | `string` of `Release` enum | `"Dynasty"`, `"Uprising"` |
89
- | treatment | `string` of `Treatment` enum | `"Alternate Art"`, `"Extended Art"` |
90
-
91
- ## Enums
92
-
93
- **`Class`**
13
+ Published as **dual ESM + CJS** — works in bundlers, native Node ESM, and CommonJS.
94
14
 
95
- ```ts
96
- "NotClassed", "Generic", "Adjudicator", "Bard", "Brute", "Guardian", "Illusionist", "Mechanologist", "Merchant", "Ninja", "Ranger", "Runeblade", "Shapeshifter", "Warrior", "Wizard",
97
- ```
98
-
99
- <br/>
100
-
101
- **`Format`**
15
+ ## Usage
102
16
 
103
17
  ```ts
104
- "Blitz", "Clash", "Classic Constructed", "Commoner",
18
+ import { Hero, Rarity, getDefaultPrinting } from "@flesh-and-blood/types";
105
19
  ```
106
20
 
107
- <br/>
108
-
109
- **`Fusion`**
21
+ Data and helper modules are also available as subpath imports, so you can pull in just what you need:
110
22
 
111
23
  ```ts
112
- "Earth", "Ice", "Lightning",
24
+ import { releases } from "@flesh-and-blood/types/sets";
25
+ import { getDefaultPrinting } from "@flesh-and-blood/types/helpers";
26
+ import type { Card } from "@flesh-and-blood/types/interfaces";
113
27
  ```
114
28
 
115
- <br/>
29
+ ## What's included
116
30
 
117
- **`Rarity`**
118
-
119
- ```ts
120
- "Token", "Common", "Rare", "Super Rare", "Majestic", "Legendary", "Fabled", "Promo",
121
- ```
31
+ The exported TypeScript types are the source of truth for exact values and fields — the lists below are
32
+ an overview.
122
33
 
123
- <br/>
34
+ ### Enums
124
35
 
125
- **`Release`**
36
+ `Bond`, `Class`, `Flow`, `Foiling`, `Format`, `Fusion`, `Hero`, `Keyword`, `Language`, `Meta`,
37
+ `Metatype`, `Rarity`, `Release`, `ReleaseEdition`, `ReleaseType`, `Shorthand`, `Subtype`, `Talent`,
38
+ `Trait`, `Treatment`, `Type`.
126
39
 
127
- ```ts
128
- // Full sets
129
- "Arcane Rising", "Crucible of War", "Dynasty", "Everfest", "History Pack 1", "Monarch", "Tales of Aria", "Uprising", "Welcome to Rathe",
40
+ ### Interfaces
130
41
 
131
- // Hero/blitz decks
132
- "Boltyn Blitz Deck", "Briar Blitz Deck", "Bravo Blitz Deck", "Chane Blitz Deck", "Classic Battles: Rhinar vs Dorinthea", "Dorinthea Hero Deck", "Ira Welcome Deck", "Katsu Hero Deck", "LeviaBlitzDeck", "Lexi Blitz Deck", "Oldhim Blitz Deck", "Prism Blitz Deck", "Rhinar Hero Deck",
42
+ `Card` (the main card shape), `DoubleSidedCard`, `Printing`, `LegalOverride`, `ReleaseInfo`,
43
+ `SilverAgeChapter`.
133
44
 
134
- // One-offs
135
- "Promos",
136
- ```
45
+ ### Helpers — `@flesh-and-blood/types/helpers`
137
46
 
138
- <br/>
47
+ - **Printing pickers:** `getPrint`, `getDefaultPrinting`, `getSpecialPrinting`, `getBoomerPrinting`,
48
+ `getMaxRarityPrinting`
49
+ - **Card properties:** `getCardIdentifier`, `getFrontAndBackCardIdentifier`,
50
+ `getCardFromGEMCardIdentifier`, `getIsArenaCard`, `getIsDeckCard`, `getIsCardTokenForDeck`,
51
+ `getCanCardBeTokenForDeck`, `getCanAddToDeck`, `getShouldRotateCardImage`
139
52
 
140
- **`Talent`**
53
+ ### Set data — `@flesh-and-blood/types/sets`
141
54
 
142
- ```ts
143
- "Draconic", "Earth", "Elemental", "Ice", "Light", "Lightning", "Royal", "Shadow",
144
- ```
145
-
146
- <br/>
147
-
148
- **`Type`**
149
-
150
- ```ts
151
- "Action", "Attack Action", "Attack Reaction", "Defense Reaction", "Equipment", "Hero", "Instant", "Mentor", "Resource", "Token", "Weapon",
152
- ```
153
-
154
- **`Hero`**
155
-
156
- ```ts
157
- "Arakni", "Azalea", "Benji", "Boltyn", "Bravo", "Briar", "Chane", "Dash", "Data Doll", "Dorinthea", "Emperor", "Genis Wotchuneed", "Ira", "Iyslander", "Kano", "Kassai", "Katsu", "Kavdaen", "Kayo", "Levia", "Lexi", "Oldhim", "Prism", "Rhinar", "Ruu’di", "Shiyana", "Taylor", "Valda", "Viserai", "Yorick",
158
- ```
159
-
160
- <br/>
161
-
162
- **`Keyword`**
163
-
164
- ```ts
165
- "Arcane Barrier", "Battleworn", "Blade Break", "Blood Debt", "Boost", "Channel", "Charge", "Combo", "Crush", "Dominate", "Essence", "Freeze", "Fusion", "Go Again", "Heave", "Intimidate", "Legendary", "Mentor", "Negate", "Opt", "Phantasm", "Reload", "Reprise", "Specialization", "Spectra", "Spellvoid", "Temper", "Thaw", "Unfreeze",
166
- ```
55
+ `releases`, `fullSetIdentifiers`, `setIdentifierToSetMappings`, `setToSetIdentifierMappings`,
56
+ `silverAgeChapters`, plus `getIsBooster`, `getIsReprint`, `getIsDraftable`, `getIsPreconstructed`.
167
57
 
168
58
  ## Working with this project
169
59
 
170
- ### Card data
171
-
172
- - [src/cards.csv](src/cards.csv) is the source of truth for all generated data. The data is managed in Google Sheets and sourced from [the-fab-cube/flesh-and-blood-cards](https://github.com/the-fab-cube/flesh-and-blood-cards).
60
+ Source lives in `src/` (`interfaces.ts`, `sets.ts`, `helpers/`).
173
61
 
174
- ### Data transformations
175
-
176
- There are three steps involved in transforming the `.tsv` source data into typed `.ts` code - executed via `npm run transform`.
177
-
178
- 1. [src/parser.ts](src/parser.ts) reads from the `.tsv` file and converts the data into JavaScript objects (performing basic steps like converting comma-delimited lists into arrays)
179
- 1. [src/mapper.ts](src/mapper.ts) takes the parsed card data and transforms it to match the interfaces in [src/interfaces.ts](src/interfaces.ts)
180
- 1. [src/writer.ts](src/writer.ts) creates `.ts` files containing the card information and all types
181
-
182
- ### Bundling the library
183
-
184
- To generate the distributed package code run `npm run build` after transforming the data.
62
+ ```bash
63
+ npm run build # build:esm (per-file ESM, tree-shakeable) + build:cjs (bundled) + tsc declarations
64
+ npm test # jest
65
+ ```
@@ -3,6 +3,7 @@ export interface Card {
3
3
  cardIdentifier: string;
4
4
  classes: Class[];
5
5
  defaultImage?: string;
6
+ firstReleaseDate: string;
6
7
  legalFormats: Format[];
7
8
  legalHeroes: Hero[];
8
9
  name: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flesh-and-blood/types",
3
3
  "description": "TypeScript representations of Flesh and Blood card types",
4
- "version": "4.0.3",
4
+ "version": "4.0.4",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "dist/index.cjs",
@@ -71,5 +71,5 @@
71
71
  "FAB",
72
72
  "FABTCG"
73
73
  ],
74
- "gitHead": "ddbb4d4372b235cc064ac7ccef1b2b42d721447f"
74
+ "gitHead": "341ad7b281233911841c004cc8109203375867ec"
75
75
  }