unitProto.js 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. const proto = require("../data/protoData.json");
  3. /*
  4. * Unit for Fps Manager. Managing definitions versions for game protocol
  5. * Author: SaltyMonkey
  6. * Contributors:
  7. */
  8. /**
  9. * @typedef {import("../fpsManager.js").deps} deps
  10. */
  11. class unitProto {
  12. /**
  13. *Creates an instance of unitProto.
  14. * @param {deps} deps dependencies
  15. * @memberof unitProto
  16. */
  17. constructor(deps) {
  18. this.__mod = deps.mod;
  19. console.log("DEBUG: unitProto -> constructor");
  20. }
  21. /**
  22. * @description returns def version based on current game patch
  23. * @param {*} defName definition string
  24. * @returns {Array} definition data with version
  25. * @memberof unitProto
  26. */
  27. getData(defName) {
  28. let version = proto[defName][this.__mod.majorPatchVersion];
  29. return version ? [defName, version] : [defName, proto[defName].default];
  30. }
  31. }
  32. module.exports = unitProto;