
# -> Reset timer var
scoreboard players set #or.global OverlyRealistic.Player.RegenTimer 0

# -> Base time
scoreboard players operation #or.global OverlyRealistic.Player.RegenTimer += #or.setting.base_regen_time OverlyRealistic.Settings.ArbitrarySetting

# -> Temperature check
execute unless score @s OverlyRealistic.Player.Stats.Temperature matches 30..80 run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 2

# -> Thirst check
execute unless score @s OverlyRealistic.Player.Stats.Thirst matches 80.. run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 3

execute unless score @s OverlyRealistic.Player.Stats.Thirst matches 40.. run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 5

# -> Hunger check
execute unless score @s OverlyRealistic.Player.Hunger matches ..15 run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 3

execute unless score @s OverlyRealistic.Player.Hunger matches ..5 run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 5

# -> Outside check
execute if predicate overly_realistic:player/temperature/is_outside run \
    scoreboard players add #or.global OverlyRealistic.Player.RegenTimer 1

# -> Healthcare check
execute if score @s OverlyRealistic.Player.WisdomStats.Healthcare matches 5 \
    if score #or.global OverlyRealistic.Player.RegenTimer matches 5.. run \
        scoreboard players remove #or.global OverlyRealistic.Player.RegenTimer 5

# -> Increase player regen timer
scoreboard players add @s OverlyRealistic.Player.RegenTimer 1

# -> Function tag
function #overly_realistic:mechanics/player_regen_operate

# -> If player regen timer is not over the max regen timer then return
execute unless score @s OverlyRealistic.Player.RegenTimer >= #or.global OverlyRealistic.Player.RegenTimer run \
    return fail

# -> Reset player regen timer
scoreboard players set @s OverlyRealistic.Player.RegenTimer 0

# -> Get player max health
execute store result score #or.global OverlyRealistic.General.ArbitraryData run \
    attribute @s max_health get

# -> If player health = player max health then return
execute if score @s OverlyRealistic.Player.Health = #or.global OverlyRealistic.General.ArbitraryData run \
    return fail

# -> Else, regen player
scoreboard players set @s OverlyRealistic.Player.PlayerHeal 10000
function overly_realistic:general/healing/heal_main