cdb2yugiohcard 1.0.1
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/.eslintignore +4 -0
- package/.eslintrc.js +25 -0
- package/.prettierrc +4 -0
- package/AGENTS.md +22 -0
- package/LICENSE +22 -0
- package/README.md +86 -0
- package/dist/index.cjs +12925 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +12897 -0
- package/dist/index.mjs.map +7 -0
- package/dist/src/constants/index.d.ts +6 -0
- package/dist/src/convert.d.ts +3 -0
- package/dist/src/locales/base.d.ts +23 -0
- package/dist/src/locales/common.d.ts +9 -0
- package/dist/src/locales/en.d.ts +14 -0
- package/dist/src/locales/jp.d.ts +10 -0
- package/dist/src/locales/kr.d.ts +10 -0
- package/dist/src/locales/registry.d.ts +2 -0
- package/dist/src/locales/sc.d.ts +11 -0
- package/dist/src/types/index.d.ts +39 -0
- package/dist/src/types/strings.d.ts +6 -0
- package/dist/src/utility/bitmask.d.ts +2 -0
- package/dist/src/utility/text.d.ts +3 -0
- package/dist/src/vendor/strings.d.ts +2 -0
- package/index.ts +4 -0
- package/package.json +84 -0
- package/tsconfig.json +24 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: '@typescript-eslint/parser',
|
|
3
|
+
parserOptions: {
|
|
4
|
+
project: 'tsconfig.json',
|
|
5
|
+
tsconfigRootDir : __dirname,
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
},
|
|
8
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/recommended',
|
|
11
|
+
'plugin:prettier/recommended',
|
|
12
|
+
],
|
|
13
|
+
root: true,
|
|
14
|
+
env: {
|
|
15
|
+
node: true,
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
ignorePatterns: ['.eslintrc.js', 'src/vendor/**'],
|
|
19
|
+
rules: {
|
|
20
|
+
'@typescript-eslint/interface-name-prefix': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
|
+
},
|
|
25
|
+
};
|
package/.prettierrc
ADDED
package/AGENTS.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 项目规范
|
|
2
|
+
|
|
3
|
+
## 项目目标
|
|
4
|
+
|
|
5
|
+
把 ygopro-cdb-encode 转换为 yugioh-card 的数据。
|
|
6
|
+
|
|
7
|
+
## 注意事项
|
|
8
|
+
|
|
9
|
+
- 不要擅自写 md 文件。
|
|
10
|
+
- 写完代码之后遇到 eslint 报错,不要直接手动修,而是先跑 npm run lint 修复。
|
|
11
|
+
- 和业务无关的逻辑写在 src/utility/ 下
|
|
12
|
+
- 常量写在 src/constants/ 下
|
|
13
|
+
- 类型写在 src/types/ 下
|
|
14
|
+
|
|
15
|
+
## 参考项目
|
|
16
|
+
|
|
17
|
+
这些项目只能看,不能进行修改。
|
|
18
|
+
|
|
19
|
+
- 曾经的成功转换项目: /home/nanahira/ygo/diy
|
|
20
|
+
- ygopro-cdb-encode: /home/nanahira/ygo/ygopro-cdb-encode
|
|
21
|
+
- ygopro 文本: /home/nanahira/ygo/ygopro/strings.conf
|
|
22
|
+
- ygopro-cdb-descgen: /home/nanahira/ygo/ygopro-cdb-descgen
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Nanahira
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# cdb2yugiohcard
|
|
2
|
+
|
|
3
|
+
Convert [ygopro-cdb-encode](https://www.npmjs.com/package/ygopro-cdb-encode) card data to [yugioh-card](https://www.npmjs.com/package/yugioh-card) format.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install cdb2yugiohcard ygopro-cdb-encode yugioh-card
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`ygopro-cdb-encode` and `yugioh-card` are peer dependencies and must be installed alongside.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic Conversion
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { YGOProCdb } from 'ygopro-cdb-encode';
|
|
19
|
+
import { cdbToYugiohCard } from 'cdb2yugiohcard';
|
|
20
|
+
|
|
21
|
+
// Load CDB database
|
|
22
|
+
const cdb = new YGOProCdb(SQL).from(cdbData);
|
|
23
|
+
const card = cdb.findById(46986414);
|
|
24
|
+
|
|
25
|
+
// Convert to yugioh-card data
|
|
26
|
+
const data = cdbToYugiohCard(card, { language: 'sc' });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Supported Languages
|
|
30
|
+
|
|
31
|
+
| Code | Language |
|
|
32
|
+
|------|----------|
|
|
33
|
+
| `sc` | Simplified Chinese (default) |
|
|
34
|
+
| `tc` | Traditional Chinese (uses SC logic) |
|
|
35
|
+
| `astral` | Astral (uses SC logic) |
|
|
36
|
+
| `jp` | Japanese |
|
|
37
|
+
| `kr` | Korean |
|
|
38
|
+
| `en` | English |
|
|
39
|
+
|
|
40
|
+
### Passing Extra Fields
|
|
41
|
+
|
|
42
|
+
The second argument of `cdbToYugiohCard` accepts any additional `yugioh-card` fields such as card image and rarity:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const data = cdbToYugiohCard(card, {
|
|
46
|
+
language: 'sc',
|
|
47
|
+
image: '/path/to/card/image.jpg',
|
|
48
|
+
rare: 'sr',
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Rendering Card Images with yugioh-card
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { YugiohCard } from 'yugioh-card';
|
|
56
|
+
import { Canvas } from 'skia-canvas';
|
|
57
|
+
|
|
58
|
+
const yugiohCard = new YugiohCard({
|
|
59
|
+
canvas: new Canvas(400, 580),
|
|
60
|
+
resourcePath: '/path/to/yugioh-card/static',
|
|
61
|
+
data,
|
|
62
|
+
});
|
|
63
|
+
await yugiohCard.bindCanvas();
|
|
64
|
+
await yugiohCard.bindData();
|
|
65
|
+
await yugiohCard.render();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
### `cdbToYugiohCard(card, extras?)`
|
|
71
|
+
|
|
72
|
+
- `card` — `CardDataEntry` from `ygopro-cdb-encode`
|
|
73
|
+
- `extras` — `Partial<YugiohCardData>`, optional extra fields. The `language` field selects the locale handler.
|
|
74
|
+
- Returns `Partial<YugiohCardData>`
|
|
75
|
+
|
|
76
|
+
### `getLocaleHandler(language)`
|
|
77
|
+
|
|
78
|
+
Get the locale handler instance for a given language code.
|
|
79
|
+
|
|
80
|
+
### `LocaleHandler`
|
|
81
|
+
|
|
82
|
+
Abstract base class for locale handlers. Extend this to implement custom language support.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|