add_score.mcfunction 3.6 KB

123456789101112131415161718192021222324252627282930313233
  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 if score #bonus_add_score mem matches ..10 run scoreboard players operation @s total_score += #bonus_add_score mem
  5. execute if score #bonus_add_score mem matches ..10 run scoreboard players operation @s total_score_disp += #bonus_add_score mem
  6. execute if score #bonus_add_score mem matches ..10 run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 获得了 ",{"score": {"name":"#bonus_add_score","objective": "mem"},"color":"aqua"},{"text": " 分","color":"aqua"},", 当前共有 ",{"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":"green","bold": true},{"selector": "@s","color":"green"}," 的硬币投出了正面, 得分加倍, 当前共有 ",{"score": {"name": "@s","objective": "total_score"},"color":"green"},{"text": " 分", "color":"green"}]
  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":"red","bold": true},{"selector": "@s","color":"red"}," 的硬币投出了反面, 得分减半, 当前共有 ",{"score": {"name": "@s","objective": "total_score"},"color":"red"},{"text": " 分", "color":"red"}]
  17. # 200:偷分
  18. execute if score #bonus_add_score mem matches 200 run scoreboard players add @s total_score 1
  19. execute if score #bonus_add_score mem matches 200 run scoreboard players add @s total_score_disp 1
  20. scoreboard players set #score_max mem -2147483648
  21. execute as @a run function ltw:main/get_max_score
  22. tag @a remove highest
  23. execute as @a if score @s total_score = #score_max mem run tag @s add highest
  24. execute if score #bonus_add_score mem matches 200 run scoreboard players remove @a[tag=highest,limit=1,sort=furthest] total_score 1
  25. execute if score #bonus_add_score mem matches 200 run scoreboard players remove @a[tag=highest,limit=1,sort=furthest] total_score_disp 1
  26. execute if score #bonus_add_score mem matches 200 if entity @s[tag=highest] run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 试图偷取自己的分数……"]
  27. execute if score #bonus_add_score mem matches 200 if entity @s[tag=!highest] run tellraw @a ["",{"text": ">> ","color":"red","bold": true},{"selector": "@a[tag=highest,limit=1,sort=furthest]","color":"red"}," 被偷取了 ",{"text": "1 分","color":"red"},", 当前共有 ",{"score": {"name": "@a[tag=highest,limit=1,sort=furthest]","objective": "total_score"}}, " 分"]
  28. execute if score #bonus_add_score mem matches 200 if entity @s[tag=!highest] run tellraw @a ["",{"text": ">> ","color":"green","bold": true},{"selector": "@s","color":"green"}," 偷取了 ",{"text": "1 分","color":"green"},", 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 分"]
  29. # FIXME : [LTCat] 偷分可能存在 Bug?