UNPKG

homm3-parsers

Version:

Collection of binary parsers able to parse various file formats related to Heroes of Might and Magic III

41 lines 3.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const binary_markup_1 = require("binary-markup"); const constants_1 = require("./constants"); const artifact_1 = require("./enums/artifact"); const creature_1 = require("./enums/creature"); const hero_1 = require("./enums/hero"); const skill_1 = require("./enums/skill"); const spell_1 = require("./enums/spell"); const resource_1 = require("./enums/resource"); const player_1 = require("./enums/player"); exports.isRoE = (context) => context.get('format') === constants_1.MapFormat.ROE; exports.isSoD = (context) => context.get('format') === constants_1.MapFormat.SOD; exports.isNotRoE = (context) => context.get('format') !== constants_1.MapFormat.ROE; exports.hommString = binary_markup_1.pascalString(binary_markup_1.uint32); exports.primarySkills = binary_markup_1.struct(binary_markup_1.uint8 `attack`, binary_markup_1.uint8 `defense`, binary_markup_1.uint8 `spellPower`, binary_markup_1.uint8 `knowledge`); exports.skill = binary_markup_1.enums(binary_markup_1.byte, skill_1.secondarySkillEnum); exports.secondarySkill = binary_markup_1.struct(exports.skill `type`, binary_markup_1.enums(binary_markup_1.uint8, skill_1.secondarySkillMasteryEnum) `level`); exports.experience = binary_markup_1.uint32; exports.heroType = binary_markup_1.uint8; exports.artifactType = binary_markup_1.when(exports.isRoE, binary_markup_1.uint8, binary_markup_1.uint16); exports.creatureType = binary_markup_1.when(exports.isRoE, binary_markup_1.int8, binary_markup_1.int16); exports.resourceType = binary_markup_1.uint8; exports.spellType = binary_markup_1.uint8; exports.absodId = binary_markup_1.uint32; exports.playerFlag = binary_markup_1.enums(binary_markup_1.uint8, player_1.playerEnum); exports.artifact = binary_markup_1.enums(exports.artifactType, artifact_1.artifactEnum); exports.creature = binary_markup_1.enums(exports.creatureType, creature_1.creatureEnum); exports.hero = binary_markup_1.enums(exports.heroType, hero_1.heroEnum); exports.spell = binary_markup_1.enums(exports.spellType, spell_1.spellEnum); exports.resource = binary_markup_1.enums(exports.resourceType, resource_1.resourceEnum); exports.creatureSlot = binary_markup_1.struct(exports.creature `type`, binary_markup_1.uint16 `quantity`); exports.army = binary_markup_1.array(exports.creatureSlot, 7); exports.resources = binary_markup_1.array(binary_markup_1.int32, 7); exports.wornArtifacts = binary_markup_1.struct(exports.artifact `headwear`, exports.artifact `shoulders`, exports.artifact `rightHand`, exports.artifact `leftHand`, exports.artifact `torso`, exports.artifact `rightRing`, exports.artifact `leftRing`, exports.artifact `feet`, exports.artifact `misc1`, exports.artifact `misc2`, exports.artifact `misc3`, exports.artifact `misc4`, exports.artifact `device1`, exports.artifact `device2`, exports.artifact `device3`, exports.artifact `device4`, binary_markup_1.when(exports.isSoD, binary_markup_1.uint16), exports.artifact `spellbook`, exports.artifact `misc5`); exports.backpack = binary_markup_1.struct( // binary_markup_1.uint16 `count`, binary_markup_1.array(exports.artifact, binary_markup_1.ctx `count`) `artifacts`); exports.artifacts = binary_markup_1.struct(exports.wornArtifacts `worn`, exports.backpack `backpack`); exports.owner = binary_markup_1.enums(binary_markup_1.byte, player_1.playerEnum); //# sourceMappingURL=common.bml.js.map