IntroTableMgr.ts
1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { tMgr } from "../../Global";
import { IntroTable, TableName } from "./TableDefine";
export class IntroTableMgr {
private _levelList: number[] = [];
private _idList: number[] = [];
private static _ins: IntroTableMgr = null;
static get ins(): IntroTableMgr {
if (this._ins == null) {
this._ins = new IntroTableMgr();
let all = tMgr.map[TableName.INTRO];
for (const key in all) {
if (Object.prototype.hasOwnProperty.call(all, key)) {
if (!Number(key)) {
continue;
}
const element = all[key] as IntroTable;
if (element.Level > 0) {
this._ins._levelList.push(element.Level);
this._ins._idList.push(element.ID);
}
}
}
}
return this._ins;
}
getTableByLevel(level: number): IntroTable {
let index = this._levelList.indexOf(level);
if (index > -1) {
let id = this._idList[index];
return tMgr.getConfig(TableName.INTRO, id) as IntroTable;
}
return null;
}
}