ソースを参照

重构准备系统

LTCatt 6 年 前
親
コミット
e8a8c116ed

+ 0 - 1
data/ltw/functions/init.mcfunction

@@ -95,7 +95,6 @@ scoreboard players set #const_9 mem 9
 scoreboard players set #const_10 mem 10
 scoreboard players set #const_81 mem 81
 scoreboard players set #const_100 mem 100
-scoreboard players set $game_type mem 1
 
 # 队伍
 team remove player

+ 2 - 2
data/ltw/functions/main/player_leave.mcfunction

@@ -3,8 +3,8 @@ execute as @a at @s run function lib:sounds/error
 
 # 由于玩家人数不足,强制结束游戏
 execute store result score #count mem if entity @a[tag=!watcher]
-execute if score $state mem matches 1.. if score $game_type mem matches 1 if score #count mem matches ..2 run function ltw:main/game_end
-execute if score $state mem matches 1.. if score $game_type mem matches 1 if score #count mem matches ..2 run tellraw @a ["",{"text":">> ","color":"red","bold":true},{"text": "由于玩家不足, 游戏强制结束, 无名次金粒奖励……","color":"red","bold":false}]
+execute if score $state mem matches 1.. if score #count mem matches ..2 run function ltw:main/game_end
+execute if score $state mem matches 1.. if score #count mem matches ..2 run tellraw @a ["",{"text":">> ","color":"red","bold":true},{"text": "由于玩家不足, 游戏强制结束, 无名次金粒奖励……","color":"red","bold":false}]
 
 # 如果携带热土豆的玩家掉线,则重新生成土豆
 execute if score $state mem matches 5 run function mini:main/player_leave

+ 0 - 8
data/ltw/functions/state/0/change_classic.mcfunction

@@ -1,8 +0,0 @@
-# 切换为晶石模式
-execute if score $game_type mem matches 1 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},"游戏模式已切换为 ",{"text": "晶石模式","color":"aqua"}]
-execute if score $game_type mem matches 1 as @a at @s run function lib:sounds/teleport
-scoreboard players set $game_type mem 0
-function ltw:state/0/refresh_game_type
-
-# 取消倒计时
-scoreboard players set $countdown mem 0

+ 0 - 8
data/ltw/functions/state/0/change_gameparty.mcfunction

@@ -1,8 +0,0 @@
-# 切换为派对模式
-execute if score $game_type mem matches 0 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},"游戏模式已切换为 ",{"text": "派对模式","color":"aqua"}]
-execute if score $game_type mem matches 0 as @a at @s run function lib:sounds/teleport
-scoreboard players set $game_type mem 1
-function ltw:state/0/refresh_game_type
-
-# 取消倒计时
-scoreboard players set $countdown mem 0

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

@@ -1,3 +0,0 @@
-# 更新当前选择的小游戏状态
-execute if score $game_type mem matches 0 run fill 14 15 1 19 11 6 minecraft:crimson_hyphae replace minecraft:warped_hyphae
-execute if score $game_type mem matches 1 run fill 14 15 1 19 11 6 minecraft:warped_hyphae replace minecraft:crimson_hyphae

+ 0 - 1
data/ltw/functions/state/0/start_gameparty.mcfunction

@@ -11,7 +11,6 @@ scoreboard players set @a[tag=!watcher] total_score 0
 scoreboard players reset * total_score_disp
 scoreboard players set @a[tag=!watcher] total_score_disp 0
 scoreboard players set $round mem 1
-scoreboard players set $game_type mem 1
 scoreboard players add $ game_id 1
 scoreboard players operation @a game_id = $ game_id
 

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

@@ -30,6 +30,3 @@ function ltw:state/0/parkour/tempo_block/marker_spawn
 
 # 重置开始倒计时
 scoreboard players set $countdown mem 0
-
-# 重置当前状态
-function ltw:state/0/refresh_game_type

+ 2 - 7
data/ltw/functions/state/0/tick20.mcfunction

@@ -1,12 +1,7 @@
 # 尝试进行倒计时
-execute if score $countdown mem matches 1.. if score $game_type mem matches 0 run function ltw:state/0/try_start_classic
-execute if score $countdown mem matches 1.. if score $game_type mem matches 1 run function ltw:state/0/try_start_gameparty
+execute if score $countdown mem matches 1.. run function ltw:state/0/try_start_gameparty
 
-# 显示倒计时,播放音效
-execute store result score $count mem if entity @a[tag=lobby_ready]
-execute if score $countdown mem matches 1.. run title @a times 3 14 2
+# 计算倒计时,播放音效
 scoreboard players operation #time mem = $countdown mem
 scoreboard players remove #time mem 1
-execute if score $countdown mem matches 1.. run title @a subtitle [{"score":{"name":"#time","objective":"mem"}}," 秒 | ",{"score":{"name":"$count","objective":"mem"}}," 人"]
-execute if score $countdown mem matches 1.. run title @a title [""]
 execute if score $countdown mem matches 1..10 run execute as @a at @s run function lib:sounds/hit2

+ 7 - 6
data/ltw/functions/state/0/tick5.mcfunction

@@ -1,8 +1,4 @@
-# 判断玩家是否处于准备状态
-# tag @a remove lobby_ready
-# tag @a remove lobby_watch
-# tag @a[x=-24,y=8,z=-32,dx=5,dy=5,dz=5] add lobby_ready
-# tag @a[tag=!lobby_ready] add lobby_watch
+# 让无状态玩家变为准备状态
 execute as @a[tag=!lobby_ready,tag=!lobby_watch] run function item:lobby_state/join_watch
 
 # 给予进度
@@ -10,6 +6,11 @@ execute as @a at @s if entity @s[x=-1,y=22,z=-29,dx=5,dy=3,dz=3] run advancement
 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
 
-# 隐藏名片
+# 隐藏/显示老板的名片
 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
+
+# 显示信息
+execute store result score $count mem if entity @a[tag=lobby_ready]
+execute if score $countdown mem matches 1.. run title @a actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#time","objective":"mem"}}," 秒后开始游戏"]
+execute if score $countdown mem matches 0 run title @a actionbar [{"text":"","color":"yellow"},{"score":{"name":"$count","objective":"mem"}}," 人已准备"]

+ 0 - 4
data/ltw/functions/state/0/try_start_classic.mcfunction

@@ -1,4 +0,0 @@
-# 尝试开始晶石模式
-tellraw @a[tag=lobby_ready] ["",{"text": ">> ","color":"red","bold": true},{"text": "晶石模式尚未完成, 请开始派对模式!","color":"red"}]
-execute as @a[tag=lobby_ready] at @s run function lib:sounds/error
-scoreboard players set $countdown mem 0

+ 2 - 3
data/ltw/functions/state/0/try_start_game.mcfunction

@@ -1,9 +1,8 @@
-# 尝试开始任意游戏
+# 尝试开始游戏
 
 # 进行条件判断
 execute if score $countdown mem matches 0 run scoreboard players set $countdown mem 999
-execute if score $game_type mem matches 0 run function ltw:state/0/try_start_classic
-execute if score $game_type mem matches 1 run function ltw:state/0/try_start_gameparty
+function ltw:state/0/try_start_gameparty
 
 # 进行提示
 execute if score $countdown mem matches 999 run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]

+ 2 - 2
data/ltw/functions/state/7/next.mcfunction

@@ -18,8 +18,8 @@ execute unless entity @a[tag=new_selector] if entity @a[tag=selecting] run tellr
 
 # 以玩家为对象开始执行
 execute as @a[tag=new_selector] run function ltw:state/7/next2
-execute unless entity @a[tag=new_selector] if score $game_type mem matches 1 if score $round mem matches 5.. run function ltw:main/game_end
-execute unless entity @a[tag=new_selector] if score $game_type mem matches 1 if score $round mem matches ..4 run function ltw:state/7/continue_gameparty
+execute unless entity @a[tag=new_selector] if score $round mem matches 5.. run function ltw:main/game_end
+execute unless entity @a[tag=new_selector] if score $round mem matches ..4 run function ltw:state/7/continue_gameparty
 
 # 初始化倒计时与 HUD
 scoreboard players set $countdown mem 10