ygopro-yrp-encode
v1.0.1
Published
A platform-agnostic YGOPro `.yrp` / `.yrp2` replay parser and writer (no Node `Buffer` usage inside the core logic).
Readme
ygopro-yrp-encode
A platform-agnostic YGOPro .yrp / .yrp2 replay parser and writer (no Node Buffer usage inside the core logic).
Install
npm i ygopro-yrp-encodeAPI
YGOProYrp
Main class for reading and writing replays.
import { YGOProYrp } from 'ygopro-yrp-encode';
// Read
const payload = fs.readFileSync('tests/ygopro-yrp-test.yrp');
const yrp = new YGOProYrp().fromYrp(payload);
console.log(yrp.hostName); // first player name
console.log(yrp.clientName); // second player name
// Write
const out = yrp.toYrp();
fs.writeFileSync('ygopro-yrp-test-remake.yrp', out);YGOProYrpLike
Structure used by the deep-copy constructor.
import { YGOProYrp, type YGOProYrpLike } from 'ygopro-yrp-encode';
const copy = new YGOProYrp(existing as YGOProYrpLike); // deep copyReplayHeader
Header object used by YGOProYrp. It exposes flags and LZMA properties.
import { ReplayHeader, REPLAY_ID_YRP1, REPLAY_ID_YRP2 } from 'ygopro-yrp-encode';
const header = new ReplayHeader();
header.id = REPLAY_ID_YRP1;Constants
import {
SEED_COUNT,
REPLAY_ID_YRP1,
REPLAY_ID_YRP2,
REPLAY_COMPRESSED_FLAG,
REPLAY_TAG_FLAG,
REPLAY_DECODED_FLAG,
REPLAY_SINGLE_MODE,
REPLAY_UNIFORM,
} from 'ygopro-yrp-encode';Notes
- Repacking will usually produce a different SHA256, because LZMA compression output is not byte-stable.
- Tag duel fields (
tag*) are only present whenheader.isTagis true.
