From 09188484020d167214a29aeadcfb867d9456847b Mon Sep 17 00:00:00 2001 From: szdytom Date: Sat, 7 Oct 2023 10:05:05 +0800 Subject: [PATCH] Add player list command Signed-off-by: szdytom --- README.md | 20 +++++++++++--------- src/ica-i18n.sc | 19 +++++++++++++++++-- src/ica-loader.sc | 1 + src/ica-settings.sc | 2 +- src/ica.sc | 36 +++++++++++++++++++++++++++++++++++- 5 files changed, 65 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7a56045..3249938 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ ICollect-Alpha 是一个使用 [Carpet 脚本](https://github.com/gnembon/fabric 1. 发射火球:发射与TNT爆炸威力相同的恶魂火球。 2. 发射烟花:发射可以造成大量伤害的烟花火箭。 -3. 建筑烟花:发射在其下方生成道路的烟花火箭(道路建筑材料为_石化橡木台阶_)。 +3. 建筑烟花:发射在其下方生成道路的烟花火箭(道路建筑材料为 _石化橡木台阶_)。 【指令使用】 1. `/ica`:列出物品收集目标和时限信息 @@ -33,6 +33,7 @@ ICollect-Alpha 是一个使用 [Carpet 脚本](https://github.com/gnembon/fabric 5. `/ica refill`:刷新自己的烟花 6. `/ica locate `:定位某一玩家位置,空手使用时可获得指向位置的指南针(不能跨维度定位) 7. `/ica spyglass `:切换望远镜的能力 +7. `/ica ps`:查看玩家列表,狼人可看到队友 7. `/ica-vote`:查看当前投票状态信息 8. `/ica-vote abstain`:投弃权票 9. `/ica-vote sus `:投票给某一玩家 @@ -43,14 +44,15 @@ ICollect-Alpha 是一个使用 [Carpet 脚本](https://github.com/gnembon/fabric 首先需要安装 Fabric 和 Fabric Carpet 模组,然后将 `src` 目录下的 `.sc` 代码复制到世界的 `script` 文件夹下。打开世界后,使用 `/script load ica-loader` 加载加载脚本,使用命令 `/ica-loader` 加载各个模块: -- 使用 `/ica-setting career ` 设置职业的玩家数量 -- 使用 `/ica-setting add ` 设置一个未使用的收集目标 -- 使用 `/ica-setting set ` 设置一个指定的收集目标 -- 使用 `/ica-admin confirm` 开始游戏,开始时请保证所有参与者在线 +- `/ica-setting career ` 设置职业的玩家数量 +- `/ica-setting add ` 设置一个未使用的收集目标 +- `/ica-setting set ` 设置一个指定的收集目标 +- `/ica-admin confirm` 开始游戏,开始时请保证所有参与者在线 ## 调试命令 -- 使用 `/ica-effect-applier enable` 强制启用状态效果广播 -- 使用 `/ica-effect-applier enable` 强制禁用状态效果广播 -- 使用 `/ica-admin cancel` 终止游戏 - +- `/ica-effect-applier enable` 强制启用状态效果广播 +- `/ica-effect-applier enable` 强制禁用状态效果广播 +- `/ica-admin reset` 终止游戏 +- `/ica-i18n dump` 向 JSON 文件中写入本地化值 +- `/bossbar set ica:prepare_counter value 20` 强制跳过准备阶段 diff --git a/src/ica-i18n.sc b/src/ica-i18n.sc index 63bcace..3e63e50 100644 --- a/src/ica-i18n.sc +++ b/src/ica-i18n.sc @@ -1,6 +1,10 @@ __config() -> { 'scope' -> 'global', 'exports' -> ['getLocaleKey', 'useIcaInstead', 'startedReject', 'pendingReject'], + 'command_permission' -> 'ops', + 'commands' -> { + 'dump' -> 'cmdDump', + }, }; global_TranslateKeysEnUS = { @@ -47,7 +51,7 @@ global_TranslateKeysEnUS = { 'career.display.hunter' -> ' - Hunter(Fireball): %d participants.', 'career.display.firework_hunter' -> ' - Hunter(Firework): %d participants.', 'career.display.builder' -> ' - Builder: %d participants.', - 'career.display.piggy' -> '- Piggies: whatever the rest.', + 'career.display.piggy' -> ' - Piggies: whatever the rest.', 'career.set' -> 'Career %s set to %d participants.', 'career.title.bystander' -> 'Bystander', @@ -106,7 +110,7 @@ global_TranslateKeysEnUS = { 'list.item.id' -> '#%d: ', 'vote.title' -> 'There are %d candidates:', - 'vote.deceased' -> '[deceased]', + 'vote.deceased' -> '[Deceased]', 'vote.amount.1' -> '[%02d vote]', 'vote.amount.2' -> '[%02d votes]', 'vote.footer' -> 'Current elected: ', @@ -124,6 +128,13 @@ global_TranslateKeysEnUS = { 'seed.title' -> 'Map Seed: ', + 'ps.wolf' -> '[Wolf]', + 'ps.button.locate' -> '[Click To Locate]', + 'ps.marker' -> ' - ', + 'ps.me' -> '[You]', + 'ps.offline' -> '[Offline]', + 'ps.title' -> 'There are %d participants:', + 'misc.clipboard' -> 'Click To Copy', 'license.header' -> 'ICollect-Alpha, Copyright (C) 2023 方而静\nICollect-Alpha comes with ABSOLUTELY NO WARRANTY;\nfor details type \'/ica-loader show w\'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type \'/ica-loader show c\' for details.' @@ -150,3 +161,7 @@ pendingReject() -> ( , 'mb /ica-admin confirm', '?/ica-admin confirm' , ' ' + getLocaleKey('reject.pending.after'))); ); + +cmdDump() -> ( + write_file('ica-i18n-keys.json', 'shared_json', global_TranslateKeysEnUS); +); diff --git a/src/ica-loader.sc b/src/ica-loader.sc index 7389989..f43455e 100644 --- a/src/ica-loader.sc +++ b/src/ica-loader.sc @@ -26,6 +26,7 @@ cmdLoad() -> ( run('script load ica'); run('script load ica-vote'); run('script load ica-settings'); + run('script load ica-i18n'); ); cmdShowW() -> ( diff --git a/src/ica-settings.sc b/src/ica-settings.sc index 9917e8c..f254786 100644 --- a/src/ica-settings.sc +++ b/src/ica-settings.sc @@ -38,7 +38,7 @@ cmdSet(slot_id, goal_item_tuple) -> ( put(nbt_storage('ica:data'), 'Goals', etag, -1); print(format(' ' + str(getLocaleKey('goal.set.before'), slot_id) , 'b ' + item_display_name(goal_item_tuple:0), '^ minecraft:' + goal_item_tuple:0 - , ' ' + getLocaleKey('goal.set.after')); + , ' ' + getLocaleKey('goal.set.after'))); if(getFirstUnsetGoal() > 5, ( print(format(' ' + getLocaleKey('hint.allset.before') , 'mb /ica-admin confirm', '?/ica-admin confirm' diff --git a/src/ica.sc b/src/ica.sc index f125e30..a9e1c04 100644 --- a/src/ica.sc +++ b/src/ica.sc @@ -9,6 +9,8 @@ __config() -> { 'whoami' -> 'cmdMe', 'locate ' -> 'cmdLocate', 'spyglass ' -> 'cmdSpyglassSwitch', + 'ps' -> 'cmdListPalyer', + 'playerlist' -> 'cmdListPalyer', }, 'arguments' -> { 'slot' -> { 'type' -> 'int', 'min' -> 0, 'max' -> 5 @@ -20,7 +22,8 @@ __config() -> { ) )}, 'spyglass_feature' -> { 'type' -> 'string', - 'options' -> [ 'builder', 'firework', 'fireball' ] } + 'options' -> [ 'builder', 'firework', 'fireball' ] }, + 'message' -> { 'type' -> 'text' }, } }; @@ -243,3 +246,34 @@ cmdSubmit(slot_id) -> ( bossbar('ica:collected', 'value', iv); print(getLocaleKey('submit.success')); ); + +cmdListPalyer() -> ( + if(!nbt_storage('ica:data'):'Started', ( + pendingReject(); + return(false) + )); + me = player(); + + cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates'); + cand_n = length(cand_names); + print(str(getLocaleKey('ps.title'), cand_n)); + for(cand_names, ( + p = player(_); + fcomp = [' ' + getLocaleKey('ps.marker')]; + if(p == null, ( + put(fcomp, null, 'g ' + _); + put(fcomp, null, ' ' + getLocaleKey('ps.offline')); + ), ( + put(fcomp, null, if(query(p, 'has_scoreboard_tag', 'ica.deceased') + , 's ', 'b ') + _); + if(p == me, ( + put(fcomp, null, ' ' + getLocaleKey('ps.me')); + )); + if(query(me, 'has_scoreboard_tag', 'ica.wolf') + && query(p, 'has_scoreboard_tag', 'ica.wolf'), ( + put(fcomp, null, ' ' + getLocaleKey('ps.wolf')); + )); + )); + print(format(fcomp)); + )); +);