# w3xdata

`w3xdata` allows for extracting Warcraft 3 map data in a typed, semi-structured
way.

## Examples

```typescript
import {
  mapItemSpecs,
  mapStrings,
  mapUnitSpecs,
  replaceStrings,
} from "w3xdata";
import { promises as fs } from "fs";

Promise.all([
  fs.readFile("map/war3map.w3u"),
  fs.readFile("map/war3map.w3t"),
  fs.readFile("map/war3map.wts"),
]).then(([w3u, w3t, wts]) => {
  const strings = mapStrings(wts);
  const units = replaceStrings(mapUnitSpecs(w3u), strings);
  const items = replaceStrings(mapItemSpecs(w3t), strings);

  console.log(units.hfoo.text?.Name); // "Footman"
  console.log(units.h001.text?.Name); // "Custom Footman"
  console.log(items.ratf.text?.Name); // "Claws of Attack +15"
});
```

### Reforged skin files

Reforged maps split cosmetic overrides (names, tooltips, icons) into
`war3mapSkin.w3u` / `war3mapSkin.w3t`. Pass them as the optional second arg
and the modifications are applied on top of the main file:

```typescript
const units = mapUnitSpecs(w3u, w3uSkin);
const items = mapItemSpecs(w3t, w3tSkin);
```
