#loop


#first login
scoreboard players add @a[tag=!xlifeinstalled] deaths 0
scoreboard players add @a[tag=!xlifeinstalled] newdeath 0
tag @a[tag=!xlifeinstalled,scores={deaths=0}] add xlifeinstalled

#newdeath
tag @e[type=player,scores={newdeath=1}] remove heartsSet
scoreboard players set @e[type=player,scores={newdeath=1}] newdeath 0

#setting hearts amount
#1 heart
tellraw @p[tag=!heartsSet,scores={deaths=0}] [{"bold": true, "text":"Welcome to X-Life", "color":"green"}]
tellraw @p[tag=!heartsSet,scores={deaths=0}] [{"bold": false, "text":"You start with 1 heart and 10 lives, with each death you lose a life, but get 1 extra heart. Have fun!", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=0}] minecraft:generic.max_health base set 2

#2 hearts
tellraw @p[tag=!heartsSet,scores={deaths=1}] [{"bold": false, "text":"You died, you have 9 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=1}] minecraft:generic.max_health base set 4

#3 hearts
tellraw @p[tag=!heartsSet,scores={deaths=2}] [{"bold": false, "text":"You died, you have 8 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=2}] minecraft:generic.max_health base set 6

#4 hearts
tellraw @p[tag=!heartsSet,scores={deaths=3}] [{"bold": false, "text":"You died, you have 7 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=3}] minecraft:generic.max_health base set 8

#5 hearts
tellraw @p[tag=!heartsSet,scores={deaths=4}] [{"bold": false, "text":"You died, you have 6 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=4}] minecraft:generic.max_health base set 10

#6 hearts
tellraw @p[tag=!heartsSet,scores={deaths=5}] [{"bold": false, "text":"You died, you have 5 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=5}] minecraft:generic.max_health base set 12

#7 hearts
tellraw @p[tag=!heartsSet,scores={deaths=6}] [{"bold": false, "text":"You died, you have 4 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=6}] minecraft:generic.max_health base set 14

#8 hearts
tellraw @p[tag=!heartsSet,scores={deaths=7}] [{"bold": false, "text":"You died, you have 3 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=7}] minecraft:generic.max_health base set 16

#9 hearts
tellraw @p[tag=!heartsSet,scores={deaths=8}] [{"bold": false, "text":"You died, you have 2 lives left.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=8}] minecraft:generic.max_health base set 18

#10 hearts
tellraw @p[tag=!heartsSet,scores={deaths=9}] [{"bold": false, "text":"You died, be careful, this is your last life.", "color":"dark_aqua"}]
attribute @p[tag=!heartsSet,scores={deaths=9}] minecraft:generic.max_health base set 20

#it's over
tellraw @p[tag=!heartsSet,scores={deaths=10}] [{"bold": false, "text":"Well, that's a bummer, that was your last life, you're now in spectator mode.", "color":"dark_aqua"}]
gamemode spectator @p[tag=!heartsSet,scores={deaths=10}]

tag @p[tag=!heartsSet, scores={deaths=0..}] add heartsSet
