@mks.haro/axicode 1.0.0 → 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/README.md +138 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# @mks.haro/axicode
|
|
2
|
+
|
|
3
|
+
Compact binary build code encoder/decoder for Guild Wars 2 builds. Produces shareable build strings in the **AxiCode** format used by [AxiForge](https://axiforge.com).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mks.haro/axicode
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
const { encodeShareCode, decodeShareCode, isValidShareCode } = require("@mks.haro/axicode");
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Encoding a build
|
|
18
|
+
|
|
19
|
+
Pass a build object to `encodeShareCode` to get a share code string:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const code = encodeShareCode({
|
|
23
|
+
profession: "Warrior",
|
|
24
|
+
gameMode: "pve",
|
|
25
|
+
specializations: [
|
|
26
|
+
{
|
|
27
|
+
id: 4, name: "Strength", elite: false,
|
|
28
|
+
majorChoices: { 1: 1444, 2: 1449, 3: 1437 },
|
|
29
|
+
majorTraitsByTier: {
|
|
30
|
+
1: [{ id: 1444 }, { id: 1447 }, { id: 2000 }],
|
|
31
|
+
2: [{ id: 1449 }, { id: 1448 }, { id: 1453 }],
|
|
32
|
+
3: [{ id: 1437 }, { id: 1440 }, { id: 1454 }],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
// ... two more specializations
|
|
36
|
+
],
|
|
37
|
+
skills: {
|
|
38
|
+
heal: { id: 14402 },
|
|
39
|
+
utility: [{ id: 14404 }, { id: 14410 }, { id: 14405 }],
|
|
40
|
+
elite: { id: 14355 },
|
|
41
|
+
},
|
|
42
|
+
equipment: {
|
|
43
|
+
statPackage: "Berserker's",
|
|
44
|
+
weapons: { mainhand1: "greatsword", offhand1: "", mainhand2: "axe", offhand2: "" },
|
|
45
|
+
runes: { head: "24836", shoulders: "24836", chest: "24836", hands: "24836", legs: "24836", feet: "24836" },
|
|
46
|
+
sigils: { mainhand1: ["24615", "24868"], offhand1: [], mainhand2: ["24615"], offhand2: [] },
|
|
47
|
+
relic: "Relic of the Thief",
|
|
48
|
+
food: "Bowl of Sweet and Spicy Butternut Squash Soup",
|
|
49
|
+
utility: "Superior Sharpening Stone",
|
|
50
|
+
enrichment: "",
|
|
51
|
+
infusions: {
|
|
52
|
+
head: "49432", shoulders: "49432", chest: "49432", hands: "49432", legs: "49432", feet: "49432",
|
|
53
|
+
back: ["49432", "49432"], ring1: ["49432", "49432", "49432"], ring2: ["49432", "49432", "49432"],
|
|
54
|
+
accessory1: "49432", accessory2: "49432",
|
|
55
|
+
mainhand1: ["49432", "49432"], offhand1: [], mainhand2: ["49432", "49432"], offhand2: [],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
// Profession-specific fields (include as needed)
|
|
59
|
+
selectedLegends: ["", ""], // Revenant
|
|
60
|
+
selectedPets: { terrestrial1: 0, terrestrial2: 0 }, // Ranger
|
|
61
|
+
activeAttunement: "", // Elementalist
|
|
62
|
+
activeKit: 0, // Engineer
|
|
63
|
+
activeWeaponSet: 1, // Warrior
|
|
64
|
+
antiquaryArtifacts: { f2: 0, f3: 0, f4: 0 }, // Thief (Antiquary)
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log(code);
|
|
68
|
+
// => "<AxiForge:Berserker:x1y2z3...>"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Decoding a build
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
const build = decodeShareCode("<AxiForge:Berserker:x1y2z3...>");
|
|
75
|
+
|
|
76
|
+
console.log(build.profession); // "Warrior"
|
|
77
|
+
console.log(build.gameMode); // "pve"
|
|
78
|
+
console.log(build.equipment.statPackage); // "Berserker's"
|
|
79
|
+
console.log(build.skills.healId); // 14402
|
|
80
|
+
console.log(build.equipment.weapons); // { mainhand1: "greatsword", ... }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Validating a share code
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
isValidShareCode("<AxiForge:Berserker:x1y2z3...>"); // true
|
|
87
|
+
isValidShareCode("not a share code"); // false
|
|
88
|
+
isValidShareCode("[&DQYlPSkvMBc=]"); // false (GW2 chat link, not AxiCode)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### `encodeShareCode(build) → string`
|
|
94
|
+
|
|
95
|
+
Encodes a build object into an AxiCode share string. The output format is `<AxiForge:{label}:{payload}>`, where the label is the elite specialization name (or profession name for core builds).
|
|
96
|
+
|
|
97
|
+
### `decodeShareCode(code) → object`
|
|
98
|
+
|
|
99
|
+
Decodes an AxiCode share string back into a build object. Throws if the format is invalid or the payload is corrupted.
|
|
100
|
+
|
|
101
|
+
**Returned object shape:**
|
|
102
|
+
|
|
103
|
+
| Field | Type | Description |
|
|
104
|
+
|-------|------|-------------|
|
|
105
|
+
| `profession` | `string` | Profession name (e.g. `"Warrior"`) |
|
|
106
|
+
| `gameMode` | `string` | `"pve"`, `"pvp"`, or `"wvw"` |
|
|
107
|
+
| `specializations` | `array` | Three specs, each with `id` and `traitChoices` (1=top, 2=mid, 3=bottom, 0=none) |
|
|
108
|
+
| `skills` | `object` | `{ healId, utilityIds: [3], eliteId }` |
|
|
109
|
+
| `underwaterSkills` | `object` | Same shape as `skills`, zeroed if unused |
|
|
110
|
+
| `equipment` | `object` | Stat package, weapons, runes, sigils, relic, food, utility, enrichment, infusions |
|
|
111
|
+
| `selectedLegends` | `array` | Revenant legend strings |
|
|
112
|
+
| `selectedPets` | `object` | Ranger pet IDs |
|
|
113
|
+
| `activeAttunement` | `string` | Elementalist attunement |
|
|
114
|
+
| `activeKit` | `number` | Engineer active kit skill ID |
|
|
115
|
+
| `activeWeaponSet` | `number` | Warrior active weapon set (1 or 2) |
|
|
116
|
+
| `antiquaryArtifacts` | `object` | Thief Antiquary artifact skill IDs |
|
|
117
|
+
|
|
118
|
+
### `isValidShareCode(text) → boolean`
|
|
119
|
+
|
|
120
|
+
Returns `true` if the string matches the AxiCode wrapper format.
|
|
121
|
+
|
|
122
|
+
## Supported Values
|
|
123
|
+
|
|
124
|
+
**Professions:** Guardian, Warrior, Engineer, Ranger, Thief, Elementalist, Mesmer, Necromancer, Revenant
|
|
125
|
+
|
|
126
|
+
**Weapons:** axe, dagger, mace, pistol, sword, scepter, focus, shield, torch, warhorn, greatsword, hammer, longbow, rifle, shortbow, staff, harpoon, spear, trident
|
|
127
|
+
|
|
128
|
+
**Stat combos:** Berserker's, Marauder's, Assassin's, Valkyrie, Dragon's, Viper's, Grieving, Sinister, Dire, Rabid, Carrion, Trailblazer's, Knight's, Soldier's, Cleric's, Minstrel's, Harrier's, Ritualist's, Seraph, Zealot's, Celestial
|
|
129
|
+
|
|
130
|
+
**Game modes:** pve, pvp, wvw
|
|
131
|
+
|
|
132
|
+
## Format Details
|
|
133
|
+
|
|
134
|
+
AxiCode uses a compact binary encoding with bit-level packing and [Z85](https://rfc.zeromq.org/spec/32/) encoding for the text payload. The format uses flags to conditionally include optional sections (offhands, second weapon set, underwater, profession-specific data, per-slot runes/infusions), keeping simple builds small while supporting full equipment detail.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|