
# -> Reset counter
scoreboard players reset @s OverlyRealistic.Player.WisdomSpecialized.BlocksPlaced


# -> Set skill XP increase
scoreboard players set #or.skill_xp_increase OverlyRealistic.General.ArbitraryData 28

# -> If player is low on sanity then decrease XP change
execute if score @s OverlyRealistic.Player.IsFeelingDull matches 1 run \
    scoreboard players operation #or.skill_xp_increase OverlyRealistic.General.ArbitraryData /= #or.static_num_2 OverlyRealistic.General.ArbitraryData

# -> Add to skill XP
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Building_XP += #or.skill_xp_increase OverlyRealistic.General.ArbitraryData


# -> Sanity increase
execute if score @s OverlyRealistic.Player.WisdomStats.Building matches 4.. run \
    scoreboard players add @s OverlyRealistic.Player.Stats.MentalHealth 1

# -> Create inspiration marker on RNG, if possible
execute if score @s OverlyRealistic.Player.WisdomStats.Building matches 3 \
    if predicate overly_realistic:player/wisdom/inspiration_marker_creation_level_3 \
    unless entity @n[type=marker,tag=OverlyRealistic.Block.BuildInspirationMarker,distance=..84,sort=arbitrary] \
    summon marker run \
        function overly_realistic:players/wisdom/building/actions/create_inspiration_marker
execute if score @s OverlyRealistic.Player.WisdomStats.Building matches 4 \
    if predicate overly_realistic:player/wisdom/inspiration_marker_creation_level_4 \
    unless entity @n[type=marker,tag=OverlyRealistic.Block.BuildInspirationMarker,distance=..84,sort=arbitrary] \
    summon marker run \
        function overly_realistic:players/wisdom/building/actions/create_inspiration_marker
execute if score @s OverlyRealistic.Player.WisdomStats.Building matches 5 \
    if predicate overly_realistic:player/wisdom/inspiration_marker_creation_level_5 \
    unless entity @n[type=marker,tag=OverlyRealistic.Block.BuildInspirationMarker,distance=..84,sort=arbitrary] \
    summon marker run \
        function overly_realistic:players/wisdom/building/actions/create_inspiration_marker

# -> Intelligence buff
scoreboard players operation #or.intelligence_level OverlyRealistic.General.ArbitraryData = @s OverlyRealistic.Player.Stats.Intelligence
scoreboard players operation #or.intelligence_level OverlyRealistic.General.ArbitraryData /= #or.static_num_2 OverlyRealistic.General.ArbitraryData
scoreboard players operation @s OverlyRealistic.Player.WisdomStats.Building_XP += #or.intelligence_level OverlyRealistic.General.ArbitraryData

# -> Remove other skills' xp
function overly_realistic:players/wisdom/building/remove_from_others_xp

# -> If current XP is greater than the cap then increase level
execute if score @s OverlyRealistic.Player.WisdomStats.Building_XP >= @s OverlyRealistic.Player.WisdomStats.Building_XP_Max run \
    function overly_realistic:players/wisdom/building/increase_level
