
# -> Get increased XP value (length / 2)
scoreboard players operation #or.book_written_length OverlyRealistic.General.ArbitraryData /= #or.static_num_2 OverlyRealistic.General.ArbitraryData
execute if score #or.book_written_length OverlyRealistic.General.ArbitraryData matches ..-1 run \
    scoreboard players set #or.book_written_length OverlyRealistic.General.ArbitraryData 0

# -> Set to skill XP
scoreboard players operation #or.skill_xp_increase OverlyRealistic.General.ArbitraryData += #or.book_written_length OverlyRealistic.General.ArbitraryData

# -> 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.Scribing_XP += #or.skill_xp_increase OverlyRealistic.General.ArbitraryData


# -> 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.Scribing_XP += #or.intelligence_level OverlyRealistic.General.ArbitraryData

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

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