فهرست منبع

重构:游戏开始倒计时

LTCatt 5 سال پیش
والد
کامیت
90322e4088

+ 1 - 1
data/ltw/functions/state/0/sp/join_play.mcfunction

@@ -7,7 +7,7 @@ kill @e[type=item,nbt={Item:{id:"minecraft:gray_dye",tag:{lobby_item:1b}}}]
 execute if data entity @s Inventory[{Slot:0b}] run scoreboard players set @s temp 0
 execute if data entity @s Inventory[{Slot:0b}] at @s run function lib:pop_slot/return_item
 # 设置新的选择物品
-replaceitem entity @s hotbar.0 lime_dye{lobby_item:1b,display:{Name:'[{"text":"","color":"green","italic":false},"准备模式 (按 ",{"keybind":"key.drop"}," 旁观)"]',Lore:['[{"text":"","color":"gray","italic":false},"你将在下一局参与游戏"]']}}
+replaceitem entity @s hotbar.0 lime_dye{lobby_item:1b,display:{Name:'[{"text":"","color":"green","italic":false},"准备模式 (按 ",{"keybind":"key.drop"}," 以旁观)"]',Lore:['[{"text":"","color":"gray","italic":false},"你将在下一局参与游戏"]']}}
 
 # 设置队伍
 team join hub_play @s

+ 2 - 2
data/ltw/functions/state/0/sp/join_watch.mcfunction

@@ -2,12 +2,12 @@
 # 清理现有选择物品
 clear @s lime_dye{lobby_item:1b}
 clear @s gray_dye{lobby_item:1b}
-kill @e[type=item,nbt={Item:{id:"minecraft:gray_dye",tag:{lobby_item:1b}}}]
+kill @e[type=item,nbt={Item:{id:"minecraft:lime_dye",tag:{lobby_item:1b}}}]
 # 弹出玩家放在第一格上的物品
 execute if data entity @s Inventory[{Slot:0b}] run scoreboard players set @s temp 0
 execute if data entity @s Inventory[{Slot:0b}] at @s run function lib:pop_slot/return_item
 # 设置新的选择物品
-replaceitem entity @s hotbar.0 gray_dye{lobby_item:1b,display:{Name:'[{"text":"","color":"white","italic":false},"旁观模式 (按 ",{"keybind":"key.drop"}," 准备)"]',Lore:['[{"text":"","color":"gray","italic":false},"你将在下一局旁观游戏"]']}}
+replaceitem entity @s hotbar.0 gray_dye{lobby_item:1b,display:{Name:'[{"text":"","color":"white","italic":false},"旁观模式 (按 ",{"keybind":"key.drop"}," 以准备)"]',Lore:['[{"text":"","color":"gray","italic":false},"你将在下一局旁观游戏"]']}}
 
 # 设置队伍
 team join hub_watch @s

+ 3 - 3
data/ltw/functions/state/0/state_enter.mcfunction

@@ -38,14 +38,14 @@ execute as @a[team=!debug] run function ltw:state/0/player_enter
 
 # ——————————————————————————————————————————————
 
+# 重置开始倒计时
+scoreboard players set $start_countdown mem 9999999
 
 
 
 
-# TODO: 未完成的重构
 
-# 重置开始倒计时
-#scoreboard players set #start_countdown mem 9999999
+# TODO: 未完成的重构
 
 # 启用节奏跑酷
 #scoreboard players set $tempo_enable mem 1

+ 0 - 9
data/ltw/functions/state/0/tick2.mcfunction

@@ -2,12 +2,3 @@
 # 检查玩家是否移出了准备物品
 execute as @a[team=hub_watch] unless data entity @s Inventory[{Slot:0b,id:"minecraft:gray_dye",tag:{"lobby_item":1b}}] run function ltw:state/0/sp/join_play
 execute as @a[team=hub_play] unless data entity @s Inventory[{Slot:0b,id:"minecraft:lime_dye",tag:{"lobby_item":1b}}] run function ltw:state/0/sp/join_watch
-
-
-# TODO: 未完成的重构
-
-## 清除互斥的准备物品
-#execute as @a[team=hub_watch] if data entity @s Inventory[{tag:{lobby_item:1b,lobby_ready:1b}}] run clear @s lime_dye{lobby_item:1b} 
-#execute as @a[team=hub_play] if data entity @s Inventory[{tag:{lobby_item:1b,lobby_watch:1b}}] run clear @s gray_dye{lobby_item:1b}
-## 清除临时物品
-#clear @a red_dye{LockTempItem:1b}

+ 40 - 37
data/ltw/functions/state/0/tick5.mcfunction

@@ -3,51 +3,54 @@
 execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s if entity @a[distance=..5] run data modify entity @s CustomNameVisible set value true
 execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s unless entity @a[distance=..5] run data modify entity @s CustomNameVisible set value false
 
+# TODO: 未完成的重构
+
+## 20s:提示未准备
+#execute if score $start_countdown mem matches 80 run tellraw @a[team=watching] [{"text":"","color":"red"},{"text":">> ","bold": true},"你还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
+
+## 让无状态玩家变为旁观状态
+#execute as @a[team=!debug,team=!hub_play,team=!hub_watch] run function ltw:state/0/sp/join_watch
+
+## 给予主大厅进度
+#execute as @a at @s if entity @s[x=-1,y=22,z=-29,dx=5,dy=3,dz=3] run advancement grant @s only ltw:parkour/explore1
+#execute as @a at @s if entity @s[x=6,y=48,z=-32,dx=4,dy=3,dz=9] run advancement grant @s only ltw:parkour/explore2
+#execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement grant @s only ltw:parkour/explore3
+
+
 # ————————————————————————————————————————————————————————————————————————————
-# 游戏准备检查部分
+#  游戏开始倒计时
 # ————————————————————————————————————————————————————————————————————————————
 
-# TODO: 未完成的重构
+# 检查人数
+execute store result score #ready_count mem if entity @a[team=hub_play]
+execute store result score #total_count mem if entity @a
 
-# 检查已准备人数
-execute store result score $count mem if entity @a[team=hub_play]
-
-# 开始:提示开始
-execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]
-execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
-execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run scoreboard players set #start_countdown mem 121
-
-# 取消:提示取消
-execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","bold": true},"已准备人数不足, 游戏取消!"]
-execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
-execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run scoreboard players set #start_countdown mem 9999999
-
-# 播放音效
-scoreboard players remove #start_countdown mem 1
-scoreboard players operation #start_sec mem = #start_countdown mem
-scoreboard players operation #start_sec mem /= #const_4 mem
-scoreboard players operation #start_div mem = #start_countdown mem
-scoreboard players operation #start_div mem %= #const_4 mem
+# 人数足够,开始倒计时
+execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run tellraw @a [{"text":" ❇ ","color":"green"}," 游戏即将开始, 请使用第一格的物品确定自己是否参与!"]
+execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
+execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run scoreboard players set $start_countdown mem 241
+
+# 人数不足,取消倒计时
+execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run tellraw @a [{"text":" ✖ ","color":"red"}," 准备人数不足, 开始倒计时已取消!"]
+execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
+execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run scoreboard players set $start_countdown mem 9999999
+
+# 20s:提示玩家数量过多
+execute if score $start_countdown mem matches 80 if score #ready_count mem matches 9.. run tellraw @a [{"text":" ❇ ","color":"gold"}," 准备人数已超出 8 人的人数上限, 将随机抽取 8 人进行游戏!"]
+
+# 10s:播放倒计时音效
+scoreboard players remove $start_countdown mem 1
+scoreboard players operation #start_sec mem = $start_countdown mem
+scoreboard players operation #start_sec mem /= #4 mem
+scoreboard players operation #start_div mem = $start_countdown mem
+scoreboard players operation #start_div mem %= #4 mem
 execute if score #start_sec mem matches 1..10 if score #start_div mem matches 3 run execute as @a at @s run function lib:sounds/hit2
 
-# 20s:提示未准备
-execute if score #start_countdown mem matches 80 run tellraw @a[team=watching] [{"text":"","color":"red"},{"text":">> ","bold": true},"你还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
-
-# 10s:提示玩家数量过多
-execute if score #start_countdown mem matches 40 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"已超出游戏最多支持的 8 人人数上限, 将随机抽取 8 人开始游戏!"]
-
 # 0s:开始游戏
-execute if score #start_countdown mem matches 0 run function ltw:state/0/start_game
+execute if score $start_countdown mem matches 0 run function ltw:state/0/start_game
 
 # 显示信息
-execute store result score #total_count mem if entity @a
-execute if score #start_countdown mem matches 1..199 run title @a[team=!debugging] actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始游戏"]
-execute if score #start_countdown mem matches 200.. run title @a[team=!debugging] actionbar [{"text":"","color":"red"},{"score":{"name":"$count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 需要 3 人以开始游戏"]
+execute if score $start_countdown mem matches 1..999 run title @a[team=!debugging] actionbar [{"text":"","color":"green"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始游戏"]
+execute if score $start_countdown mem matches 999.. run title @a[team=!debugging] actionbar [{"text":"","color":"red"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 需要 3 人以开始游戏"]
 
-## 让无状态玩家变为旁观状态
-#execute as @a[team=!debug,team=!hub_play,team=!hub_watch] run function ltw:state/0/sp/join_watch
 
-## 给予主大厅进度
-#execute as @a at @s if entity @s[x=-1,y=22,z=-29,dx=5,dy=3,dz=3] run advancement grant @s only ltw:parkour/explore1
-#execute as @a at @s if entity @s[x=6,y=48,z=-32,dx=4,dy=3,dz=9] run advancement grant @s only ltw:parkour/explore2
-#execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement grant @s only ltw:parkour/explore3

+ 1 - 1
data/old/test/functions/countdown/quick.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:将倒计时修改为立即结束
 
-scoreboard players set #start_countdown mem 3
+scoreboard players set $start_countdown mem 3
 scoreboard players set $countdown mem 1
 scoreboard players set $countdown_fast mem 5
 tellraw @a ["",{"text": ">> ","color": "aqua","bold": true}, {"text": "管理员按下了快进键!","color": "aqua"}]

+ 1 - 1
data/old/test/functions/countdown/slow.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:将倒计时修改为永不结束
 
-scoreboard players set #start_countdown mem 999999
+scoreboard players set $start_countdown mem 999999
 scoreboard players set $countdown mem 999999
 scoreboard players set $countdown_fast mem 999999
 tellraw @a ["",{"text": ">> ","color": "aqua","bold": true}, {"text": "管理员将倒计时延长到了无限期!","color": "aqua"}]