execute if score @s armor_enchant_lvl matches 3.. run return run tellraw @s {"text":"You already purchased all armor enchants!","color":"aqua"}

$execute if score @s armor_enchant_lvl matches 0 unless score @s gems matches $(enchant_armor0).. run return run tellraw @s {"text":"You don't have enough gems! ($(enchant_armor0)g)","color":"red"}
$execute if score @s armor_enchant_lvl matches 1 unless score @s gems matches $(enchant_armor1).. run return run tellraw @s {"text":"You don't have enough gems! ($(enchant_armor1)g)","color":"red"}
$execute if score @s armor_enchant_lvl matches 2 unless score @s gems matches $(enchant_armor2).. run return run tellraw @s {"text":"You don't have enough gems! ($(enchant_armor2)g)","color":"red"}

$execute if score @s armor_enchant_lvl matches 0 run function pctf:logic/player/gems/remove {amount: "$(enchant_armor0)"}
$execute if score @s armor_enchant_lvl matches 1 run function pctf:logic/player/gems/remove {amount: "$(enchant_armor1)"}
$execute if score @s armor_enchant_lvl matches 2 run function pctf:logic/player/gems/remove {amount: "$(enchant_armor2)"}

scoreboard players add @s armor_enchant_lvl 1

execute if entity @s[nbt={active_effects:[{id:"minecraft:invisibility"}]}] run return 0

clear @s #pctf:armors

execute if entity @s[team=blue] run function pctf:logic/player/armor/blue
execute if entity @s[team=red] run function pctf:logic/player/armor/red