-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #499 from bcdice/fate_core_system
Fate Core System
- Loading branch information
Showing
3 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# frozen_string_literal: true | ||
|
||
module BCDice | ||
module GameSystem | ||
class FateCoreSystem < Base | ||
# ゲームシステムの識別子 | ||
ID = 'FateCoreSystem' | ||
|
||
# ゲームシステム名 | ||
NAME = 'Fate Core System' | ||
|
||
# ゲームシステム名の読みがな | ||
SORT_KEY = 'ふえいとこあしすてむ' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<~MESSAGETEXT | ||
■ ファッジダイスによる判定 (xDF+y>=t) | ||
ファッジダイスをx個ダイスロールし、結果を判定します。 | ||
x: ダイス数 | ||
y: 修正値(省略可) | ||
t: 目標値値(省略可) | ||
例)4DF, 4DF>=3, 4DF+1>=3 | ||
MESSAGETEXT | ||
|
||
register_prefix('\d+DF') | ||
|
||
def eval_game_system_specific_command(command) | ||
roll_df(command) | ||
end | ||
|
||
private | ||
|
||
def roll_df(command) | ||
parser = Command::Parser.new("DF", round_type: @round_type) | ||
.enable_prefix_number() | ||
.restrict_cmp_op_to(:>=, nil) | ||
|
||
parsed = parser.parse(command) | ||
unless parsed | ||
return nil | ||
end | ||
|
||
dice_list = roll_fate_dice(parsed.prefix_number) | ||
total = dice_list.sum() + parsed.modify_number | ||
|
||
fate_dice_list = dice_list.map do |i| | ||
if i.zero? | ||
"[ ]" | ||
elsif i.positive? | ||
"[+]" | ||
else | ||
"[-]" | ||
end | ||
end | ||
|
||
result = outcome(total, parsed.target_number) | ||
sequence = [ | ||
"(#{parsed})", | ||
"#{fate_dice_list.join()}#{Format.modifier(parsed.modify_number)}", | ||
result_ladder(total), | ||
result.text, | ||
] | ||
|
||
result.text = sequence.compact.join(" > ") | ||
return result | ||
end | ||
|
||
def roll_fate_dice(times) | ||
@randomizer.roll_barabara(times, 3).map { |i| i - 2 } | ||
end | ||
|
||
def result_ladder(total) | ||
ladder = | ||
case total.clamp(-2, 8) | ||
when 8 | ||
"Legendary" | ||
when 7 | ||
"Epic" | ||
when 6 | ||
"Fantastic" | ||
when 5 | ||
"Superb" | ||
when 4 | ||
"Great" | ||
when 3 | ||
"Good" | ||
when 2 | ||
"Fair" | ||
when 1 | ||
"Average" | ||
when 0 | ||
"Mediocre" | ||
when -1 | ||
"Poor" | ||
else | ||
"Terrible" | ||
end | ||
|
||
return "#{ladder}(#{format('%+d', total)})" | ||
end | ||
|
||
def outcome(total, target) | ||
if target.nil? | ||
Result.new | ||
elsif total == target | ||
Result.success("Tie") | ||
elsif total >= target + 3 | ||
Result.critical("Succeed with Style") | ||
elsif total >= target | ||
Result.success("Succeed") | ||
else | ||
Result.failure("Fail") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [-][ ][-][-] > Terrible(-3)" | ||
rands = [ | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [-][ ][-][ ] > Terrible(-2)" | ||
rands = [ | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [ ][ ][-][ ] > Poor(-1)" | ||
rands = [ | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [ ][ ][ ][ ] > Mediocre(+0)" | ||
rands = [ | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [+][ ][ ][ ] > Average(+1)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [+][+][ ][ ] > Fair(+2)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [+][+][+][ ] > Good(+3)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 2 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [+][+][+][+] > Great(+4)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "5DF" | ||
output = "(5DF) > [+][+][+][+][+] > Superb(+5)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "5DF+1" | ||
output = "(5DF+1) > [+][+][+][+][+]+1 > Fantastic(+6)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "5DF+2" | ||
output = "(5DF+2) > [+][+][+][+][+]+2 > Epic(+7)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "5DF+3" | ||
output = "(5DF+3) > [+][+][+][+][+]+3 > Legendary(+8)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "5DF+4" | ||
output = "(5DF+4) > [+][+][+][+][+]+4 > Legendary(+9)" | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF" | ||
output = "(4DF) > [ ][-][ ][+] > Mediocre(+0)" | ||
rands = [ | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 1 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF>=3" | ||
output = "(4DF>=3) > [+][+][+][+] > Great(+4) > Succeed" | ||
success = true | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF+1>=3" | ||
output = "(4DF+1>=3) > [+][+][+][+]+1 > Superb(+5) > Succeed" | ||
success = true | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF+2>=3" | ||
output = "(4DF+2>=3) > [+][+][+][+]+2 > Fantastic(+6) > Succeed with Style" | ||
success = true | ||
critical = true | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF+1>=3" | ||
output = "(4DF+1>=3) > [+][+][+][-]+1 > Good(+3) > Tie" | ||
success = true | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 1 }, | ||
] | ||
|
||
[[ test ]] | ||
game_system = "FateCoreSystem" | ||
input = "4DF+1>=3" | ||
output = "(4DF+1>=3) > [+][ ][+][-]+1 > Fair(+2) > Fail" | ||
failure = true | ||
rands = [ | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 2 }, | ||
{ sides = 3, value = 3 }, | ||
{ sides = 3, value = 1 }, | ||
] |