
# --> (@EVENT: Completed the telescope minigame /// ID: 100,088)

# -> Message
execute if score #or.setting.output_messages OverlyRealistic.Settings.ArbitrarySetting matches 1 \
    if score #or.setting.overlay_messages OverlyRealistic.Settings.ArbitrarySetting matches 1 run \
        tellraw @s [\
        {\
            text:"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"\
        },\
        {\
            text:"[Closing GUI] \n",\
            color:"#929292",\
            bold:true\
        },\
        {\
            text:"\n\n"\
        }\
    ]

# -> If theres no telescope nearby then return
execute unless entity @n[type=interaction,tag=OverlyRealistic.Block.Telescope,distance=..8] run \
    return fail

# -> Sound
playsound entity.experience_orb.pickup block @s ~ ~ ~ 0.5 1
playsound minecraft:item.spyglass.use block @s ~ ~ ~ 1 0.8

# -> Close GUI
dialog show @s overly_realistic:empty
dialog clear @s

# -> Show completion text
title @s times 0 40 20
title @s title ""
title @s subtitle {text:"Completed!",color:"#51e018"}

# -> Reward with scribery experience
function overly_realistic:players/wisdom/scribing/add_to_skill_xp_c_be_near_bookshelves

# -> On RNG, give intelligence
execute if predicate overly_realistic:world/telescope/intelligence_gain_rng run \
    scoreboard players add @s[scores={OverlyRealistic.Player.Stats.Intelligence=..99}] OverlyRealistic.Player.Stats.Intelligence 1

# -> Set LastTimeUsedTelescope
scoreboard players operation @s OverlyRealistic.Player.LastTimeUsedTelescope = #or.WorldDay OverlyRealistic.General.ArbitraryData
