mm_workflow 1.5.0 → 1.6.1
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/common/mod/dispatcher/load_balance/index.js +8 -6
- package/common/mod/executor/custom/index.js +7 -8
- package/common/mod/generator/llm_gen_workflow/index.js +113 -100
- package/common/mod/manager/database/index.js +39 -26
- package/common/mod/manager/discovery/index.js +17 -3
- package/common/mod/manager/json_util.js +43 -31
- package/common/mod/observer/audit/index.js +7 -4
- package/common/mod/observer/prometheus/index.js +59 -42
- package/common/mod/receiver/webhook/index.js +30 -11
- package/index.js +0 -4
- package/kernel/blockly_converter.js +55 -33
- package/kernel/blockly_defs.js +88 -71
- package/kernel/bpmn_parser.js +27 -15
- package/kernel/kernel.js +145 -103
- package/kernel/kernel_config.js +33 -7
- package/kernel/workflow_engine.js +30 -17
- package/kernel/workflow_state.js +25 -8
- package/package.json +19 -11
- package/tool/circuit_breaker/index.js +187 -5
- package/tool/ip_block/index.js +20 -5
- package/tool/rate_limit/index.js +49 -5
- package/tool/sensitive/index.js +29 -5
- package/tool/spam/index.js +30 -5
- package/tool/sql_inject/index.js +35 -5
- package/tool/workflow_admin/index.js +65 -0
- package/tool/workflow_admin/tool.json +40 -0
- package/tool/workflow_run/index.js +81 -0
- package/tool/workflow_run/tool.json +60 -0
- package/common/workflow/wftest_1789472356864/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472356864/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472528456/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472528456/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472914308/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472914308/suggest_h.json +0 -14
- package/common/workflow/wftest_1789472926735/ok_wf.json +0 -20
- package/common/workflow/wftest_1789472926735/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473005165/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473005165/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473128440/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473128440/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473140984/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473140984/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473444205/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473444205/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473632028/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473632028/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473735755/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473735755/suggest_h.json +0 -14
- package/common/workflow/wftest_1789473793373/ok_wf.json +0 -20
- package/common/workflow/wftest_1789473793373/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474054650/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474054650/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474139961/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474139961/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474522109/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474522109/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474695647/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474695647/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474822920/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474822920/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474863955/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474863955/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474920642/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474920642/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474948523/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474948523/suggest_h.json +0 -14
- package/common/workflow/wftest_1789474977320/ok_wf.json +0 -20
- package/common/workflow/wftest_1789474977320/suggest_h.json +0 -14
- package/common/workflow/wftest_1789475013956/ok_wf.json +0 -20
- package/common/workflow/wftest_1789475013956/suggest_h.json +0 -14
- package/common/workflow/wftest_1789476776624/ok_wf.json +0 -20
- package/common/workflow/wftest_1789476776624/suggest_h.json +0 -14
- package/common/workflow/wftest_1789477074699/ok_wf.json +0 -20
- package/common/workflow/wftest_1789477074699/suggest_h.json +0 -14
- package/common/workflow/wftest_1789478655100/ok_wf.json +0 -20
- package/common/workflow/wftest_1789478655100/suggest_h.json +0 -14
- package/common/workflow/wftest_1789499010987/ok_wf.json +0 -20
- package/common/workflow/wftest_1789499010987/suggest_h.json +0 -14
- package/common/workflow/wftest_1789519488954/ok_wf.json +0 -20
- package/common/workflow/wftest_1789519488954/suggest_h.json +0 -14
- package/docs/API/345/217/202/350/200/203.md +0 -146
- package/docs/Blockly/346/230/240/345/260/204/346/226/271/346/241/210.md +0 -213
- package/docs/LLM/351/233/206/346/210/220/346/214/207/345/215/227.md +0 -29
- package/docs/Workflow/347/274/226/345/206/231/346/214/207/345/215/227.md +0 -194
- package/docs/ctx/344/270/212/344/270/213/346/226/207/350/257/246/350/247/243.md +0 -256
- package/docs//344/272/214/346/254/241/345/274/200/345/217/221/346/214/207/345/215/227.md +0 -151
- package/docs//345/244/232/345/215/217/350/256/256/350/247/246/345/217/221/346/214/207/345/215/227.md +0 -272
- package/docs//345/256/236/346/210/230/346/241/210/344/276/213.md +0 -392
- package/docs//345/267/245/344/275/234/346/265/201/350/246/206/347/233/226/345/210/206/346/236/220.md +0 -585
- package/docs//345/274/200/345/217/221/346/226/207/346/241/243.md +0 -200
- package/docs//345/277/253/351/200/237/345/274/200/345/247/213.md +0 -66
- package/docs//346/234/200/344/275/263/345/256/236/350/267/265.md +0 -265
- package/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +0 -29
- package/docs//346/240/270/345/277/203/346/246/202/345/277/265.md +0 -194
- package/docs//346/250/241/345/235/227/344/275/223/347/263/273/350/257/264/346/230/216.md +0 -111
- package/docs//346/250/241/345/235/227/346/270/205/345/215/225.md +0 -288
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/AI/345/267/245/344/275/234/346/265/201/347/224/237/346/210/220/346/210/220/346/234/254/345/210/206/346/236/220.md +0 -234
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/CM/345/207/275/346/225/260/345/244/247/345/205/250.md +0 -93
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212/RPG_Maker_/344/272/213/344/273/266/350/204/232/346/234/254/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -734
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/270/211/345/233/275/346/235/200/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -379
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/345/206/263/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -256
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//344/277/256/344/273/231/347/211/210/345/215/241/347/211/214/346/270/270/346/210/217.md +0 -355
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233CM/345/207/275/346/225/260/345/210/206/346/236/220.md +0 -81
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/206/222/351/231/251/345/262/233NPC/350/204/232/346/234/254/346/224/257/346/214/201/345/210/206/346/236/220.md +0 -365
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/244/247/351/203/250/345/210/206/351/200/232/347/224/250/346/250/241/345/235/227/345/210/206/346/236/220.md +0 -33
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//345/260/217/345/225/206/345/272/227/351/234/200/346/261/202/350/247/204/346/240/274.md +0 -577
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/250/241/346/213/237/344/272/272/347/224/237/346/201/213/347/210/261/345/205/273/346/210/220RPG/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -314
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/255/243/345/274/217/345/217/257/347/224/250/345/267/256/350/267/235/345/210/206/346/236/220.md +0 -463
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//346/270/270/346/210/217/347/216/213/345/215/241/347/211/214/346/270/270/346/210/217/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -673
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -405
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//350/264/252/345/251/252/344/271/213/345/262/233/347/262/276/347/256/200/347/211/210/345/217/257/350/241/214/346/200/247/345/210/206/346/236/220.md +0 -289
- package/docs//350/256/276/350/256/241/345/210/206/346/236/220/346/212/245/345/221/212//351/207/215/350/243/205/346/234/272/345/205/265/346/226/207/345/255/227/347/211/210/346/270/270/346/210/217.md +0 -417
- package/docs//350/260/203/350/257/225/344/270/216/346/216/222/351/224/231.md +0 -255
- package/example/common/mod/executor/effect/executor.json +0 -58
- package/example/common/mod/executor/effect/index.js +0 -93
- package/example/common/mod/executor/warp/executor.json +0 -57
- package/example/common/mod/executor/warp/index.js +0 -73
- package/example/common/mod/manager/inventory/index.js +0 -205
- package/example/common/mod/manager/inventory/manager.json +0 -70
- package/example/common/mod/manager/persistence/index.js +0 -176
- package/example/common/mod/manager/persistence/manager.json +0 -67
- package/example/common/mod/manager/player/index.js +0 -187
- package/example/common/mod/manager/player/manager.json +0 -102
- package/example/common/mod/manager/quest/index.js +0 -196
- package/example/common/mod/manager/quest/manager.json +0 -50
- package/example/common/mod/manager/shop/index.js +0 -66
- package/example/common/mod/manager/shop/manager.json +0 -44
- package/example/common/mod/manager/skill/index.js +0 -143
- package/example/common/mod/manager/skill/manager.json +0 -82
- package/example/common/script/demo/index.js +0 -16
- package/example/common/script/demo/script.json +0 -21
- package/example/common/workflow/admin/dashboard.json +0 -87
- package/example/common/workflow/admin/order_deliver.json +0 -99
- package/example/common/workflow/admin/order_list.json +0 -79
- package/example/common/workflow/admin/product_off.json +0 -85
- package/example/common/workflow/admin/product_on.json +0 -85
- package/example/common/workflow/admin/user_list.json +0 -68
- package/example/common/workflow/cart/add.json +0 -86
- package/example/common/workflow/cart/checkout.json +0 -120
- package/example/common/workflow/cart/del.json +0 -47
- package/example/common/workflow/cart/list.json +0 -55
- package/example/common/workflow/cart/set.json +0 -106
- package/example/common/workflow/db/create_table.json +0 -57
- package/example/common/workflow/db/mysql_query.json +0 -47
- package/example/common/workflow/db/sqlite_crud.json +0 -48
- package/example/common/workflow/npc/blacksmith.json +0 -91
- package/example/common/workflow/npc/quest_giver.json +0 -136
- package/example/common/workflow/order/create.json +0 -76
- package/example/common/workflow/order/create_bpmn.json +0 -105
- package/example/common/workflow/order/history.json +0 -69
- package/example/common/workflow/payment/process.json +0 -74
- package/example/common/workflow/product/add.json +0 -72
- package/example/common/workflow/product/categories.json +0 -41
- package/example/common/workflow/product/count.json +0 -65
- package/example/common/workflow/product/del.json +0 -84
- package/example/common/workflow/product/get.json +0 -59
- package/example/common/workflow/product/list.json +0 -80
- package/example/common/workflow/product/search.json +0 -59
- package/example/common/workflow/product/set.json +0 -87
- package/example/common/workflow/shop/create.json +0 -70
- package/example/common/workflow/shop/del.json +0 -84
- package/example/common/workflow/shop/get.json +0 -43
- package/example/common/workflow/shop/list.json +0 -80
- package/example/common/workflow/shop/products.json +0 -69
- package/example/common/workflow/shop/set.json +0 -64
- package/example/common/workflow/system/monitor.json +0 -62
- package/example/common/workflow/user/address_add.json +0 -49
- package/example/common/workflow/user/address_list.json +0 -44
- package/example/common/workflow/user/change_password.json +0 -87
- package/example/common/workflow/user/login.json +0 -83
- package/example/common/workflow/user/profile.json +0 -71
- package/example/common/workflow/user/register.json +0 -77
- package/example/config +0 -122
- package/example/config.json +0 -94
- package/example/data/model/bag.json +0 -28
- package/example/data/model/character.json +0 -38
- package/example/data/model/quest.json +0 -14
- package/example/data/model/save.json +0 -10
- package/example/data/model/shop.json +0 -14
- package/example/data/model/skill.json +0 -28
- package/example/data/test.js +0 -365
- package/example/db/mm.db +0 -0
- package/example/db/mm.db-shm +0 -0
- package/example/db/mm.db-wal +0 -0
- package/example/db/sql/ecommerce.sql +0 -84
- package/example/db/sql/game.sql +0 -72
- package/example/ecom_out.txt +0 -0
- package/example/ecommerce.js +0 -450
- package/example/index.js +0 -262
- package/example/npc_demo.js +0 -361
- package/lib/tools/circuit_breaker/index.js +0 -164
- package/lib/tools/index.js +0 -16
- package/lib/tools/ip_block/index.js +0 -20
- package/lib/tools/rate_limit/index.js +0 -49
- package/lib/tools/sensitive/index.js +0 -29
- package/lib/tools/spam/index.js +0 -30
- package/lib/tools/sql_inject/index.js +0 -35
- package/llm.js +0 -257
- package/scan_modules.js +0 -124
- package/scripts/add_type_field.js +0 -153
- package/scripts/create_project.js +0 -276
- package/scripts/generate_mod.js +0 -229
- package/templates/db/backup_table.json +0 -52
- package/templates/db/create_table.json +0 -68
- package/templates/db/crud_sqlite.json +0 -98
- package/templates/db/db_sqlite.json +0 -52
- package/templates/db/ecommerce.sql +0 -87
- package/templates/db/export_table.json +0 -51
- package/templates/demo/hello.json +0 -47
- package/templates/demo/http_demo.json +0 -48
- package/templates/demo/llm_chat.json +0 -44
- package/templates/demo/render_demo.json +0 -46
- package/templates/demo/validator_demo.json +0 -64
- package/templates/order/create.json +0 -113
- package/templates/user_account/add.json +0 -92
- package/templates/user_account/count.json +0 -24
- package/templates/user_account/del.json +0 -38
- package/templates/user_account/get.json +0 -48
- package/templates/user_account/init.json +0 -76
- package/templates/user_account/list.json +0 -48
- package/templates/user_account/set.json +0 -65
- package/templates/user_account/user_account.sql +0 -21
- package/test.js +0 -253
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "effect",
|
|
3
|
-
"title": "音效特效执行器",
|
|
4
|
-
"description": "播放音效或特效动画,对应 CM 音效特效函数 playSound/showEffect",
|
|
5
|
-
"type": "data",
|
|
6
|
-
"params": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"player_id": {
|
|
10
|
-
"type": "integer",
|
|
11
|
-
"description": "玩家ID"
|
|
12
|
-
},
|
|
13
|
-
"action": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "操作类型: play_sound/show_effect",
|
|
16
|
-
"default": "play_sound",
|
|
17
|
-
"enum": ["play_sound", "show_effect"]
|
|
18
|
-
},
|
|
19
|
-
"sound_path": {
|
|
20
|
-
"type": "string",
|
|
21
|
-
"description": "音效文件路径(play_sound 使用)"
|
|
22
|
-
},
|
|
23
|
-
"effect_path": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"description": "特效动画路径(show_effect 使用)"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"required": ["player_id"]
|
|
29
|
-
},
|
|
30
|
-
"returns": {
|
|
31
|
-
"type": "object",
|
|
32
|
-
"description": "返回播放指令,异常时返回 error",
|
|
33
|
-
"properties": {
|
|
34
|
-
"msg": {
|
|
35
|
-
"type": "string",
|
|
36
|
-
"description": "播放指令已发送"
|
|
37
|
-
},
|
|
38
|
-
"action": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"description": "固定值 play_sound/show_effect"
|
|
41
|
-
},
|
|
42
|
-
"player_id": {
|
|
43
|
-
"type": "integer",
|
|
44
|
-
"description": "玩家ID"
|
|
45
|
-
},
|
|
46
|
-
"sound_path": {
|
|
47
|
-
"type": "string",
|
|
48
|
-
"description": "音效文件路径(play_sound)"
|
|
49
|
-
},
|
|
50
|
-
"effect_path": {
|
|
51
|
-
"type": "string",
|
|
52
|
-
"description": "特效动画路径(show_effect)"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"options": {},
|
|
57
|
-
"group": "game"
|
|
58
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 音效特效执行器
|
|
3
|
-
* 校验玩家后下发音效或特效播放指令
|
|
4
|
-
* 对应 CM 音效特效函数 playSound/showEffect
|
|
5
|
-
*/
|
|
6
|
-
async function main(params, ctx, options) {
|
|
7
|
-
var player_id = params.player_id;
|
|
8
|
-
if (player_id === undefined || player_id === null) {
|
|
9
|
-
ctx.output = _error('EXEC_MISSING_PARAM', '缺少 player_id 参数');
|
|
10
|
-
return ctx.output;
|
|
11
|
-
}
|
|
12
|
-
var data_mod = this.getParent().getMod('manager', 'data');
|
|
13
|
-
var player = await _findPlayer(data_mod, ctx, player_id);
|
|
14
|
-
if (!player) {
|
|
15
|
-
ctx.output = _error('EXEC_PLAYER_NOT_FOUND', '玩家不存在: ' + player_id);
|
|
16
|
-
return ctx.output;
|
|
17
|
-
}
|
|
18
|
-
var action = params.action || 'play_sound';
|
|
19
|
-
if (action === 'play_sound') {
|
|
20
|
-
return _playSound(params, ctx, options);
|
|
21
|
-
}
|
|
22
|
-
if (action === 'show_effect') {
|
|
23
|
-
return _showEffect(params, ctx, options);
|
|
24
|
-
}
|
|
25
|
-
ctx.output = _error('EXEC_UNKNOWN_ACTION', '不支持的操作: ' + action);
|
|
26
|
-
return ctx.output;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 查询玩家数据
|
|
31
|
-
* @param {object} data_mod 数据模型管理器
|
|
32
|
-
* @param {object} ctx 上下文对象
|
|
33
|
-
* @param {number} player_id 玩家ID
|
|
34
|
-
* @returns {object|null} 玩家对象
|
|
35
|
-
*/
|
|
36
|
-
async function _findPlayer(data_mod, ctx, player_id) {
|
|
37
|
-
try {
|
|
38
|
-
var result = await data_mod.main.call(data_mod, ctx, {
|
|
39
|
-
action: 'get',
|
|
40
|
-
model: 'character',
|
|
41
|
-
query: { id: player_id }
|
|
42
|
-
});
|
|
43
|
-
return result && result.obj ? result.obj : null;
|
|
44
|
-
} catch (_error) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 播放音效
|
|
51
|
-
* @param {object} ctx 上下文对象
|
|
52
|
-
* @param {object} params 步骤参数
|
|
53
|
-
* @returns {object} 播放结果
|
|
54
|
-
*/
|
|
55
|
-
function _playSound(params, ctx, options) {
|
|
56
|
-
var sound_path = params.sound_path || params.path || '';
|
|
57
|
-
ctx.output = {
|
|
58
|
-
msg: '音效播放指令已发送',
|
|
59
|
-
action: 'play_sound',
|
|
60
|
-
player_id: params.player_id,
|
|
61
|
-
sound_path: sound_path
|
|
62
|
-
};
|
|
63
|
-
return ctx.output;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 播放特效动画
|
|
68
|
-
* @param {object} ctx 上下文对象
|
|
69
|
-
* @param {object} params 步骤参数
|
|
70
|
-
* @returns {object} 播放结果
|
|
71
|
-
*/
|
|
72
|
-
function _showEffect(params, ctx, options) {
|
|
73
|
-
var effect_path = params.effect_path || params.path || '';
|
|
74
|
-
ctx.output = {
|
|
75
|
-
msg: '特效播放指令已发送',
|
|
76
|
-
action: 'show_effect',
|
|
77
|
-
player_id: params.player_id,
|
|
78
|
-
effect_path: effect_path
|
|
79
|
-
};
|
|
80
|
-
return ctx.output;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 构建统一错误对象
|
|
85
|
-
* @param {string} code 错误码
|
|
86
|
-
* @param {string} message 错误信息
|
|
87
|
-
* @returns {object} 错误对象
|
|
88
|
-
*/
|
|
89
|
-
function _error(code, message) {
|
|
90
|
-
return { error: { code: code, message: message } };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
module.exports = { main };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "warp",
|
|
3
|
-
"title": "传送执行器",
|
|
4
|
-
"description": "传送玩家至指定地图及传送点,对应 CM 地图函数 warp",
|
|
5
|
-
"type": "data",
|
|
6
|
-
"params": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"player_id": {
|
|
10
|
-
"type": "integer",
|
|
11
|
-
"description": "玩家ID"
|
|
12
|
-
},
|
|
13
|
-
"map_id": {
|
|
14
|
-
"type": "integer",
|
|
15
|
-
"description": "目标地图ID"
|
|
16
|
-
},
|
|
17
|
-
"portal_index": {
|
|
18
|
-
"type": "integer",
|
|
19
|
-
"description": "传送点索引",
|
|
20
|
-
"default": 0
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"required": ["player_id", "map_id"]
|
|
24
|
-
},
|
|
25
|
-
"returns": {
|
|
26
|
-
"type": "object",
|
|
27
|
-
"description": "返回传送指令,异常时返回 error",
|
|
28
|
-
"properties": {
|
|
29
|
-
"msg": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"description": "传送指令已发送"
|
|
32
|
-
},
|
|
33
|
-
"action": {
|
|
34
|
-
"type": "string",
|
|
35
|
-
"description": "固定值 warp"
|
|
36
|
-
},
|
|
37
|
-
"player_id": {
|
|
38
|
-
"type": "integer",
|
|
39
|
-
"description": "玩家ID"
|
|
40
|
-
},
|
|
41
|
-
"from_map": {
|
|
42
|
-
"type": "integer",
|
|
43
|
-
"description": "传送前地图ID"
|
|
44
|
-
},
|
|
45
|
-
"map_id": {
|
|
46
|
-
"type": "integer",
|
|
47
|
-
"description": "目标地图ID"
|
|
48
|
-
},
|
|
49
|
-
"portal_index": {
|
|
50
|
-
"type": "integer",
|
|
51
|
-
"description": "传送点索引"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"options": {},
|
|
56
|
-
"group": "game"
|
|
57
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 传送执行器
|
|
3
|
-
* 传送玩家至指定地图及传送点,并持久化玩家当前位置
|
|
4
|
-
* 对应 CM 地图函数 warp
|
|
5
|
-
*/
|
|
6
|
-
async function main(params, ctx, options) {
|
|
7
|
-
var player_id = params.player_id;
|
|
8
|
-
var map_id = params.map_id;
|
|
9
|
-
if (player_id === undefined || player_id === null || map_id === undefined || map_id === null) {
|
|
10
|
-
ctx.output = _error('EXEC_MISSING_PARAM', '缺少 player_id/map_id 参数');
|
|
11
|
-
return ctx.output;
|
|
12
|
-
}
|
|
13
|
-
var data_mod = this.getParent().getMod('manager', 'data');
|
|
14
|
-
var player = await _findPlayer(data_mod, ctx, player_id);
|
|
15
|
-
if (!player) {
|
|
16
|
-
ctx.output = _error('EXEC_PLAYER_NOT_FOUND', '玩家不存在: ' + player_id);
|
|
17
|
-
return ctx.output;
|
|
18
|
-
}
|
|
19
|
-
var portal_index = params.portal_index || 0;
|
|
20
|
-
var from_map = player.map_id || 0;
|
|
21
|
-
try {
|
|
22
|
-
await data_mod.main.call(data_mod, ctx, {
|
|
23
|
-
action: 'set',
|
|
24
|
-
model: 'character',
|
|
25
|
-
query: { id: player_id },
|
|
26
|
-
body: { map_id: map_id, portal_index: portal_index }
|
|
27
|
-
});
|
|
28
|
-
} catch (_error) {
|
|
29
|
-
ctx.output = _error('EXEC_WARP_FAILED', '玩家位置保存失败');
|
|
30
|
-
return ctx.output;
|
|
31
|
-
}
|
|
32
|
-
ctx.output = {
|
|
33
|
-
msg: '传送成功',
|
|
34
|
-
action: 'warp',
|
|
35
|
-
player_id: player_id,
|
|
36
|
-
from_map: from_map,
|
|
37
|
-
map_id: map_id,
|
|
38
|
-
portal_index: portal_index
|
|
39
|
-
};
|
|
40
|
-
return ctx.output;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 查询玩家数据
|
|
45
|
-
* @param {object} data_mod 数据模型管理器
|
|
46
|
-
* @param {object} ctx 上下文对象
|
|
47
|
-
* @param {number} player_id 玩家ID
|
|
48
|
-
* @returns {object|null} 玩家对象
|
|
49
|
-
*/
|
|
50
|
-
async function _findPlayer(data_mod, ctx, player_id) {
|
|
51
|
-
try {
|
|
52
|
-
var result = await data_mod.main.call(data_mod, ctx, {
|
|
53
|
-
action: 'get',
|
|
54
|
-
model: 'character',
|
|
55
|
-
query: { id: player_id }
|
|
56
|
-
});
|
|
57
|
-
return result && result.obj ? result.obj : null;
|
|
58
|
-
} catch (_error) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 构建统一错误对象
|
|
65
|
-
* @param {string} code 错误码
|
|
66
|
-
* @param {string} message 错误信息
|
|
67
|
-
* @returns {object} 错误对象
|
|
68
|
-
*/
|
|
69
|
-
function _error(code, message) {
|
|
70
|
-
return { error: { code: code, message: message } };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = { main };
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 背包与金币管理器
|
|
3
|
-
* 管理道具增减与金币变动,对应 CM 背包函数
|
|
4
|
-
* haveItem/itemQuantity/gainItem/getCoin/gainCoin
|
|
5
|
-
*/
|
|
6
|
-
async function main(params, ctx, options) {
|
|
7
|
-
var player_id = params.player_id;
|
|
8
|
-
if (player_id === undefined || player_id === null) {
|
|
9
|
-
ctx.output = _error('MGR_MISSING_PARAM', '缺少 player_id 参数');
|
|
10
|
-
return ctx.output;
|
|
11
|
-
}
|
|
12
|
-
var data_mod = this.getParent().getMod('manager', 'data');
|
|
13
|
-
var action = params.action || 'get_coin';
|
|
14
|
-
var player = await _findPlayer(data_mod, ctx, player_id);
|
|
15
|
-
if (!player) {
|
|
16
|
-
ctx.output = _error('MGR_PLAYER_NOT_FOUND', '玩家不存在: ' + player_id);
|
|
17
|
-
return ctx.output;
|
|
18
|
-
}
|
|
19
|
-
ctx.output = await _runAction(ctx, data_mod, action, params, player);
|
|
20
|
-
return ctx.output;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 查询玩家数据
|
|
25
|
-
* @param {object} data_mod 数据模型管理器
|
|
26
|
-
* @param {object} ctx 上下文对象
|
|
27
|
-
* @param {number} player_id 玩家ID
|
|
28
|
-
* @returns {object|null} 玩家对象
|
|
29
|
-
*/
|
|
30
|
-
async function _findPlayer(data_mod, ctx, player_id) {
|
|
31
|
-
try {
|
|
32
|
-
var result = await data_mod.main.call(data_mod, ctx, {
|
|
33
|
-
action: 'get',
|
|
34
|
-
model: 'character',
|
|
35
|
-
query: { id: player_id }
|
|
36
|
-
});
|
|
37
|
-
return result && result.obj ? result.obj : null;
|
|
38
|
-
} catch (_error) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 分发处理背包操作
|
|
45
|
-
* @param {object} ctx 上下文对象
|
|
46
|
-
* @param {object} data_mod 数据模型管理器
|
|
47
|
-
* @param {string} action 操作类型
|
|
48
|
-
* @param {object} params 步骤参数
|
|
49
|
-
* @param {object} player 玩家对象
|
|
50
|
-
* @returns {object} 处理结果
|
|
51
|
-
*/
|
|
52
|
-
async function _runAction(ctx, data_mod, action, params, player) {
|
|
53
|
-
switch (action) {
|
|
54
|
-
case 'have_item':
|
|
55
|
-
return await _haveItem(ctx, data_mod, params);
|
|
56
|
-
case 'item_quantity':
|
|
57
|
-
return await _itemQuantity(ctx, data_mod, params);
|
|
58
|
-
case 'gain_item':
|
|
59
|
-
return await _gainItem(ctx, data_mod, params);
|
|
60
|
-
case 'get_coin':
|
|
61
|
-
return { coin: player.gold || 0 };
|
|
62
|
-
case 'gain_coin':
|
|
63
|
-
return await _gainCoin(ctx, data_mod, params, player);
|
|
64
|
-
default:
|
|
65
|
-
return _error('MGR_UNKNOWN_ACTION', '不支持的操作: ' + action);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 查询玩家拥有的某道具列表
|
|
71
|
-
* @param {object} ctx 上下文对象
|
|
72
|
-
* @param {object} data_mod 数据模型管理器
|
|
73
|
-
* @param {object} params 步骤参数
|
|
74
|
-
* @returns {Array} 道具列表
|
|
75
|
-
*/
|
|
76
|
-
async function _listItems(ctx, data_mod, params) {
|
|
77
|
-
try {
|
|
78
|
-
var result = await data_mod.main.call(data_mod, ctx, {
|
|
79
|
-
action: 'list',
|
|
80
|
-
model: 'bag',
|
|
81
|
-
query: { character_id: params.player_id, item_id: params.item_id }
|
|
82
|
-
});
|
|
83
|
-
return result && result.list ? result.list : [];
|
|
84
|
-
} catch (_error) {
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 检查是否拥有足够数量道具
|
|
91
|
-
* @param {object} ctx 上下文对象
|
|
92
|
-
* @param {object} data_mod 数据模型管理器
|
|
93
|
-
* @param {object} params 步骤参数
|
|
94
|
-
* @returns {object} 拥有结果
|
|
95
|
-
*/
|
|
96
|
-
async function _haveItem(ctx, data_mod, params) {
|
|
97
|
-
var items = await _listItems(ctx, data_mod, params);
|
|
98
|
-
var quantity = items.reduce(function (sum, item) {
|
|
99
|
-
return sum + (item.quantity || 0);
|
|
100
|
-
}, 0);
|
|
101
|
-
var need = params.quantity !== undefined ? params.quantity : 1;
|
|
102
|
-
return { have: quantity >= need };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 查询道具当前总数量
|
|
107
|
-
* @param {object} ctx 上下文对象
|
|
108
|
-
* @param {object} data_mod 数据模型管理器
|
|
109
|
-
* @param {object} params 步骤参数
|
|
110
|
-
* @returns {object} 数量结果
|
|
111
|
-
*/
|
|
112
|
-
async function _itemQuantity(ctx, data_mod, params) {
|
|
113
|
-
var items = await _listItems(ctx, data_mod, params);
|
|
114
|
-
var quantity = items.reduce(function (sum, item) {
|
|
115
|
-
return sum + (item.quantity || 0);
|
|
116
|
-
}, 0);
|
|
117
|
-
return { quantity: quantity };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 增减道具数量,数量归零时自动删除
|
|
122
|
-
* @param {object} ctx 上下文对象
|
|
123
|
-
* @param {object} data_mod 数据模型管理器
|
|
124
|
-
* @param {object} params 步骤参数
|
|
125
|
-
* @returns {object} 操作结果
|
|
126
|
-
*/
|
|
127
|
-
async function _gainItem(ctx, data_mod, params) {
|
|
128
|
-
var item_id = params.item_id;
|
|
129
|
-
if (item_id === undefined || item_id === null) {
|
|
130
|
-
return _error('MGR_MISSING_PARAM', '缺少 item_id 参数');
|
|
131
|
-
}
|
|
132
|
-
var amount = params.quantity || 1;
|
|
133
|
-
try {
|
|
134
|
-
var items = await _listItems(ctx, data_mod, params);
|
|
135
|
-
var target = items[0] || null;
|
|
136
|
-
if (target) {
|
|
137
|
-
var new_qty = (target.quantity || 0) + amount;
|
|
138
|
-
if (new_qty <= 0) {
|
|
139
|
-
await data_mod.main.call(data_mod, ctx, {
|
|
140
|
-
action: 'del',
|
|
141
|
-
model: 'bag',
|
|
142
|
-
query: { id: target.id }
|
|
143
|
-
});
|
|
144
|
-
} else {
|
|
145
|
-
await data_mod.main.call(data_mod, ctx, {
|
|
146
|
-
action: 'set',
|
|
147
|
-
model: 'bag',
|
|
148
|
-
query: { id: target.id },
|
|
149
|
-
body: { quantity: new_qty }
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return { msg: '道具数量更新成功', quantity: Math.max(new_qty, 0) };
|
|
153
|
-
}
|
|
154
|
-
if (amount <= 0) return { msg: '道具不足,无法扣除', quantity: 0 };
|
|
155
|
-
await data_mod.main.call(data_mod, ctx, {
|
|
156
|
-
action: 'add',
|
|
157
|
-
model: 'bag',
|
|
158
|
-
body: {
|
|
159
|
-
character_id: params.player_id,
|
|
160
|
-
item_id: item_id,
|
|
161
|
-
item_name: params.item_name || '道具' + item_id,
|
|
162
|
-
item_type: params.item_type || 'material',
|
|
163
|
-
quantity: amount
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
return { msg: '道具发放成功', quantity: amount };
|
|
167
|
-
} catch (_error) {
|
|
168
|
-
return { msg: '道具操作失败', quantity: 0 };
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 增减金币数量
|
|
174
|
-
* @param {object} ctx 上下文对象
|
|
175
|
-
* @param {object} data_mod 数据模型管理器
|
|
176
|
-
* @param {object} params 步骤参数
|
|
177
|
-
* @param {object} player 玩家对象
|
|
178
|
-
* @returns {object} 操作结果
|
|
179
|
-
*/
|
|
180
|
-
async function _gainCoin(ctx, data_mod, params, player) {
|
|
181
|
-
try {
|
|
182
|
-
var coin = (player.gold || 0) + (params.amount || 0);
|
|
183
|
-
await data_mod.main.call(data_mod, ctx, {
|
|
184
|
-
action: 'set',
|
|
185
|
-
model: 'character',
|
|
186
|
-
query: { id: player.id },
|
|
187
|
-
body: { gold: coin }
|
|
188
|
-
});
|
|
189
|
-
return { msg: '金币变动成功', coin: coin };
|
|
190
|
-
} catch (_error) {
|
|
191
|
-
return { msg: '金币变动失败', coin: player.gold || 0 };
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* 构建统一错误对象
|
|
197
|
-
* @param {string} code 错误码
|
|
198
|
-
* @param {string} message 错误信息
|
|
199
|
-
* @returns {object} 错误对象
|
|
200
|
-
*/
|
|
201
|
-
function _error(code, message) {
|
|
202
|
-
return { error: { code: code, message: message } };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
module.exports = { main };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "inventory",
|
|
3
|
-
"title": "背包与金币管理器",
|
|
4
|
-
"description": "管理道具增减与金币变动,对应 CM 背包函数 haveItem/itemQuantity/gainItem/getCoin/gainCoin",
|
|
5
|
-
"type": "data",
|
|
6
|
-
"params": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"player_id": {
|
|
10
|
-
"type": "integer",
|
|
11
|
-
"description": "玩家ID"
|
|
12
|
-
},
|
|
13
|
-
"action": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "操作类型: have_item/item_quantity/gain_item/get_coin/gain_coin",
|
|
16
|
-
"default": "get_coin",
|
|
17
|
-
"enum": ["have_item", "item_quantity", "gain_item", "get_coin", "gain_coin"]
|
|
18
|
-
},
|
|
19
|
-
"item_id": {
|
|
20
|
-
"type": "integer",
|
|
21
|
-
"description": "道具ID"
|
|
22
|
-
},
|
|
23
|
-
"quantity": {
|
|
24
|
-
"type": "integer",
|
|
25
|
-
"description": "道具数量或增减量,可为负数(gain_item/have_item 使用)"
|
|
26
|
-
},
|
|
27
|
-
"item_name": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"description": "道具名(新增道具时使用)"
|
|
30
|
-
},
|
|
31
|
-
"item_type": {
|
|
32
|
-
"type": "string",
|
|
33
|
-
"description": "道具类型: weapon/armor/potion/material(新增道具时使用)"
|
|
34
|
-
},
|
|
35
|
-
"price": {
|
|
36
|
-
"type": "integer",
|
|
37
|
-
"description": "单价(新增道具时使用)"
|
|
38
|
-
},
|
|
39
|
-
"amount": {
|
|
40
|
-
"type": "integer",
|
|
41
|
-
"description": "金币增减量(gain_coin 使用),可为负数"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"required": ["player_id"]
|
|
45
|
-
},
|
|
46
|
-
"returns": {
|
|
47
|
-
"type": "object",
|
|
48
|
-
"description": "读操作返回 have/quantity/coin,写操作返回 msg+quantity/coin,异常时返回 error",
|
|
49
|
-
"properties": {
|
|
50
|
-
"have": {
|
|
51
|
-
"type": "boolean",
|
|
52
|
-
"description": "是否拥有足够道具(have_item)"
|
|
53
|
-
},
|
|
54
|
-
"quantity": {
|
|
55
|
-
"type": "integer",
|
|
56
|
-
"description": "道具数量或操作后数量(item_quantity/gain_item)"
|
|
57
|
-
},
|
|
58
|
-
"coin": {
|
|
59
|
-
"type": "integer",
|
|
60
|
-
"description": "金币数(get_coin/gain_coin)"
|
|
61
|
-
},
|
|
62
|
-
"msg": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"description": "操作结果描述(写操作)"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"options": {},
|
|
69
|
-
"group": "game"
|
|
70
|
-
}
|