增加配表

This commit is contained in:
zhl 2020-12-01 17:02:01 +08:00
parent 0a7146d200
commit 3d6b3b24d8
28 changed files with 1116 additions and 34 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
.idea
.DS_Store
lib

67
configs/compound_tbl.json Normal file
View File

@ -0,0 +1,67 @@
[
{
"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": 8
},
{
"id": 99009,
"type_id": 2,
"value": 8
},
{
"id": 99010,
"type_id": 2,
"value": 15
},
{
"id": 99011,
"type_id": 2,
"value": 20
},
{
"id": 99012,
"type_id": 2,
"value": 5
},
{
"id": 99012,
"type_id": 1,
"value": 5
}
]

View File

@ -0,0 +1,74 @@
[
{
"id": 20011,
"type_id": 1,
"eff1_id": 41011,
"eff2_id": 0,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20021,
"type_id": 1,
"eff1_id": 41021,
"eff2_id": 40131,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20031,
"type_id": 1,
"eff1_id": 41031,
"eff2_id": 0,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20041,
"type_id": 1,
"eff1_id": 41041,
"eff2_id": 40151,
"eff3_id": 40161,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20051,
"type_id": 1,
"eff1_id": 41051,
"eff2_id": 40171,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20061,
"type_id": 1,
"eff1_id": 41061,
"eff2_id": 40181,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20071,
"type_id": 2,
"eff1_id": 40191,
"eff2_id": 0,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
},
{
"id": 20081,
"type_id": 2,
"eff1_id": 40201,
"eff2_id": 0,
"eff3_id": 0,
"eff4_id": 0,
"eff5_id": 0
}
]

22
configs/hero_tbl.json Normal file
View File

@ -0,0 +1,22 @@
[
{
"id": 30011,
"unit_id": 50011,
"ex_skill": 0
},
{
"id": 30021,
"unit_id": 50021,
"ex_skill": 0
},
{
"id": 30031,
"unit_id": 50031,
"ex_skill": 0
},
{
"id": 30041,
"unit_id": 50041,
"ex_skill": 0
}
]

442
configs/skill_tbl.json Normal file
View File

@ -0,0 +1,442 @@
[
{
"id": 40011,
"skill_type": 5,
"tigger_type": 5,
"cond_type": 1,
"cond_v1": 1,
"cond_v2": 4,
"effect_type": 2,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 4,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40021,
"skill_type": 5,
"tigger_type": 5,
"cond_type": 1,
"cond_v1": 1,
"cond_v2": 2,
"effect_type": 2,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 2,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40031,
"skill_type": 5,
"tigger_type": 4,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 1,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 1,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40041,
"skill_type": 5,
"tigger_type": 6,
"cond_type": 2,
"cond_v1": 3,
"cond_v2": 4,
"effect_type": 1,
"friendly": 2,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 1,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40051,
"skill_type": 5,
"tigger_type": 6,
"cond_type": 2,
"cond_v1": 3,
"cond_v2": 4,
"effect_type": 1,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 1,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40061,
"skill_type": 5,
"tigger_type": 1,
"cond_type": 4,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 4,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 2,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40111,
"skill_type": 5,
"tigger_type": 0,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 0,
"friendly": 1,
"target": 2,
"range": 1,
"eff_v1": 4,
"eff_v2": 30,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40121,
"skill_type": 5,
"tigger_type": 0,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 10,
"friendly": 1,
"target": 2,
"range": 2,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40131,
"skill_type": 2,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 5,
"friendly": 1,
"target": 2,
"range": 1,
"eff_v1": 1,
"eff_v2": 20,
"eff_v3": 1,
"eff_v4": 20,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40141,
"skill_type": 4,
"tigger_type": 0,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 6,
"friendly": 1,
"target": 2,
"range": 3,
"eff_v1": 1,
"eff_v2": 15,
"eff_v3": 1,
"eff_v4": 15,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40151,
"skill_type": 2,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 1,
"friendly": 3,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 1,
"eff_v3": 1,
"eff_v4": 1,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40161,
"skill_type": 2,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 1,
"friendly": 1,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 20,
"eff_v3": 1,
"eff_v4": 2,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40171,
"skill_type": 2,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 3,
"friendly": 4,
"target": 1,
"range": 0,
"eff_v1": 1,
"eff_v2": 1,
"eff_v3": 1,
"eff_v4": 1,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40181,
"skill_type": 2,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 7,
"friendly": 4,
"target": 2,
"range": 1,
"eff_v1": 1,
"eff_v2": 20,
"eff_v3": 1,
"eff_v4": 20,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40191,
"skill_type": 1,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 7,
"friendly": 4,
"target": 2,
"range": 1,
"eff_v1": 2,
"eff_v2": 0,
"eff_v3": 2,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 40201,
"skill_type": 1,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 7,
"friendly": 4,
"target": 2,
"range": 2,
"eff_v1": 1,
"eff_v2": 15,
"eff_v3": 1,
"eff_v4": 15,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 0,
"skill_type": 0,
"tigger_type": 0,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 0,
"friendly": 0,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 0,
"skill_type": 0,
"tigger_type": 0,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 0,
"friendly": 0,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 0,
"unit_count": 0,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 41011,
"skill_type": 5,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 8,
"friendly": 1,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 51011,
"unit_count": 1,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 41021,
"skill_type": 5,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 8,
"friendly": 1,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 51021,
"unit_count": 1,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 41031,
"skill_type": 5,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 8,
"friendly": 1,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 51031,
"unit_count": 1,
"subskill_id": 0,
"subskill_count": 0
},
{
"id": 41041,
"skill_type": 5,
"tigger_type": 3,
"cond_type": 0,
"cond_v1": 0,
"cond_v2": 0,
"effect_type": 8,
"friendly": 1,
"target": 0,
"range": 0,
"eff_v1": 0,
"eff_v2": 0,
"eff_v3": 0,
"eff_v4": 0,
"unit_id": 51041,
"unit_count": 1,
"subskill_id": 0,
"subskill_count": 0
}
]

View File

@ -0,0 +1,86 @@
[
{
"id": 10001,
"type_id": 1,
"count": 16,
"point": 1,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10011,
"type_id": 1,
"count": 16,
"point": 2,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10021,
"type_id": 1,
"count": 16,
"point": 3,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10031,
"type_id": 1,
"count": 16,
"point": 4,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10041,
"type_id": 1,
"count": 16,
"point": 5,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10051,
"type_id": 1,
"count": 16,
"point": 6,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10061,
"type_id": 1,
"count": 16,
"point": 7,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10071,
"type_id": 1,
"count": 16,
"point": 8,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10081,
"type_id": 1,
"count": 16,
"point": 9,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10091,
"type_id": 1,
"count": 16,
"point": 10,
"weight": "20011:10|20021:10|20031:10|20041:10|20051:10|20061:10|20071:10|20081:10"
},
{
"id": 10101,
"type_id": 2,
"count": 16,
"point": 100,
"weight": ""
},
{
"id": 10111,
"type_id": 3,
"count": 8,
"point": 1000,
"weight": ""
}
]

142
configs/unit_tbl.json Normal file
View File

@ -0,0 +1,142 @@
[
{
"id": 50011,
"type_id": 1,
"hero_hp": 150,
"raceid": 8,
"job_id": 1,
"power_type": 1,
"power_value": 30,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 40011,
"skill2_id": 0,
"skill3_id": 0
},
{
"id": 50021,
"type_id": 1,
"hero_hp": 150,
"raceid": 9,
"job_id": 1,
"power_type": 1,
"power_value": 30,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 40031,
"skill2_id": 40021,
"skill3_id": 0
},
{
"id": 50031,
"type_id": 1,
"hero_hp": 150,
"raceid": 4,
"job_id": 1,
"power_type": 1,
"power_value": 30,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 40041,
"skill2_id": 40051,
"skill3_id": 40021
},
{
"id": 50041,
"type_id": 1,
"hero_hp": 150,
"raceid": 1,
"job_id": 1,
"power_type": 1,
"power_value": 30,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 40061,
"skill2_id": 40021,
"skill3_id": 0
},
{
"id": 0,
"type_id": 0,
"hero_hp": 0,
"raceid": 0,
"job_id": 0,
"power_type": 0,
"power_value": 0,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 0,
"skill2_id": 0,
"skill3_id": 0
},
{
"id": 0,
"type_id": 0,
"hero_hp": 0,
"raceid": 0,
"job_id": 0,
"power_type": 0,
"power_value": 0,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 0,
"skill2_id": 0,
"skill3_id": 0
},
{
"id": 51011,
"type_id": 2,
"hero_hp": 0,
"raceid": 5,
"job_id": 1,
"power_type": 2,
"power_value": 0,
"eff_type": 1,
"eff_value": 20,
"skill1_id": 40111,
"skill2_id": 40121,
"skill3_id": 0
},
{
"id": 51021,
"type_id": 2,
"hero_hp": 0,
"raceid": 1,
"job_id": 1,
"power_type": 2,
"power_value": 0,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 0,
"skill2_id": 0,
"skill3_id": 0
},
{
"id": 51031,
"type_id": 2,
"hero_hp": 0,
"raceid": 11,
"job_id": 1,
"power_type": 3,
"power_value": 0,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 40141,
"skill2_id": 0,
"skill3_id": 0
},
{
"id": 51041,
"type_id": 2,
"hero_hp": 0,
"raceid": 2,
"job_id": 1,
"power_type": 2,
"power_value": 0,
"eff_type": 0,
"eff_value": 0,
"skill1_id": 0,
"skill2_id": 0,
"skill3_id": 0
}
]

28
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "my-app",
"name": "card_svr",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
@ -434,8 +434,7 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"bcrypt-pbkdf": {
"version": "1.0.2",
@ -497,7 +496,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -639,8 +637,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"content-disposition": {
"version": "0.5.3",
@ -1001,11 +998,19 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"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=",
"dev": true
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"fsevents": {
"version": "2.1.3",
@ -1046,7 +1051,6 @@
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@ -1180,7 +1184,6 @@
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
@ -1524,7 +1527,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -1795,8 +1797,7 @@
"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=",
"dev": true
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-key": {
"version": "2.0.1",
@ -2064,7 +2065,6 @@
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
"dev": true,
"requires": {
"glob": "^7.1.3"
}

View File

@ -2,19 +2,14 @@
"private": true,
"name": "card_svr",
"version": "1.0.0",
"description": "npm init template for bootstrapping an empty Colyseus project",
"main": "lib/index.js",
"typings" : "src/global.d.ts",
"scripts": {
"start": "ts-node-dev src/index.ts",
"start": "ts-node-dev --files src/index.ts",
"loadtest": "colyseus-loadtest loadtest/example.ts --room my_room --numClients 3",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "UNLICENSED",
"bugs": {
"url": "https://github.com/colyseus/create-colyseus/issues"
},
"homepage": "https://github.com/colyseus/create-colyseus#readme",
"devDependencies": {
"@colyseus/loadtest": "^0.14.0",
"@types/cors": "^2.8.6",
@ -30,6 +25,7 @@
"colyseus": "^0.14.0",
"cors": "^2.8.5",
"express": "^4.16.4",
"express-jwt": "^5.3.1"
"express-jwt": "^5.3.1",
"fs-jetpack": "^4.1.0"
}
}

25
src/cfgs/BaseCfg.ts Normal file
View File

@ -0,0 +1,25 @@
import {Cfg} from "../common/DataParser";
export class BaseCfg implements Cfg{
/**
* ID
*/
public id: number;
/**
*
*/
public value: number;
/**
*
*/
public valueType: number;
public decode(data: any) {
this.id = data.id;
this.value = data.value;
this.valueType = data.type_id;
}
}

22
src/cfgs/EffectCardCfg.ts Normal file
View File

@ -0,0 +1,22 @@
import {Cfg} from "../common/DataParser";
export class EffectCardCfg implements Cfg{
public id: number;
public typeId: number;
public eff1Id: number;
public eff2Id: number;
public eff3Id: number;
public eff4Id: number;
public eff5Id: number;
public decode(data: any) {
this.id = data.id;
this.typeId = data.type_id;
this.eff1Id = data.eff1_id;
this.eff2Id = data.eff2_id;
this.eff3Id = data.eff3_id;
this.eff4Id = data.eff4_id;
this.eff5Id = data.eff5_id;
}
}

13
src/cfgs/HeroCfg.ts Normal file
View File

@ -0,0 +1,13 @@
import {Cfg} from "../common/DataParser";
export class HeroCfg implements Cfg{
public id: number;
public unitId: number;
public exSkill: number;
public decode(data: any) {
this.id = data.id;
this.unitId = data.unit_id;
this.exSkill = data.ex_skill;
}
}

43
src/cfgs/SkillCfg.ts Normal file
View File

@ -0,0 +1,43 @@
import {Cfg} from "../common/DataParser";
export class SkillCfg implements Cfg{
public id: number;
public skillType: number;
public triggerType: number;
public condType: number;
public condV1: number;
public condV2: number;
public effectType: number;
public friendly: number;
public target: number;
public range: number;
public effV1: number;
public effV2: number;
public effV3: number;
public effV4: number;
public unitId: number;
public unitCount: number;
public subSkillId: number;
public subSkillCount: number;
public decode(data: any) {
this.id = data.id;
this.skillType = data.skill_type;
this.triggerType = data.tigger_type;
this.condType = data.cond_type;
this.condV1 = data.cond_v1;
this.condV2 = data.cond_v2;
this.effectType = data.effect_type;
this.friendly = data.friendly;
this.target = data.target;
this.range = data.range;
this.effV1 = data.eff_v1;
this.effV2 = data.eff_v2;
this.effV3 = data.eff_v3;
this.effV4 = data.eff_v4;
this.unitId = data.unit_id;
this.unitCount = data.unit_count;
this.subSkillId = data.subskill_id;
this.subSkillCount = data.subskill_count;
}
}

15
src/cfgs/SystemCardCfg.ts Normal file
View File

@ -0,0 +1,15 @@
import {Cfg} from "../common/DataParser";
export class SystemCardCfg implements Cfg {
public id: number;
public typeId: number;
public count: number;
public point: number;
public weight: string;
public decode(data: any) {
this.id = data.id;
this.typeId = data.type_id;
this.point = data.point;
this.weight = data.weight;
}
}

32
src/cfgs/UnitCfg.ts Normal file
View File

@ -0,0 +1,32 @@
import {Cfg} from "../common/DataParser";
export class UnitCfg implements Cfg{
public id: number;
public typeId: number;
public heroHp: number;
public raceId: number;
public jobId: number;
public powerType: number;
public powerValue: number;
public effType: number;
public effValue: number;
public skill1Id: number;
public skill2Id: number;
public skill3Id: number;
public decode(data: any) {
this.id = data.id;
this.typeId = data.type_id;
this.heroHp = data.hero_hp;
this.raceId = data.raceid;
this.jobId = data.job_id;
this.powerType = data.power_type;
this.powerValue = data.power_value;
this.effType = data.eff_type;
this.effValue = data.eff_value;
this.skill1Id = data.skill1_id;
this.skill2Id = data.skill2_id;
this.skill3Id = data.skill3_id;
}
}

60
src/common/DataParser.ts Normal file
View File

@ -0,0 +1,60 @@
import * as jetpack from "fs-jetpack";
const $cfg = <any>{};
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 = {};
return dict;
});
},
loadAll() {
let jsonPath = `configs`;
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){
$cfg[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 };
}

19
src/common/GConfig.ts Normal file
View File

@ -0,0 +1,19 @@
import {BaseCfg} from "../cfgs/BaseCfg";
import {DataParser} from "./DataParser";
import {EffectCardCfg} from "../cfgs/EffectCardCfg";
import {HeroCfg} from "../cfgs/HeroCfg";
import {SkillCfg} from "../cfgs/SkillCfg";
import {SystemCardCfg} from "../cfgs/SystemCardCfg";
import {UnitCfg} from "../cfgs/UnitCfg";
export function initData() {
const rP = DataParser.regCommonParser.bind(DataParser);
rP("compound", BaseCfg);
rP("effectcard", EffectCardCfg);
rP("hero", HeroCfg);
rP("skill", SkillCfg);
rP("systemcard", SystemCardCfg);
rP("unit", UnitCfg);
DataParser.loadAll();
}

13
src/global.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
export {};
declare var console1: Console;
declare global {
namespace NodeJS {
interface Global {
NODE_ENV: string
ROOT_PATH: string
$cfg: any
}
}
}

View File

@ -7,13 +7,16 @@ import { monitor } from "@colyseus/monitor";
import { GeneralRoom } from "./rooms/GeneralRoom";
import {MongooseDriver} from "colyseus/lib/matchmaker/drivers/MongooseDriver";
import {initData} from "./common/GConfig";
const port = Number(process.env.PORT || 2567);
const app = express()
app.use(cors());
app.use(express.json())
initData();
const server = http.createServer(app);
const gameServer = new Server({
server,

View File

@ -12,10 +12,6 @@ export class GeneralRoom extends Room {
maxClients = 4;
clientMap = new Map();
getClient(sessionId: string) {
return this.clientMap.get(sessionId);
}
onCreate (options: any) {
this.setState(new CardGameState());
this.state.gameSate = 0;

View File

@ -5,7 +5,7 @@ export class ChildAsyncCommand extends Command<CardGameState, { i: number }> {
async execute({ i }: {i: number}) {
await new Promise((resolve) => {
setTimeout(() => {
this.state.i += i;
this.state.round += i;
resolve();
}, 100)
})

View File

@ -3,6 +3,6 @@ import { CardGameState } from "../schema/CardGameState";
export class ChildCommand extends Command<CardGameState, { i: number }> {
execute({ i }: {i: number}) {
this.state.i += i;
this.state.round += i;
}
}

View File

@ -4,7 +4,7 @@ import {ChildAsyncCommand} from "./ChildAsyncCommand";
export class EnqueueAsyncCommand extends Command<CardGameState, { count: number }> {
async execute({ count }: {count: number}) {
this.state.i = 0;
this.state.round = 0;
return [...Array(count)].map(_ =>
new ChildAsyncCommand().setPayload({ i: count }));

View File

@ -5,7 +5,7 @@ import {ChildCommand} from "./ChildCommand";
export class EnqueueCommand extends Command<CardGameState, { count: number }> {
execute({ count }: {count: number}) {
this.state.i = 0;
this.state.round = 0;
return [...Array(count)].map(_ =>
new ChildCommand().setPayload({ i: count }));

View File

@ -1,5 +1,4 @@
import {Schema, type, filter} from "@colyseus/schema";
import { Client } from "colyseus";
export class Card extends Schema {

View File

@ -27,8 +27,11 @@ export class CardGameState extends Schema {
@type("string")
subTurn: string;
/**
*
*/
@type("number")
i: number;
round: number;
/**
*
*/

View File

@ -1,6 +1,7 @@
import {MapSchema, SetSchema, Schema, type} from "@colyseus/schema";
import {Card} from "./Card";
import {Pet} from "./Pet";
import {Card} from "./Card";
export class Player extends Schema {
@type("number")

View File

@ -1,7 +1,15 @@
{
"ts-node": {
"files": true
},
"files": [
"src/index.ts",
"src/global.d.ts"
],
"compilerOptions": {
"outDir": "lib",
"target": "es6",
"baseUrl": "./src",
"module": "commonjs",
"strict": true,
"strictNullChecks": false,