Browse Source

自动开始游戏

LTCatt 6 years ago
parent
commit
760bb79181

+ 0 - 1
data/ltw/functions/main/player_enter.mcfunction

@@ -24,6 +24,5 @@ function lib:bossbar/show
 
 # FIXME: [010] 在 init 的时候也重置随机数组
 # FIXME: [010] 已确认确实可以用钓鱼竿获得两个奖励
-# FIXME: [LTCat] 在游戏开局的时候可能会看到 2 然后 ding
 # TODO: [LTCat/HIM] 土豆的两个炸弹同时爆炸把两个人炸死,让他们俩并列第三(按存活回合数记分)
 # FIXME: 旁观者在一轮开始时会被切换为冒险模式又切回去,这会造成游戏模式变更提示,鬼知道为啥

+ 0 - 0
data/ltw/functions/state/0/start_gameparty.mcfunction → data/ltw/functions/state/0/start_game.mcfunction


+ 28 - 5
data/ltw/functions/state/0/tick20.mcfunction

@@ -1,7 +1,30 @@
-# 尝试进行倒计时
-execute if score $countdown mem matches 1.. run function ltw:state/0/try_start_gameparty
 
-# 计算倒计时,播放音效
-scoreboard players operation #time mem = $countdown mem
-scoreboard players remove #time mem 1
+# 检查已准备人数
+execute store result score $count mem if entity @a[tag=lobby_ready]
+
+# 开始:提示开始
+execute if score $count mem matches 3.. if score $countdown mem matches 99.. run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]
+execute if score $count mem matches 3.. if score $countdown mem matches 99.. as @a at @s run function lib:sounds/levelup
+execute if score $count mem matches 3.. if score $countdown mem matches 99.. run scoreboard players set $countdown mem 40
+
+# 取消:提示取消
+execute if score $count mem matches ..2 if score $countdown mem matches ..99 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","bold": true},"已准备人数不足, 游戏取消!"]
+execute if score $count mem matches ..2 if score $countdown mem matches ..99 as @a at @s run function lib:sounds/error
+execute if score $count mem matches ..2 if score $countdown mem matches ..99 run scoreboard players set $countdown mem 999
+
+# 20s:提示未准备
+execute if score $countdown mem matches 20 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
+
+# 30、10s:提示玩家数量过多
+execute if score $countdown mem matches 30 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
+execute if score $countdown mem matches 10 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
+
+# 10-:播放音效
 execute if score $countdown mem matches 1..10 run execute as @a at @s run function lib:sounds/hit2
+
+# 0:开始游戏
+execute if score $countdown mem matches 0 run function ltw:state/0/start_game
+
+# 显示信息
+execute if score $countdown mem matches ..99 run title @a actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#time","objective":"mem"}}," 秒后开始游戏"]
+execute if score $countdown mem matches 99.. run title @a actionbar [{"text":"","color":"red"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | 准备人数不足"]

+ 0 - 5
data/ltw/functions/state/0/tick5.mcfunction

@@ -9,8 +9,3 @@ execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement gr
 # 隐藏/显示老板的名片
 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 - 10
data/ltw/functions/state/0/try_start_game.mcfunction

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

+ 0 - 19
data/ltw/functions/state/0/try_start_gameparty.mcfunction

@@ -1,19 +0,0 @@
-# 尝试开始派对模式
-
-# 计算玩家数量
-execute store result score $count mem if entity @a[tag=lobby_ready]
-
-# 判断玩家数量过少
-execute if score $count mem matches ..2 as @a at @s run function lib:sounds/error
-execute if score $count mem matches ..2 run tellraw @a ["",{"text": ">> ","color":"red","bold": true},"需要至少 3 人准备以开始游戏, ",{"text":"当前仅有 ","color":"red"},{"score": {"name": "$count","objective": "mem"},"color":"red"},{"text": " 人","color":"red"}]
-execute if score $count mem matches ..2 run scoreboard players set $countdown mem 0
-
-# 提示未准备
-execute if score $countdown mem matches 10 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 可以丢出快捷栏最后一格的物品准备!"]
-
-# 判断玩家数量过多
-execute if score $count mem matches 9.. if score $countdown mem matches 15 run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
-execute if score $count mem matches 9.. if score $countdown mem matches 1 run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
-
-# 开始游戏
-execute if score $countdown mem matches 1 run function ltw:state/0/start_gameparty