# Clear
advancement grant @a only items:inv_update unlock
execute at @e[tag=center] run function rooms:0_clear/1_clear
kill @e[tag=tutorial_obj]
kill @e[tag=boss_warp]
kill @e[type=item]
tp @e[tag=EB] 0 -1 0
bossbar set generation visible false

# Clear lobby
kill @e[tag=lobby]
kill @e[type=experience_orb]

# Return meta coins if expended
scoreboard players set #tmp dungeon 5
scoreboard players operation floor dungeon *= #tmp dungeon
scoreboard players operation floor dungeon -= #tmp dungeon
scoreboard players operation mcoins shop += floor dungeon

# Structures
setblock -6 12 -7 structure_block{mode:"LOAD",name:"tutorial/00"}
setblock -6 13 -7 redstone_block
setblock -6 12 20 redstone_block
setblock -5 12 51 redstone_block
setblock -5 12 75 redstone_block
setblock -5 12 -7 air replace

# Markers
function lobby:tutorial/1_void
function lobby:tutorial/2_middle
function lobby:tutorial/3_armory
function lobby:tutorial/4_mana_souls
function lobby:tutorial/5_boss

execute as @e[tag=tutorial_obj,tag=!holder] run data merge entity @s {CustomNameVisible:1b,Marker:true,NoGravity:1b,Invisible:1b,Invulnerable:1b}

# Title
title @a title [{"text":">> ","color":"dark_red","bold":true},{"translate":"floor","color":"gold"},{"text":" 0","color":"gold"},{"text":" <<","color":"dark_red"}]
title @a subtitle {"translate":"tutorial","color":"gray","bold":true}
title @a times 10 60 10

# Reset
scoreboard players operation game state = #in_run state
scoreboard players set floor dungeon 0
execute as @a run gamemode adventure
effect clear @a
function game:reset

# warp
tp @a 0 16 0 0 0
function game:music/loop

# Inventory
execute as @a run function lobby:warp/inventory
execute as @a run scoreboard players operation @s mana = @s mana_capacity
