captainbattle 1.0.2 → 1.0.4

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/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ import "./register-all";
10
10
  * CAPTAINBATTLE_CONFIG 环境变量 → 包内 resources/config/GameJsonCfg.bin
11
11
  */
12
12
  export declare function initCfg(file?: string): void;
13
+ export declare function initJsonCfg(obj: any): void;
13
14
  export { EGameModule };
14
15
  export interface IGameParam {
15
16
  seed: number;
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EGameModule = void 0;
7
7
  exports.initCfg = initCfg;
8
+ exports.initJsonCfg = initJsonCfg;
8
9
  exports.startBattleVerify = startBattleVerify;
9
10
  exports.startStageVerify = startStageVerify;
10
11
  exports.startRelicDungeonVerify = startRelicDungeonVerify;
@@ -59,6 +60,24 @@ function initCfg(file) {
59
60
  Cfg_1.Cfg.initByConfig(cfg);
60
61
  cfgReady = true;
61
62
  }
63
+ function initJsonCfg(obj) {
64
+ cfgReady = true;
65
+ for (const key in obj) {
66
+ if (!Cfg_1.Cfg.hasOwnProperty("_" + key)) {
67
+ console.warn("Cfg.initByMergeJson null, " + key);
68
+ continue;
69
+ }
70
+ let reader = Cfg_1.Cfg["_" + key];
71
+ const jsonObj = obj[key];
72
+ if (Array.isArray(jsonObj)) {
73
+ reader.initByArray(jsonObj);
74
+ }
75
+ else {
76
+ reader.initByMap(jsonObj);
77
+ }
78
+ }
79
+ Cfg_1.Cfg.initByConfig(obj);
80
+ }
62
81
  function makeFileName(prefix) {
63
82
  const d = new Date();
64
83
  const p = (n) => String(n).padStart(2, "0");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "captainbattle",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "水上大乱斗后端战斗模拟",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",