Skip to content

Commit 58077cf

Browse files
authored
Merge pull request #835 from 8409jp/feature/aionia-improvement
[Aionia]慈悲なきアイオニアのダイスボット改善
2 parents bbc7790 + 99e10c7 commit 58077cf

File tree

2 files changed

+221
-19
lines changed

2 files changed

+221
-19
lines changed

lib/bcdice/game_system/Aionia.rb

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,43 @@ class Aionia < Base
1717
AB{n}>={dif} n=10面ダイスの数、dif=難易度
1818
- 技能判定(クリティカル・ファンブルあり)
1919
ABT{n}>={dif} n=10面ダイスの数、dif=難易度
20+
- ダメージチェック
21+
DMG>={dif} dif=ダメージ難易度
2022
21-
例:AB2>=5 (一般技能を活用して難易度5の技能判定。 クリファンなし。)
22-
例:ABT3>=15 (専門技能を活用して難易度15の技能判定。クリファンあり。)
23-
例:AB1+2>=8 (一般技能を活用せず難易度8の技能判定。 ボーナスとして+2点の補正あり。 クリファンなし。)
24-
例:ABT3-3>=10 (専門技能を活用して難易度10の技能判定。ペナルティとして-3点の補正あり。クリファンあり。)
25-
例:ABT2>=4/8/12 (一般技能を活用して難易度4/8/12の段階的な技能判定。クリファンあり。)
23+
※ 技能判定、ダメージチェックともにダイス結果、難易度に対して四則演算(+ - * /)を用いた複数ボーナスを含めることが可能です。計算結果の小数は切り捨てられます。
24+
25+
例:AB2>=5 (一般技能を活用して難易度5の技能判定。 クリファンなし。)
26+
例:ABT3>=15 (専門技能を活用して難易度15の技能判定。クリファンあり。)
27+
例:AB1+1+2>=8 (一般技能を活用せず難易度8の技能判定。 ボーナスとして+1と+2点の補正あり。 クリファンなし。)
28+
例:ABT3-3>=10+2 (専門技能を活用して難易度10+2の技能判定。ペナルティとして-3点の補正あり。クリファンあり。)
29+
例:ABT2>=4/8/12 (一般技能を活用して難易度4/8/12の段階的な技能判定。クリファンあり。)
30+
例:DMG>=50 (難易度50の判定。)
31+
例:DMG>=20+50 (難易度20+50の判定。)
2632
INFO_MESSAGE_TEXT
2733

28-
register_prefix('ABT?\d+([\+\-]\d+)?>=\d+(\/\d+)*')
34+
register_prefix('ABT?', 'DMG')
2935

3036
def eval_game_system_specific_command(command)
31-
return roll_skills(command)
37+
return roll_skills(command) || roll_damage_check(command)
3238
end
3339

3440
def roll_skills(command)
35-
m = %r{AB(T?)(\d+)([+-]\d+)?>=((\d+)((/\d+)*))}.match(command)
41+
m = %r{^AB(T?)(\d+)((?:[-+]\d+)*)>=(\d+(?:/\d+)*)((?:[-+]\d+)*)$}.match(command)
3642
return nil unless m
3743

3844
# 値の取得
3945
use_cf = m[1] != ''
4046
times = m[2].to_i
41-
bonus = m[3].to_i
42-
targets = m[4].split('/').map(&:to_i)
47+
48+
# 値の計算
49+
bonus = m[3] != '' ? Arithmetic.eval(m[3], RoundType::FLOOR) : 0
50+
return nil unless bonus
51+
52+
base_targets = m[4].split('/').map(&:to_i)
53+
target_bonus = m[5] != '' ? Arithmetic.eval(m[5], RoundType::FLOOR) : 0
54+
return nil unless target_bonus
55+
56+
targets = base_targets.map { |t| t + target_bonus }
4357
target = targets[0]
4458
min_target = targets.min
4559
max_target = targets.max
@@ -107,15 +121,8 @@ def roll_skills(command)
107121
end
108122

109123
# ボーナスがある場合の処理
110-
bonus_text = ''
111-
bonus_result = ''
112-
if bonus != 0
113-
if bonus > 0
114-
bonus_text = "+"
115-
end
116-
bonus_text += bonus.to_s
117-
bonus_result = "#{total} > "
118-
end
124+
bonus_text = m[3]
125+
bonus_result = m[3] == '' ? '' : "#{total} > "
119126

120127
# Resultクラスに結果を入れる
121128
Result.new.tap do |r|
@@ -126,6 +133,48 @@ def roll_skills(command)
126133
r.failure = !is_success
127134
end
128135
end
136+
137+
def roll_damage_check(command)
138+
parser = Command::Parser.new("DMG", round_type: BCDice::RoundType::FLOOR).restrict_cmp_op_to(:>=)
139+
parsed = parser.parse(command)
140+
return nil unless parsed
141+
142+
# 値の計算
143+
dif = parsed.target_number
144+
return nil unless dif
145+
146+
# ダイスロール
147+
dice_result = @randomizer.roll_once(100)
148+
149+
# Result用変数宣言
150+
is_success = false
151+
152+
# 結果判定
153+
if dice_result < (dif / 5)
154+
is_success = false
155+
second_result = @randomizer.roll_once(100)
156+
if second_result >= dif
157+
result_str = "失敗 > 弱点追加 > #{second_result} > 戦闘不能状態"
158+
else
159+
result_str = "失敗 > 弱点追加 > #{second_result} > 死亡状態"
160+
end
161+
elsif dice_result < (dif / 2)
162+
result_str = "失敗 > 弱点追加 > 戦闘不能状態"
163+
is_success = false
164+
elsif dice_result < dif
165+
result_str = "失敗 > 戦闘不能状態"
166+
is_success = false
167+
else
168+
result_str = "成功"
169+
is_success = true
170+
end
171+
172+
Result.new.tap do |r|
173+
r.text = "(#{command}) > #{dice_result}#{result_str}"
174+
r.success = is_success
175+
r.failure = !is_success
176+
end
177+
end
129178
end
130179
end
131180
end

test/data/Aionia.toml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,26 @@ rands = [
605605
{ sides = 10, value = 1 },
606606
]
607607

608+
609+
##### 複数ボーナス・ペナルティのテスト #####
610+
[[ test ]]
611+
game_system = "Aionia"
612+
input = "AB1+1+2>=6 ダイスへの複数ボーナス クリファンなし"
613+
output = "(AB1+1+2>=6) > 5[5]+1+2 > 8 > 成功"
614+
success = true
615+
rands = [
616+
{ sides = 10, value = 5 },
617+
]
618+
619+
[[ test ]]
620+
game_system = "Aionia"
621+
input = "AB1>=6+1+2 難易度への複数ボーナス クリファンなし"
622+
output = "(AB1>=6+1+2) > 8[8] > 失敗"
623+
failure = true
624+
rands = [
625+
{ sides = 10, value = 8 },
626+
]
627+
608628
##### 段階的な技能判定のテスト(クリファンあり)#####
609629
[[ test ]]
610630
game_system = "Aionia"
@@ -741,6 +761,63 @@ rands = [
741761
{ sides = 10, value = 9 },
742762
]
743763

764+
##### 段階的な技能判定のボーナス・ペナルティのテスト#####
765+
[[ test ]]
766+
game_system = "Aionia"
767+
input = "AB3>=14/18/22+10-2 段階的な難易度への複数ボーナス 失敗 クリファンなし"
768+
output = "(AB3>=14/18/22+10-2) > 11[3,4,4] > 失敗"
769+
failure = true
770+
rands = [
771+
{ sides = 10, value = 3 },
772+
{ sides = 10, value = 4 },
773+
{ sides = 10, value = 4 },
774+
]
775+
776+
[[ test ]]
777+
game_system = "Aionia"
778+
input = "AB3>=14/18/22+10-2 段階的な難易度への複数ボーナス 1段階成功 クリファンなし"
779+
output = "(AB3>=14/18/22+10-2) > 23[3,10,10] > 1段階成功"
780+
success = true
781+
rands = [
782+
{ sides = 10, value = 3 },
783+
{ sides = 10, value = 10 },
784+
{ sides = 10, value = 10 },
785+
]
786+
787+
[[ test ]]
788+
game_system = "Aionia"
789+
input = "AB3>=4/8/12+10-2 段階的な難易度への複数ボーナス 全成功 クリファンなし"
790+
output = "(AB3>=4/8/12+10-2) > 23[3,10,10] > 全成功"
791+
success = true
792+
rands = [
793+
{ sides = 10, value = 3 },
794+
{ sides = 10, value = 10 },
795+
{ sides = 10, value = 10 },
796+
]
797+
798+
[[ test ]]
799+
game_system = "Aionia"
800+
input = "ABT3+1-2>=14/18/22+10-2 段階的な難易度への複数ボーナス 両方にボーナス 1段階成功 クリファンあり"
801+
output = "(ABT3+1-2>=14/18/22+10-2) > 23[3,10,10]+1-2 > 22 > 1段階成功"
802+
success = true
803+
rands = [
804+
{ sides = 10, value = 3 },
805+
{ sides = 10, value = 10 },
806+
{ sides = 10, value = 10 },
807+
]
808+
809+
[[ test ]]
810+
game_system = "Aionia"
811+
input = "ABT3+1-2>=14/18/22+10-2 段階的な難易度への複数ボーナス 両方にボーナス 2段階成功 クリファンあり"
812+
output = "(ABT3+1-2>=14/18/22+10-2) > 27[7,10,10]+1-2 > 26 > 2段階成功"
813+
success = true
814+
rands = [
815+
{ sides = 10, value = 7 },
816+
{ sides = 10, value = 10 },
817+
{ sides = 10, value = 10 },
818+
]
819+
820+
744821
##### クリティカル>自動成功、ファンブル>自動失敗の優先度テスト #####
745822
[[ test ]]
746823
game_system = "Aionia"
@@ -789,3 +866,79 @@ rands = [
789866
{ sides = 10, value = 1 },
790867
{ sides = 10, value = 1 },
791868
]
869+
870+
##### DMGコマンドのテスト #####
871+
[[ test ]]
872+
game_system = "Aionia"
873+
input = "DMG>=50 DMGコマンドの成功"
874+
output = "(DMG>=50) > 50 > 成功"
875+
success = true
876+
rands = [
877+
{ sides = 100, value = 50 },
878+
]
879+
880+
[[ test ]]
881+
game_system = "Aionia"
882+
input = "DMG>=40+10 DMGコマンドの成功(計算式あり)"
883+
output = "(DMG>=40+10) > 90 > 成功"
884+
success = true
885+
rands = [
886+
{ sides = 100, value = 90 },
887+
]
888+
889+
[[ test ]]
890+
game_system = "Aionia"
891+
input = "DMG>=50 DMGコマンドの失敗 > 戦闘不能状態"
892+
output = "(DMG>=50) > 49 > 失敗 > 戦闘不能状態"
893+
failure = true
894+
rands = [
895+
{ sides = 100, value = 49 },
896+
]
897+
898+
[[ test ]]
899+
game_system = "Aionia"
900+
input = "DMG>=50 DMGコマンドの失敗 > 弱点追加 > 戦闘不能状態"
901+
output = "(DMG>=50) > 24 > 失敗 > 弱点追加 > 戦闘不能状態"
902+
failure = true
903+
rands = [
904+
{ sides = 100, value = 24 },
905+
]
906+
907+
[[ test ]]
908+
game_system = "Aionia"
909+
input = "DMG>=50 DMGコマンドの失敗 > 弱点追加 > 死亡状態"
910+
output = "(DMG>=50) > 9 > 失敗 > 弱点追加 > 49 > 死亡状態"
911+
failure = true
912+
rands = [
913+
{ sides = 100, value = 9 },
914+
{ sides = 100, value = 49 },
915+
]
916+
917+
[[ test ]]
918+
game_system = "Aionia"
919+
input = "DMG>=50 DMGコマンドの失敗 > 弱点追加 > 戦闘不能状態(再判定成功)"
920+
output = "(DMG>=50) > 9 > 失敗 > 弱点追加 > 50 > 戦闘不能状態"
921+
failure = true
922+
rands = [
923+
{ sides = 100, value = 9 },
924+
{ sides = 100, value = 50 },
925+
]
926+
927+
[[ test ]]
928+
game_system = "Aionia"
929+
input = "DMG>=30*2-10 DMGコマンドの計算式による失敗検証"
930+
output = "(DMG>=30*2-10) > 24 > 失敗 > 弱点追加 > 戦闘不能状態"
931+
failure = true
932+
rands = [
933+
{ sides = 100, value = 24 },
934+
]
935+
936+
##### 特殊なケース #####
937+
[[ test ]]
938+
game_system = "Aionia"
939+
input = "DMG>10 比較演算子の不正"
940+
output = ""
941+
success = true
942+
rands = [
943+
{ sides = 100, value = 10 },
944+
]

0 commit comments

Comments
 (0)