add_score.mcfunction 1.9 KB

123456789101112131415161718
  1. #as player
  2. execute store result score #bonus_add_score mem run data get block 0 0 0 RecordItem.tag.bonus_add_score
  3. # 正常的加分
  4. execute unless score #bonus_add_score mem matches 100 run scoreboard players operation @s total_score += #bonus_add_score mem
  5. execute unless score #bonus_add_score mem matches 100 run scoreboard players operation @s total_score_disp += #bonus_add_score mem
  6. execute unless score #bonus_add_score mem matches 100 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 获得了 ",{"score": {"name":"#bonus_add_score","objective": "mem"}}, " 分, 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 分"]
  7. # 100:硬币
  8. scoreboard players set $random_max mem 1
  9. scoreboard players set $random_min mem 0
  10. function lib:random
  11. execute if score #bonus_add_score mem matches 100 if score $random mem matches 1 run scoreboard players operation @s total_score *= $c_2 mem
  12. execute if score #bonus_add_score mem matches 100 if score $random mem matches 1 run scoreboard players operation @s total_score_disp *= $c_2 mem
  13. execute if score #bonus_add_score mem matches 100 if score $random mem matches 1 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 的硬币投出了正面, 得分加倍, 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 分"]
  14. execute if score #bonus_add_score mem matches 100 if score $random mem matches 0 run scoreboard players operation @s total_score /= $c_2 mem
  15. execute if score #bonus_add_score mem matches 100 if score $random mem matches 0 run scoreboard players operation @s total_score_disp /= $c_2 mem
  16. execute if score #bonus_add_score mem matches 100 if score $random mem matches 0 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 的硬币投出了反面, 得分减半, 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 分"]