add_score.mcfunction 3.0 KB

1234567891011121314151617181920212223242526
  1. #as player
  2. execute store result score #bonus_add_score mem run data get storage item:bonus item.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 ..0 run tellraw @a ["",{"text": ">> ","color":"red","bold": true},{"selector": "@s","color":"red"}," 没能获得积分……"]
  7. execute if score #bonus_add_score mem matches 1..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"}}, " 积分"]
  8. # 100:普通硬币 / 101:高级硬币
  9. scoreboard players set $random_max mem 1
  10. scoreboard players set $random_min mem 0
  11. function lib:random
  12. execute if score #bonus_add_score mem matches 100..101 if score $random mem matches 1 run scoreboard players operation @s total_score *= #2 mem
  13. execute if score #bonus_add_score mem matches 100..101 if score $random mem matches 1 run scoreboard players operation @s total_score_disp *= #2 mem
  14. execute if score #bonus_add_score mem matches 100..101 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"}]
  15. execute if score #bonus_add_score mem matches 100 if score $random mem matches 0 run scoreboard players operation @s total_score /= #2 mem
  16. execute if score #bonus_add_score mem matches 100 if score $random mem matches 0 run scoreboard players operation @s total_score_disp /= #2 mem
  17. 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"}]
  18. execute if score #bonus_add_score mem matches 101 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"}]
  19. # 给予进度
  20. execute if entity @s[scores={total_score=10..}] run advancement grant @s only ltw:story/score1
  21. execute if entity @s[scores={total_score=20..}] run advancement grant @s only ltw:story/score2
  22. execute if entity @s[scores={total_score=30..}] run advancement grant @s only ltw:story/score3
  23. execute if entity @s[scores={total_score=40..}] run advancement grant @s only ltw:story/score4