# Upgrades armor level
scoreboard players add armor_level zombData 1
# Takes points off score
scoreboard players operation points zombData -= cost zombData

# Fanfare
particle minecraft:firework 0.5 56.5 73.5 0.1 0 0.1 0.1 40
execute as @a[scores={location=3}] at @s run playsound minecraft:entity.player.levelup master @a ~ ~ ~ 1 1.5
execute if score armor_level zombData matches 1 run tellraw @a[scores={location=3}] [{"text":"\n ","color":"gray"},{"selector":"@s","color":"white"},{"text":" purchased"},{"text":" Armor Upgrade","color":"red"},{"text":" level"},{"text":" 1","color":"white"},{"text":" !\n"}]
execute if score armor_level zombData matches 2 run tellraw @a[scores={location=3}] [{"text":"\n ","color":"gray"},{"selector":"@s","color":"white"},{"text":" purchased"},{"text":" Armor Upgrade","color":"red"},{"text":" level"},{"text":" 2","color":"white"},{"text":" !\n"}]
execute if score armor_level zombData matches 3 run tellraw @a[scores={location=3}] [{"text":"\n ","color":"gray"},{"selector":"@s","color":"white"},{"text":" purchased"},{"text":" Armor Upgrade","color":"red"},{"text":" level"},{"text":" 3","color":"white"},{"text":" !\n"}]

# Changes the armor stand display
execute if score armor_level zombData matches 1 run data modify entity @e[type=armor_stand,limit=1,tag=armor_upgrade_display] ArmorItems set value [{id:"minecraft:iron_boots",count:1},{id:"minecraft:iron_leggings",count:1},{id:"minecraft:iron_chestplate",count:1},{}]
execute if score armor_level zombData matches 2 run data modify entity @e[type=armor_stand,limit=1,tag=armor_upgrade_display] ArmorItems set value [{id:"minecraft:diamond_boots",count:1},{id:"minecraft:diamond_leggings",count:1},{id:"minecraft:diamond_chestplate",count:1},{}]

# Changes the text display for armor
execute if score armor_level zombData matches 1 run data modify entity @e[type=text_display,limit=1,tag=armor_upgrade_text] text set value '[{"text":"","color":"gray"},{"text":"Cost: "},\
{"text":"1500","color":"white"},{"text":" points\\n"},{"text":"- "},\
{"text":"❤❤","color":"red"},\
{"text":"❤❤","color":"dark_gray"},{"text":" -"}]'
execute if score armor_level zombData matches 2 run data modify entity @e[type=text_display,limit=1,tag=armor_upgrade_text] text set value '[{"text":"","color":"gray"},{"text":"Cost: "},\
{"text":"2000","color":"white"},{"text":" points\\n"},{"text":"- "},\
{"text":"❤❤❤","color":"red"},\
{"text":"❤","color":"dark_gray"},{"text":" -"}]'
execute if score armor_level zombData matches 3 run data modify entity @e[type=text_display,limit=1,tag=armor_upgrade_text] text set value '[{"text":"","color":"gray"},\
{"text":"MAX LEVEL\\n","color":"gray"},{"text":"- "},\
{"text":"❤❤❤❤","color":"red"},\
{"text":"","color":"dark_gray"},{"text":" -"}]'

# Clears players of their armor
clear @a[scores={location=3}] #ss:armor
clear @a[scores={location=3}] potato