
# gem
execute store result score @s inventory_gems run clear @s minecraft:emerald[minecraft:custom_data={gem:1b}] 0
clear @s minecraft:emerald[minecraft:custom_data={gem:1b}]
execute store result score #amount temp run random value 1..2
execute store result storage pctf:gems input.amount int 1 run scoreboard players operation @s inventory_gems *= #amount temp
execute if score @s inventory_gems matches 1.. run function pctf:logic/player/gems/set_gems_to_add with storage pctf:gems input
scoreboard players reset @s inventory_gems

# regular coins
execute store result score @s inventory_coins run clear @s minecraft:sunflower[minecraft:custom_data={coin:1b}] 0
clear @s minecraft:sunflower[minecraft:custom_data={coin:1b}]
execute store result score #amount temp run random value 3..5
execute store result storage pctf:coins input.amount int 1 run scoreboard players operation @s inventory_coins *= #amount temp
execute if score @s inventory_coins matches 1.. run function pctf:logic/player/coins/set_coins_to_add with storage pctf:coins input
scoreboard players reset @s inventory_coins

# 1 coin
execute store result score @s inventory_coins run clear @s minecraft:sunflower[minecraft:custom_data={coin:1b,one:1b}] 0
clear @s minecraft:sunflower[minecraft:custom_data={coin:1b,one:1b}]
execute store result score #amount temp run random value 1..3
execute store result storage pctf:coins input.amount int 1 run scoreboard players operation @s inventory_coins *= #amount temp
execute if score @s inventory_coins matches 1.. run function pctf:logic/player/coins/set_coins_to_add with storage pctf:coins input
scoreboard players reset @s inventory_coins

execute store result score @s[team=blue] inventory_coins run clear @s minecraft:sunflower[minecraft:custom_data={coin:1b,blue:1b}] 0
execute store result score @s[team=red] inventory_coins run clear @s minecraft:sunflower[minecraft:custom_data={coin:1b,red:1b}] 0

# team coins
execute store result score @s inventory_coins run clear @s minecraft:sunflower[minecraft:custom_data~{coin:1b}] 0
clear @s minecraft:sunflower[minecraft:custom_data~{coin:1b}]
execute store result score #amount temp run random value 6..12
execute store result storage pctf:coins input.amount int 1 run scoreboard players operation @s inventory_coins *= #amount temp
execute if score @s inventory_coins matches 1.. run function pctf:logic/player/coins/set_coins_to_add with storage pctf:coins input
scoreboard players reset @s inventory_coins

scoreboard players reset @s temp