diff --git a/.gitignore b/.gitignore index c727bb7..aedfdd8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .idea .DS_Store +lib diff --git a/configs/compound_tbl.json b/configs/compound_tbl.json new file mode 100644 index 0000000..9f3ddcf --- /dev/null +++ b/configs/compound_tbl.json @@ -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 + } +] \ No newline at end of file diff --git a/configs/effectcard_tbl.json b/configs/effectcard_tbl.json new file mode 100644 index 0000000..30d5d5b --- /dev/null +++ b/configs/effectcard_tbl.json @@ -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 + } +] \ No newline at end of file diff --git a/configs/hero_tbl.json b/configs/hero_tbl.json new file mode 100644 index 0000000..442174a --- /dev/null +++ b/configs/hero_tbl.json @@ -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 + } +] \ No newline at end of file diff --git a/configs/skill_tbl.json b/configs/skill_tbl.json new file mode 100644 index 0000000..b22ec2c --- /dev/null +++ b/configs/skill_tbl.json @@ -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 + } +] \ No newline at end of file diff --git a/configs/systemcard_tbl.json b/configs/systemcard_tbl.json new file mode 100644 index 0000000..6ef971a --- /dev/null +++ b/configs/systemcard_tbl.json @@ -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": "" + } +] \ No newline at end of file diff --git a/configs/unit_tbl.json b/configs/unit_tbl.json new file mode 100644 index 0000000..e064437 --- /dev/null +++ b/configs/unit_tbl.json @@ -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 + } +] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9c1b3da..254f2cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index ef8fbbf..1c2158c 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/cfgs/BaseCfg.ts b/src/cfgs/BaseCfg.ts new file mode 100644 index 0000000..7aa12bf --- /dev/null +++ b/src/cfgs/BaseCfg.ts @@ -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; + } +} + + diff --git a/src/cfgs/EffectCardCfg.ts b/src/cfgs/EffectCardCfg.ts new file mode 100644 index 0000000..52891e9 --- /dev/null +++ b/src/cfgs/EffectCardCfg.ts @@ -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; + } +} diff --git a/src/cfgs/HeroCfg.ts b/src/cfgs/HeroCfg.ts new file mode 100644 index 0000000..68a0cee --- /dev/null +++ b/src/cfgs/HeroCfg.ts @@ -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; + } +} diff --git a/src/cfgs/SkillCfg.ts b/src/cfgs/SkillCfg.ts new file mode 100644 index 0000000..6d720b9 --- /dev/null +++ b/src/cfgs/SkillCfg.ts @@ -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; + } +} diff --git a/src/cfgs/SystemCardCfg.ts b/src/cfgs/SystemCardCfg.ts new file mode 100644 index 0000000..3511e56 --- /dev/null +++ b/src/cfgs/SystemCardCfg.ts @@ -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; + } +} diff --git a/src/cfgs/UnitCfg.ts b/src/cfgs/UnitCfg.ts new file mode 100644 index 0000000..04e21f9 --- /dev/null +++ b/src/cfgs/UnitCfg.ts @@ -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; + } +} diff --git a/src/common/DataParser.ts b/src/common/DataParser.ts new file mode 100644 index 0000000..ab64f8b --- /dev/null +++ b/src/common/DataParser.ts @@ -0,0 +1,60 @@ +import * as jetpack from "fs-jetpack"; + +const $cfg = {}; + +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 }; +} diff --git a/src/common/GConfig.ts b/src/common/GConfig.ts new file mode 100644 index 0000000..fc82828 --- /dev/null +++ b/src/common/GConfig.ts @@ -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(); +} + diff --git a/src/global.d.ts b/src/global.d.ts new file mode 100644 index 0000000..5bb8a8c --- /dev/null +++ b/src/global.d.ts @@ -0,0 +1,13 @@ +export {}; + +declare var console1: Console; + +declare global { + namespace NodeJS { + interface Global { + NODE_ENV: string + ROOT_PATH: string + $cfg: any + } + } +} diff --git a/src/index.ts b/src/index.ts index dc95887..6771c59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 7347671..3db6b60 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -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; diff --git a/src/rooms/commands/ChildAsyncCommand.ts b/src/rooms/commands/ChildAsyncCommand.ts index 1a9c7e0..31be852 100644 --- a/src/rooms/commands/ChildAsyncCommand.ts +++ b/src/rooms/commands/ChildAsyncCommand.ts @@ -5,7 +5,7 @@ export class ChildAsyncCommand extends Command { async execute({ i }: {i: number}) { await new Promise((resolve) => { setTimeout(() => { - this.state.i += i; + this.state.round += i; resolve(); }, 100) }) diff --git a/src/rooms/commands/ChildCommand.ts b/src/rooms/commands/ChildCommand.ts index b6ba4f9..19a6146 100644 --- a/src/rooms/commands/ChildCommand.ts +++ b/src/rooms/commands/ChildCommand.ts @@ -3,6 +3,6 @@ import { CardGameState } from "../schema/CardGameState"; export class ChildCommand extends Command { execute({ i }: {i: number}) { - this.state.i += i; + this.state.round += i; } } diff --git a/src/rooms/commands/EnqueueAsyncCommand.ts b/src/rooms/commands/EnqueueAsyncCommand.ts index 9086eac..e7998d0 100644 --- a/src/rooms/commands/EnqueueAsyncCommand.ts +++ b/src/rooms/commands/EnqueueAsyncCommand.ts @@ -4,7 +4,7 @@ import {ChildAsyncCommand} from "./ChildAsyncCommand"; export class EnqueueAsyncCommand extends Command { async execute({ count }: {count: number}) { - this.state.i = 0; + this.state.round = 0; return [...Array(count)].map(_ => new ChildAsyncCommand().setPayload({ i: count })); diff --git a/src/rooms/commands/EnqueueCommand.ts b/src/rooms/commands/EnqueueCommand.ts index e51cf44..0650c22 100644 --- a/src/rooms/commands/EnqueueCommand.ts +++ b/src/rooms/commands/EnqueueCommand.ts @@ -5,7 +5,7 @@ import {ChildCommand} from "./ChildCommand"; export class EnqueueCommand extends Command { execute({ count }: {count: number}) { - this.state.i = 0; + this.state.round = 0; return [...Array(count)].map(_ => new ChildCommand().setPayload({ i: count })); diff --git a/src/rooms/schema/Card.ts b/src/rooms/schema/Card.ts index 235bc95..6bbb002 100644 --- a/src/rooms/schema/Card.ts +++ b/src/rooms/schema/Card.ts @@ -1,5 +1,4 @@ import {Schema, type, filter} from "@colyseus/schema"; -import { Client } from "colyseus"; export class Card extends Schema { diff --git a/src/rooms/schema/CardGameState.ts b/src/rooms/schema/CardGameState.ts index 39ce56c..ffe4275 100644 --- a/src/rooms/schema/CardGameState.ts +++ b/src/rooms/schema/CardGameState.ts @@ -27,8 +27,11 @@ export class CardGameState extends Schema { @type("string") subTurn: string; + /** + * 轮次 + */ @type("number") - i: number; + round: number; /** * 当局游戏卡组队列 */ diff --git a/src/rooms/schema/Player.ts b/src/rooms/schema/Player.ts index dac5da8..f87314b 100644 --- a/src/rooms/schema/Player.ts +++ b/src/rooms/schema/Player.ts @@ -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") diff --git a/tsconfig.json b/tsconfig.json index 796e76b..6549b4f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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,