xiv-strat-board 0.1.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/README.md +166 -0
- package/dist/index.cjs +1153 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +171 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.js +1144 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# xiv-strat-board
|
|
2
|
+
|
|
3
|
+
Encoder and decoder for FF14 Strategy Board share codes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install xiv-strat-board
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Encoding a Strategy Board
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { encode } from 'xiv-strat-board';
|
|
17
|
+
|
|
18
|
+
const shareCode = encode({
|
|
19
|
+
name: 'myboard',
|
|
20
|
+
boardBackground: 'checkered',
|
|
21
|
+
objects: [
|
|
22
|
+
{ type: 'tank', x: 256, y: 192, size: 100 },
|
|
23
|
+
{ type: 'healer', x: 300, y: 192, size: 100 },
|
|
24
|
+
{ type: 'circle_aoe', x: 256, y: 192, size: 150 },
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log(shareCode); // "[stgy:a...]"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Decoding a Share Code
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { decode } from 'xiv-strat-board';
|
|
35
|
+
|
|
36
|
+
const board = decode('[stgy:aVe.........]');
|
|
37
|
+
|
|
38
|
+
console.log(board.name); // "myboard"
|
|
39
|
+
console.log(board.boardBackground); // "checkered"
|
|
40
|
+
console.log(board.objects.length); // 3
|
|
41
|
+
|
|
42
|
+
for (const obj of board.objects) {
|
|
43
|
+
console.log(`${obj.type} at (${obj.x}, ${obj.y})`);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
### `encode(board: StrategyBoard, options?: EncodeOptions): string`
|
|
50
|
+
|
|
51
|
+
Encodes a strategy board to a share code.
|
|
52
|
+
|
|
53
|
+
**Parameters:**
|
|
54
|
+
- `board` - The strategy board to encode
|
|
55
|
+
- `options.key` - Optional cipher key (0-63), random if not provided
|
|
56
|
+
|
|
57
|
+
**Returns:** Share code string (e.g., `"[stgy:a...]"`)
|
|
58
|
+
|
|
59
|
+
**Throws:** `Error` if board data is invalid
|
|
60
|
+
|
|
61
|
+
### `decode(shareCode: string): DecodeResult`
|
|
62
|
+
|
|
63
|
+
Decodes a share code to a strategy board.
|
|
64
|
+
|
|
65
|
+
**Parameters:**
|
|
66
|
+
- `shareCode` - Share code string (e.g., `"[stgy:a...]"`)
|
|
67
|
+
|
|
68
|
+
**Returns:** Decoded strategy board with `version`, `name`, `boardBackground`, and `objects`
|
|
69
|
+
|
|
70
|
+
**Throws:** `Error` if share code is invalid or malformed
|
|
71
|
+
|
|
72
|
+
## Types
|
|
73
|
+
|
|
74
|
+
### `StrategyBoard`
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface StrategyBoard {
|
|
78
|
+
name?: string; // Max 7 characters
|
|
79
|
+
boardBackground?: BackgroundType;
|
|
80
|
+
objects: StrategyObject[];
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### `StrategyObject`
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
interface StrategyObject {
|
|
88
|
+
type: IconType; // e.g., 'tank', 'circle_aoe', 'waymark_a'
|
|
89
|
+
typeId?: number; // Optional numeric ID (overrides type)
|
|
90
|
+
x: number; // 0-512, center at 256
|
|
91
|
+
y: number; // 0-384, center at 192
|
|
92
|
+
size?: number; // 1-255, default 100
|
|
93
|
+
background?: BackgroundType;
|
|
94
|
+
|
|
95
|
+
// Color (only for line_aoe, line, text)
|
|
96
|
+
color?: string; // Hex color '#RRGGBB'
|
|
97
|
+
transparency?: number; // 0-255
|
|
98
|
+
|
|
99
|
+
// AoE properties
|
|
100
|
+
arcAngle?: number; // 10-360 for fan_aoe and donut
|
|
101
|
+
donutRadius?: number; // 0-255 for donut inner radius
|
|
102
|
+
|
|
103
|
+
// Line AoE properties
|
|
104
|
+
width?: number; // Width for line_aoe
|
|
105
|
+
height?: number; // Height for line_aoe
|
|
106
|
+
|
|
107
|
+
// Line properties
|
|
108
|
+
endX?: number; // End X for line objects
|
|
109
|
+
endY?: number; // End Y for line objects
|
|
110
|
+
|
|
111
|
+
// Rotation (for fan_aoe, line_aoe, line_stack, linear_knockback, etc.)
|
|
112
|
+
angle?: number; // Rotation angle in degrees
|
|
113
|
+
|
|
114
|
+
// Counted mechanics
|
|
115
|
+
displayCount?: number; // Display count for line_stack
|
|
116
|
+
horizontalCount?: number; // Horizontal count for linear_knockback
|
|
117
|
+
verticalCount?: number; // Vertical count for linear_knockback
|
|
118
|
+
|
|
119
|
+
// Text objects
|
|
120
|
+
text?: string; // Text content for text objects
|
|
121
|
+
|
|
122
|
+
// Flip states
|
|
123
|
+
horizontalFlip?: boolean;
|
|
124
|
+
verticalFlip?: boolean;
|
|
125
|
+
|
|
126
|
+
// Visibility
|
|
127
|
+
hidden?: boolean;
|
|
128
|
+
locked?: boolean;
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `BackgroundType`
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
type BackgroundType =
|
|
136
|
+
| 'none'
|
|
137
|
+
| 'checkered'
|
|
138
|
+
| 'checkered_circle'
|
|
139
|
+
| 'checkered_square'
|
|
140
|
+
| 'grey'
|
|
141
|
+
| 'grey_circle'
|
|
142
|
+
| 'grey_square';
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Icon Types
|
|
146
|
+
|
|
147
|
+
The package supports 100+ icon types including:
|
|
148
|
+
|
|
149
|
+
- **Role markers:** `tank`, `tank_1`, `tank_2`, `healer`, `healer_1`, `healer_2`, `dps`, `dps_1`-`dps_4`, `melee_dps`, `ranged_dps`, `physical_ranged_dps`, `magical_ranged_dps`, `pure_healer`, `barrier_healer`
|
|
150
|
+
- **Jobs:** All jobs including `viper`, `pictomancer`, and base classes
|
|
151
|
+
- **Mechanics:** `circle_aoe`, `fan_aoe`, `line_aoe`, `donut`, `stack`, `line_stack`, `gaze`, `tower`, `proximity`, `proximity_player`, `tankbuster`, `radial_knockback`, `linear_knockback`, `targeting`, `moving_circle_aoe`, `1person_aoe`-`4person_aoe`
|
|
152
|
+
- **Waymarks:** `waymark_a`-`waymark_d`, `waymark_1`-`waymark_4`
|
|
153
|
+
- **Markers:** `attack_1`-`attack_8`, `bind_1`-`bind_3`, `ignore_1`, `ignore_2`, `square_marker`, `circle_marker`, `plus_marker`, `triangle_marker`
|
|
154
|
+
- **Enemies:** `small_enemy`, `medium_enemy`, `large_enemy`
|
|
155
|
+
- **Shapes:** `shape_circle`, `shape_x`, `shape_triangle`, `shape_square`, `up_arrow`, `text`, `rotate`, `rotate_clockwise`, `rotate_counterclockwise`, `highlighted_circle`, `highlighted_x`, `highlighted_square`, `highlighted_triangle`
|
|
156
|
+
- **Effects:** `enhancement`, `enfeeblement`, `lockon_red`, `lockon_blue`, `lockon_purple`, `lockon_green`
|
|
157
|
+
|
|
158
|
+
See `ICON_TYPE_IDS` export for the complete list.
|
|
159
|
+
|
|
160
|
+
## Browser Support
|
|
161
|
+
|
|
162
|
+
This package works in both Node.js and browsers. It uses `pako` for zlib compression, which is browser-compatible.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|