增加配表
This commit is contained in:
parent
59faa0db53
commit
c6714648d4
1
config/compound_tbl.json
Normal file
1
config/compound_tbl.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":99001,"type_id":1,"value":6},{"id":99002,"type_id":1,"value":2},{"id":99003,"type_id":2,"value":20},{"id":99004,"type_id":1,"value":2},{"id":99005,"type_id":1,"value":3},{"id":99006,"type_id":1,"value":4},{"id":99007,"type_id":1,"value":12},{"id":99008,"type_id":2,"value":12},{"id":99009,"type_id":2,"value":15},{"id":99010,"type_id":2,"value":15},{"id":99011,"type_id":2,"value":20},{"id":99012,"type_id":2,"value":5},{"id":99013,"type_id":1,"value":4},{"id":99014,"type_id":2,"value":5},{"id":99015,"type_id":1,"value":10},{"id":99016,"type_id":1,"value":10},{"id":99017,"type_id":2,"value":12},{"id":99018,"type_id":2,"value":12},{"id":99019,"type_id":2,"value":3},{"id":99020,"type_id":2,"value":20},{"id":99021,"type_id":3,"value":10},{"id":99022,"type_id":3,"value":55},{"id":99023,"type_id":1,"value":2},{"id":99024,"type_id":1,"value":3},{"id":99025,"type_id":1,"value":3},{"id":99026,"type_id":2,"value":1},{"id":99027,"type_id":1,"value":5},{"id":99028,"type_id":1,"value":5},{"id":99029,"type_id":1,"value":6},{"id":99030,"type_id":1,"value":6}]
|
1
config/effectcard_tbl.json
Normal file
1
config/effectcard_tbl.json
Normal file
File diff suppressed because one or more lines are too long
1
config/hero_tbl.json
Normal file
1
config/hero_tbl.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":30012,"herounit_id":52012,"ex_skill":0,"follower1id":51072,"follower2id":51082,"follower3id":51032,"follower4id":51052},{"id":30022,"herounit_id":52022,"ex_skill":0,"follower1id":51372,"follower2id":51162,"follower3id":51382,"follower4id":51332},{"id":30032,"herounit_id":52032,"ex_skill":0,"follower1id":51352,"follower2id":51042,"follower3id":51142,"follower4id":51062},{"id":30042,"herounit_id":52042,"ex_skill":0,"follower1id":51062,"follower2id":51122,"follower3id":51112,"follower4id":51042},{"id":30052,"herounit_id":52052,"ex_skill":0,"follower1id":51132,"follower2id":51082,"follower3id":51402,"follower4id":51112},{"id":30062,"herounit_id":52062,"ex_skill":0,"follower1id":51222,"follower2id":51272,"follower3id":51412,"follower4id":51042},{"id":30072,"herounit_id":52072,"ex_skill":0,"follower1id":51012,"follower2id":51082,"follower3id":51402,"follower4id":51152},{"id":30082,"herounit_id":52082,"ex_skill":0,"follower1id":51062,"follower2id":51272,"follower3id":51072,"follower4id":51052},{"id":30092,"herounit_id":52092,"ex_skill":0,"follower1id":51102,"follower2id":51372,"follower3id":51232,"follower4id":51292},{"id":30102,"herounit_id":52102,"ex_skill":0,"follower1id":51022,"follower2id":51092,"follower3id":51192,"follower4id":51392},{"id":30112,"herounit_id":52112,"ex_skill":0,"follower1id":51372,"follower2id":51162,"follower3id":51382,"follower4id":51332},{"id":30122,"herounit_id":52122,"ex_skill":0,"follower1id":51252,"follower2id":51052,"follower3id":51402,"follower4id":51132},{"id":30132,"herounit_id":52132,"ex_skill":0,"follower1id":51032,"follower2id":51342,"follower3id":51412,"follower4id":51252},{"id":30142,"herounit_id":52142,"ex_skill":0,"follower1id":51402,"follower2id":51202,"follower3id":51212,"follower4id":51342}]
|
1
config/skill_tbl.json
Normal file
1
config/skill_tbl.json
Normal file
File diff suppressed because one or more lines are too long
1
config/systemcard_tbl.json
Normal file
1
config/systemcard_tbl.json
Normal file
@ -0,0 +1 @@
|
||||
[{"id":10002,"type_id":1,"count":0,"point":0,"weight":""},{"id":10012,"type_id":1,"count":20,"point":1,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10022,"type_id":1,"count":20,"point":2,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10032,"type_id":1,"count":20,"point":3,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10042,"type_id":1,"count":20,"point":4,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10052,"type_id":1,"count":20,"point":5,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10062,"type_id":1,"count":20,"point":6,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10072,"type_id":1,"count":20,"point":7,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10082,"type_id":1,"count":20,"point":8,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10092,"type_id":1,"count":20,"point":9,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10102,"type_id":1,"count":20,"point":10,"weight":"20012:100|20032:100|20042:100|20052:150|20062:150|20072:150|20082:150|20102:750"},{"id":10112,"type_id":2,"count":20,"point":10,"weight":"20112:100"},{"id":10122,"type_id":3,"count":8,"point":10,"weight":"20122:100"},{"id":10132,"type_id":4,"count":0,"point":10,"weight":"20132:0"}]
|
1
config/unit_tbl.json
Normal file
1
config/unit_tbl.json
Normal file
File diff suppressed because one or more lines are too long
89
package-lock.json
generated
89
package-lock.json
generated
@ -116,6 +116,11 @@
|
||||
"queue-microtask": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
@ -173,6 +178,15 @@
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"bson": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.2.2.tgz",
|
||||
@ -214,6 +228,11 @@
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
|
||||
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA=="
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"cookie": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
|
||||
@ -498,6 +517,33 @@
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
|
||||
},
|
||||
"fs-jetpack": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-jetpack/-/fs-jetpack-4.1.0.tgz",
|
||||
"integrity": "sha512-h4nHLIcCaxnXfUWhwP+mLnar03R2DBlqicNvKJG44TJob8RV6GB8EKNwJgSaBeDAfqWhqq01y+Ao96vRwpXlPw==",
|
||||
"requires": {
|
||||
"minimatch": "^3.0.2",
|
||||
"rimraf": "^2.6.3"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"helmet": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/helmet/-/helmet-4.3.1.tgz",
|
||||
@ -528,6 +574,15 @@
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
||||
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
@ -696,6 +751,14 @@
|
||||
"mime-db": "1.45.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
@ -798,6 +861,19 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
|
||||
@ -906,6 +982,14 @@
|
||||
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.4.tgz",
|
||||
"integrity": "sha512-5C9HXdzK8EAqN7JDif30jqsBzavB7wLpaubisuQIGHWf2gUXSpzy6ArX/+Da8RjFpagWsCn+pIgxTMAmKw9Zug=="
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
||||
"requires": {
|
||||
"glob": "^7.1.3"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -1117,6 +1201,11 @@
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"fastify-helmet": "^5.0.3",
|
||||
"fastify-jwt": "^2.2.0",
|
||||
"fastify-plugin": "^3.0.0",
|
||||
"fs-jetpack": "^4.1.0",
|
||||
"mime-types": "^2.1.28",
|
||||
"mongoose": "5.10.3",
|
||||
"mongoose-findorcreate": "^3.0.0",
|
||||
|
@ -10,6 +10,7 @@ import {RouterMap} from './decorators/router';
|
||||
import {mongoose} from "@typegoose/typegoose";
|
||||
import logger from './logger/logger';
|
||||
import {Config} from "./cfg/Config";
|
||||
import {initData} from "./common/GConfig";
|
||||
|
||||
const zReqParserPlugin = require('./plugins/zReqParser');
|
||||
const apiAuthPlugin = require('./plugins/apiauth');
|
||||
@ -132,6 +133,7 @@ export class ApiServer {
|
||||
self.registerRouter();
|
||||
self.setErrHandler();
|
||||
self.setFormatSend();
|
||||
initData();
|
||||
this.server.listen({port: config.port}, (err: any, address: any) => {
|
||||
if (err) {
|
||||
logger.log(err)
|
||||
|
33
src/cfg/parsers/HeroCfg.ts
Normal file
33
src/cfg/parsers/HeroCfg.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import {Cfg} from "../../common/DataParser";
|
||||
|
||||
export class HeroCfg implements Cfg{
|
||||
name: "HeroCfg";
|
||||
|
||||
public id: number;
|
||||
public herounit_id: number;
|
||||
public ex_skill: number;
|
||||
public follower1id: number;
|
||||
public follower2id: number;
|
||||
public follower3id: number;
|
||||
public follower4id: number;
|
||||
|
||||
public decode(data: any) {
|
||||
this.id = data.id;
|
||||
this.herounit_id = data.herounit_id;
|
||||
this.ex_skill = data.ex_skill;
|
||||
this.follower1id = data.follower1id;
|
||||
this.follower2id = data.follower2id;
|
||||
this.follower3id = data.follower3id;
|
||||
this.follower4id = data.follower4id;
|
||||
};
|
||||
|
||||
public isOK (uniqueID: number, param1: any, param2: any): boolean {
|
||||
if((param1 == undefined || param1 == null) && (param2 == undefined || param2 == null)){
|
||||
return this.id == uniqueID;
|
||||
}
|
||||
if(param2 == undefined || param2 == null){
|
||||
return this.id == uniqueID && this.id == param1;
|
||||
}
|
||||
return this.id == uniqueID && this.id == param1 && this.id == param2;
|
||||
};
|
||||
};
|
55
src/cfg/parsers/UnitCfg.ts
Normal file
55
src/cfg/parsers/UnitCfg.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import {Cfg} from "../../common/DataParser";
|
||||
|
||||
export class UnitCfg implements Cfg{
|
||||
name: "UnitCfg";
|
||||
|
||||
public id: number;
|
||||
public unit_name: number;
|
||||
public unittypei_id: number;
|
||||
public hero_hp: number;
|
||||
public spell_power: number;
|
||||
public suck_blood: number;
|
||||
public defense: number;
|
||||
public race_id: number;
|
||||
public job_id: number;
|
||||
public powernum_typeid: number;
|
||||
public powernum: number;
|
||||
public num_signid: number;
|
||||
public edd_effid: number;
|
||||
public edd_effnum: number;
|
||||
public eddeffnum_signid: number;
|
||||
public base_skill1id: number;
|
||||
public base_skill2id: number;
|
||||
public base_skill3id: number;
|
||||
|
||||
public decode(data: any) {
|
||||
this.id = data.id;
|
||||
this.unit_name = data.unit_name;
|
||||
this.unittypei_id = data.unittypei_id;
|
||||
this.hero_hp = data.hero_hp;
|
||||
this.spell_power = data.spell_power;
|
||||
this.suck_blood = data.suck_blood;
|
||||
this.defense = data.defense;
|
||||
this.race_id = data.race_id;
|
||||
this.job_id = data.job_id;
|
||||
this.powernum_typeid = data.powernum_typeid;
|
||||
this.powernum = data.powernum;
|
||||
this.num_signid = data.num_signid;
|
||||
this.edd_effid = data.edd_effid;
|
||||
this.edd_effnum = data.edd_effnum;
|
||||
this.eddeffnum_signid = data.eddeffnum_signid;
|
||||
this.base_skill1id = data.base_skill1id;
|
||||
this.base_skill2id = data.base_skill2id;
|
||||
this.base_skill3id = data.base_skill3id;
|
||||
};
|
||||
|
||||
public isOK (uniqueID: number, param1: any, param2: any): boolean {
|
||||
if((param1 == undefined || param1 == null) && (param2 == undefined || param2 == null)){
|
||||
return this.id == uniqueID;
|
||||
}
|
||||
if(param2 == undefined || param2 == null){
|
||||
return this.id == uniqueID && this.id == param1;
|
||||
}
|
||||
return this.id == uniqueID && this.id == param1 && this.id == param2;
|
||||
};
|
||||
};
|
81
src/common/DataParser.ts
Normal file
81
src/common/DataParser.ts
Normal file
@ -0,0 +1,81 @@
|
||||
import * as jetpack from "fs-jetpack";
|
||||
import {BaseConst} from "../constants/BaseConst";
|
||||
import {error} from "./Debug";
|
||||
|
||||
const $cfg = new Map();
|
||||
const jsonPath = 'config';
|
||||
export var DataParser = (function (){
|
||||
const parsers: { [index: string]: ConfigDataParser } = {};
|
||||
|
||||
return {
|
||||
regParser,
|
||||
regCommonParser(key: string, CfgCreator: { new (): Cfg }, idkey = "id") {
|
||||
regParser(key, (data: any[]): any => {
|
||||
if (!data) return;
|
||||
let dict = new Map();
|
||||
for (let i = 0, len = data.length; i < len; i++) {
|
||||
let obj = data[i];
|
||||
if (!obj[idkey]) {
|
||||
error(`配置${key}的数据有误,唯一标识 ${idkey} 值为0或者没有${idkey}`);
|
||||
continue;
|
||||
}
|
||||
let to = new CfgCreator();
|
||||
to.decode(obj);
|
||||
if (dict.has(to.id)) {
|
||||
error(`配置${key}的数据有误,唯一标识 id 有重复值:${to.id}`)
|
||||
process.abort();
|
||||
}
|
||||
dict.set(to.id, to);
|
||||
}
|
||||
return dict;
|
||||
});
|
||||
},
|
||||
loadAll() {
|
||||
let fileArr = jetpack.list(jsonPath);
|
||||
for (let f of fileArr) {
|
||||
let key = f.replace('_tbl.json', '');
|
||||
let parser = parsers[key];
|
||||
let json = jetpack.read(`${jsonPath}/${f}`, 'json');
|
||||
if (parser && json){
|
||||
if (Array.isArray(json)) {
|
||||
let data = parser(json);
|
||||
if (data) { // 支持一些void的情况
|
||||
$cfg.set(key, data);
|
||||
}
|
||||
} else {
|
||||
$cfg.set(key, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.assign(global, {
|
||||
$cfg: $cfg
|
||||
})
|
||||
},
|
||||
}
|
||||
/**
|
||||
* 注册配置解析
|
||||
* @param key 配置的标识
|
||||
* @param parser 解析器
|
||||
*/
|
||||
function regParser(key: string, parser: ConfigDataParser) {
|
||||
parsers[key] = parser;
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* 配置数据解析函数
|
||||
*/
|
||||
export interface ConfigDataParser {
|
||||
(data: any): any;
|
||||
}
|
||||
|
||||
export interface Cfg
|
||||
{
|
||||
/**
|
||||
* 解析配置
|
||||
* @param {*} data
|
||||
* @param {*} [local] 没有接口,但是需要本地赋值的数据
|
||||
*/
|
||||
decode?: { (local?: any):void };
|
||||
id?: number;
|
||||
}
|
16
src/common/Debug.ts
Normal file
16
src/common/Debug.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import debug from 'debug';
|
||||
|
||||
debug.log = console.info.bind(console);
|
||||
|
||||
export const debugRoom = debug('jc:room');
|
||||
|
||||
export const msgLog = debug('jc:msg');
|
||||
|
||||
export const robotLog = debug('jc:robot');
|
||||
|
||||
export const assistLog = debug('jc:assist');
|
||||
|
||||
export const cardLog = debug('jc:card');
|
||||
|
||||
export const error = debug('jc:error');
|
||||
error.log = console.error.bind(console);
|
14
src/common/GConfig.ts
Normal file
14
src/common/GConfig.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {DataParser} from "./DataParser";
|
||||
import {HeroCfg} from "../cfg/parsers/HeroCfg";
|
||||
import {UnitCfg} from "../cfg/parsers/UnitCfg";
|
||||
import {BaseConst} from "../constants/BaseConst";
|
||||
|
||||
|
||||
export function initData() {
|
||||
const rP = DataParser.regCommonParser.bind(DataParser);
|
||||
rP(BaseConst.HERO, HeroCfg);
|
||||
rP(BaseConst.UNIT, UnitCfg);
|
||||
DataParser.loadAll();
|
||||
|
||||
}
|
||||
|
70
src/constants/BaseConst.ts
Normal file
70
src/constants/BaseConst.ts
Normal file
@ -0,0 +1,70 @@
|
||||
export class BaseConst {
|
||||
// 初始手牌数量
|
||||
public static readonly INIT_CARD_NUM = 99001;
|
||||
// 可更换的初始手牌上限
|
||||
public static readonly CARD_CHANGE_NUM = 99002;
|
||||
// 更换初始手牌时限
|
||||
public static readonly CARD_CHANGE_TIME = 99003;
|
||||
// 每回合发牌数量
|
||||
public static readonly ROUND_DRAW_NUM = 99004;
|
||||
// 每满几论决斗一次
|
||||
public static readonly DUEL_ROUND_NUM = 99005;
|
||||
// 第几次决斗后游戏结束
|
||||
public static readonly MAX_DUEL_NUM = 99006;
|
||||
// 玩家手牌数量上限
|
||||
public static readonly MAX_CARD_NUM = 99007;
|
||||
// 出牌公共时限
|
||||
public static readonly MAX_DISCARD_TIME = 99008;
|
||||
// 吃牌公共时限
|
||||
public static readonly MAX_EAT_TIME = 99009;
|
||||
// 操作公共时限
|
||||
public static readonly PLAYER_ACT_TIME = 99010;
|
||||
// 玩家灵活时限
|
||||
public static readonly MAX_EXT_TIME = 99011;
|
||||
// 每回合增加玩家灵活时限数值
|
||||
public static readonly ROUND_EXT_TIME = 99012;
|
||||
// 玩家随从上限
|
||||
public static readonly MAX_PLAYER_PET_COUNT = 99013;
|
||||
// 结算时间
|
||||
public static readonly ROUND_SHOW_TIME = 99014;
|
||||
// 基本奖励分
|
||||
public static readonly BASE_ADD_SCORE = 99015;
|
||||
// 额外奖励分
|
||||
public static readonly EXTRA_ADD_SCORE = 99016;
|
||||
// 游戏结果显示时间, 也是游戏重开等待时间
|
||||
public static readonly GAME_RESULT_TIME = 99017;
|
||||
// 匹配等待时间, 时间结束后, 填充机器人;
|
||||
public static readonly WAITING_PLAYER_TIME = 99018;
|
||||
// 匹配等待时, 每进入一个玩家, 等待时间延长n秒
|
||||
public static readonly WAITING_PLAYER_ONEPLUS = 99019;
|
||||
// 英雄选择时间
|
||||
public static readonly PICK_HERO_TIME = 99020;
|
||||
// 机器人操作最小时间
|
||||
public static readonly ROBOT_ACTTIME_MIN = 99021;
|
||||
// 机器人操作最大时间
|
||||
public static readonly ROBOT_ACTTIME_MAX = 99022;
|
||||
// 队友死亡后,补牌数量
|
||||
public static readonly TEAM_DEAD_ADDNUM = 99023
|
||||
// 胡牌张数(自摸)
|
||||
public static readonly SELF_EAT_COUNT = 99024
|
||||
// 胡牌张数(吃牌)
|
||||
public static readonly OTHER_EAT_COUNT = 99025
|
||||
// 轮空轮的间隔时间
|
||||
public static readonly EMPTY_ROUND_TIME = 99026
|
||||
// 各玩家初始卡牌数
|
||||
public static readonly PLAYER1_INIT_NUM = 99027
|
||||
public static readonly PLAYER2_INIT_NUM = 99028
|
||||
public static readonly PLAYER3_INIT_NUM = 99029
|
||||
public static readonly PLAYER4_INIT_NUM = 99030
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static readonly COMPOUND = "compound";
|
||||
public static readonly EFFECTCARD = "effectcard";
|
||||
public static readonly HERO = "hero";
|
||||
public static readonly SKILL = "skill";
|
||||
public static readonly SYSTEMCARD = "systemcard";
|
||||
public static readonly UNIT = "unit";
|
||||
}
|
@ -101,7 +101,9 @@ export default class CardController extends BaseController {
|
||||
throw new ZError(101, '卷轴不足');
|
||||
}
|
||||
account.moneys.set(MoneyTypeConst.CARD_SCROLL, money - count);
|
||||
// TODO: 随机取count张卡牌, 并与当前已有的卡比较, 将新卡添加进用户卡组
|
||||
|
||||
// TODO: 随机取count张卡牌, 并与当前已有的卡比较, 将新卡添加进用户卡组
|
||||
await account.save();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
29
src/decorators/singleton.decorator.ts
Normal file
29
src/decorators/singleton.decorator.ts
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 单例化一个class
|
||||
* 使用方法:
|
||||
* @singleton
|
||||
* class Test {}
|
||||
* new Test() === new Test() // returns `true`
|
||||
* 也可以不使用 decorator
|
||||
* const TestSingleton = singleton(Test)
|
||||
* new TestSingleton() === new TestSingleton() //returns 'true'
|
||||
*/
|
||||
|
||||
export const SINGLETON_KEY = Symbol()
|
||||
|
||||
export type Singleton<T extends new (...args: any[]) => any> = T & {
|
||||
[SINGLETON_KEY]: T extends new (...args: any[]) => infer I ? I : never
|
||||
}
|
||||
export const singleton = <T extends new (...args: any[]) => any>(classTarget: T) =>
|
||||
new Proxy(classTarget, {
|
||||
construct(target: Singleton<T>, argumentsList, newTarget) {
|
||||
// Skip proxy for children
|
||||
if (target.prototype !== newTarget.prototype) {
|
||||
return Reflect.construct(target, argumentsList, newTarget)
|
||||
}
|
||||
if (!target[SINGLETON_KEY]) {
|
||||
target[SINGLETON_KEY] = Reflect.construct(target, argumentsList, newTarget)
|
||||
}
|
||||
return target[SINGLETON_KEY]
|
||||
},
|
||||
})
|
11
src/global.d.ts
vendored
Normal file
11
src/global.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export {};
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
NODE_ENV: string
|
||||
ROOT_PATH: string
|
||||
$cfg: any
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user