-
Notifications
You must be signed in to change notification settings - Fork 9
/
patch.diff
1341 lines (1194 loc) · 50.9 KB
/
patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/lib/bcdice/arithmetic/node.rb b/lib/bcdice/arithmetic/node.rb
--- a/lib/bcdice/arithmetic/node.rb
+++ b/lib/bcdice/arithmetic/node.rb
@@ -48,6 +48,8 @@ module BCDice
def eval(round_type)
l = @lhs.eval(round_type)
r = @rhs.eval(round_type)
+
+ raise ZeroDivisionError if r == 0
divide_and_round(l, r, round_type)
end
@@ -101,9 +103,10 @@ module BCDice
when RoundType::CEIL
(dividend.to_f / divisor).ceil
when RoundType::ROUND
- (dividend.to_f / divisor).round
+ x = dividend.to_f / divisor
+ x.negative? ? -(x.abs.round) : x.round
else # RoundType::FLOOR
- dividend / divisor
+ (dividend / divisor).floor
end
end
end
@@ -138,7 +141,8 @@ module BCDice
# @param [Symbol] _round_type ゲームシステムの端数処理設定
# @return [Integer]
def divide_and_round(dividend, divisor, _round_type)
- (dividend.to_f / divisor).round
+ x = dividend.to_f / divisor
+ x.negative? ? -(x.abs.round) : x.round
end
end
@@ -155,7 +159,7 @@ module BCDice
# @param [Symbol] _round_type ゲームシステムの端数処理設定
# @return [Integer]
def divide_and_round(dividend, divisor, _round_type)
- dividend / divisor
+ (dividend / divisor).floor
end
end
diff --git a/lib/bcdice/base.rb b/lib/bcdice/base.rb
--- a/lib/bcdice/base.rb
+++ b/lib/bcdice/base.rb
@@ -20,8 +20,7 @@ module BCDice
# 応答するコマンドのprefixを登録する
# @param prefixes [Array<String>]
def register_prefix(*prefixes)
- @prefixes ||= []
- @prefixes.concat(prefixes.flatten)
+ @prefixes = (@prefixes || []) + prefixes.flatten
end
def register_prefix_from_super_class
@@ -328,7 +327,7 @@ module BCDice
num = @randomizer.roll_sum(count, 6)
debug("num", num)
- index = ((num - 1) / 2)
+ index = ((num - 1) / 2).to_i
debug("index", index)
text = table[index]
diff --git a/lib/bcdice/common_command/add_dice/node.rb b/lib/bcdice/common_command/add_dice/node.rb
--- a/lib/bcdice/common_command/add_dice/node.rb
+++ b/lib/bcdice/common_command/add_dice/node.rb
@@ -140,7 +140,7 @@ module BCDice
lhs = @lhs.eval(game_system, randomizer)
rhs = @rhs.eval(game_system, randomizer)
- return calc(lhs, rhs, game_system.round_type)
+ return calc(lhs, rhs, game_system.round_type).to_i
end
# @return [Boolean]
@@ -177,7 +177,7 @@ module BCDice
# @param _round_type [Symbol] ゲームシステムの端数処理設定
# @return [Integer] 演算の結果
def calc(lhs, rhs, _round_type)
- lhs.send(@op, rhs)
+ lhs.send(@op, rhs).to_i
end
# S式で使う演算子の表現を返す
@@ -242,7 +242,7 @@ module BCDice
return 1
end
- return divide_and_round(lhs, rhs, round_type)
+ return divide_and_round(lhs, rhs, round_type).to_i
end
# 除算および端数処理を行う
@@ -271,9 +271,10 @@ module BCDice
when RoundType::CEIL
(dividend.to_f / divisor).ceil
when RoundType::ROUND
- (dividend.to_f / divisor).round
+ x = dividend.to_f / divisor
+ x.negative? ? -(x.abs.round) : x.round
else # RoundType::FLOOR
- dividend / divisor
+ (dividend / divisor).floor
end
end
end
@@ -304,7 +305,8 @@ module BCDice
# @param (see DivideWithGameSystemDefault#divide_and_round)
# @return [Integer]
def divide_and_round(dividend, divisor, _round_type)
- (dividend.to_f / divisor).round
+ x = dividend.to_f / divisor
+ x.negative? ? -(x.abs.round) : x.round
end
end
@@ -319,7 +321,7 @@ module BCDice
# @param (see DivideWithGameSystemDefault#divide_and_round)
# @return [Integer]
def divide_and_round(dividend, divisor, _round_type)
- dividend / divisor
+ (dividend / divisor).floor
end
end
@@ -342,7 +344,7 @@ module BCDice
# @param [Randomizer] randomizer ランダマイザ
# @return [Integer] 評価結果
def eval(game_system, randomizer)
- [email protected](game_system, randomizer)
+ [email protected](game_system, randomizer).to_i
end
# @return [Boolean]
@@ -398,7 +400,7 @@ module BCDice
total = dice_list.sum()
@text = "#{total}[#{dice_list.join(',')}]"
- return total
+ return total.to_i
end
# @return [Boolean]
@@ -529,7 +531,7 @@ module BCDice
@text = "#{total}[#{sorted_values.join(',')}]"
- return total
+ return total.to_i
end
# @return [Boolean]
@@ -590,7 +592,7 @@ module BCDice
# @param randomizer [Randomizer]
# @return [integer]
def eval(game_system, randomizer)
- @expr.eval(game_system, randomizer)
+ @expr.eval(game_system, randomizer).to_i
end
# @return [Boolean]
@@ -623,7 +625,7 @@ module BCDice
# ノードを初期化する
# @param [Integer] literal 値
def initialize(literal)
- @literal = literal
+ @literal = literal.to_i
end
# 符号を反転した結果の数値ノードを返す
@@ -635,7 +637,7 @@ module BCDice
# ノードを評価する
# @return [Integer] 格納している値
def eval(_game_system, _randomizer)
- @literal
+ @literal.to_i
end
# @return [Boolean]
diff --git a/lib/bcdice/common_command/calc/node.rb b/lib/bcdice/common_command/calc/node.rb
--- a/lib/bcdice/common_command/calc/node.rb
+++ b/lib/bcdice/common_command/calc/node.rb
@@ -15,7 +15,7 @@ module BCDice
def eval(round_type)
value =
begin
- @expr.eval(round_type)
+ @expr.eval(round_type).to_i
rescue ZeroDivisionError
"ゼロ除算が発生したため計算できませんでした"
end
diff --git a/lib/bcdice/common_command/repeat.rb b/lib/bcdice/common_command/repeat.rb
--- a/lib/bcdice/common_command/repeat.rb
+++ b/lib/bcdice/common_command/repeat.rb
@@ -68,7 +68,7 @@ module BCDice
cmd.eval()
end
- if results.count(nil) == @times
+ if results.count { |i| i == nil } == @times
return result_with_text("繰り返し対象のコマンドが実行できませんでした (#{@trailer})")
end
diff --git a/lib/bcdice/dice_table/d66_table.rb b/lib/bcdice/dice_table/d66_table.rb
--- a/lib/bcdice/dice_table/d66_table.rb
+++ b/lib/bcdice/dice_table/d66_table.rb
@@ -37,7 +37,7 @@ module BCDice
end
key = dice[0] * 10 + dice[1]
- chosen = @items[key]
+ chosen = @items[key] || @items[key.to_s]
chosen = chosen.roll(randomizer) if chosen.respond_to?(:roll)
RollResult.new(@name, key, chosen)
end
diff --git a/lib/bcdice/game_system/Amadeus.rb b/lib/bcdice/game_system/Amadeus.rb
--- a/lib/bcdice/game_system/Amadeus.rb
+++ b/lib/bcdice/game_system/Amadeus.rb
@@ -101,7 +101,7 @@ module BCDice
end
if available_inga
- inga = inga_table[dice - 1]
+ inga = inga_table[(dice - 1)]
"#{total}_#{result}[#{dice}#{inga}]"
else
"#{total}_#{result}[#{dice}]"
diff --git a/lib/bcdice/game_system/Arianrhod_Korean.rb b/lib/bcdice/game_system/Arianrhod_Korean.rb
--- a/lib/bcdice/game_system/Arianrhod_Korean.rb
+++ b/lib/bcdice/game_system/Arianrhod_Korean.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require "bcdice/game_system/Arianrhod"
+
module BCDice
module GameSystem
class Arianrhod_Korean < Arianrhod
diff --git a/lib/bcdice/game_system/AssaultEngine.rb b/lib/bcdice/game_system/AssaultEngine.rb
--- a/lib/bcdice/game_system/AssaultEngine.rb
+++ b/lib/bcdice/game_system/AssaultEngine.rb
@@ -40,7 +40,7 @@ module BCDice
if cmd.command.include?("AES") # SWAP初回
total = @randomizer.roll_once(100) % 100 # 0-99
- swap = (total % 10) * 10 + (total / 10)
+ swap = (total % 10) * 10 + (total / 10).floor
r1 = judge(target, total)
r2 = judge(target, swap)
text = "(AES#{format00(target)}) > #{r1.text} / スワップ#{r2.text}"
@@ -53,7 +53,7 @@ module BCDice
else # リロール
now = cmd.prefix_number
die = @randomizer.roll_once(10) % 10 # 0-9
- new1 = judge(target, (now / 10 * 10) + die) # 1の位を振り直す
+ new1 = judge(target, ((now / 10).floor * 10) + die) # 1の位を振り直す
new2 = judge(target, now % 10 + die * 10) # 10の位を振り直す
text = "(#{format00(now)}AE#{format00(target)}) > #{die} > #{new1.text} / #{new2.text}"
@@ -78,7 +78,7 @@ module BCDice
end
def judge(target, total)
- double = (total / 10) == (total % 10)
+ double = (total / 10).floor == (total % 10)
total_text = format00(total)
if total <= target
double ? Result.critical("(#{total_text})クリティカル") : Result.success("(#{total_text})成功")
diff --git a/lib/bcdice/game_system/ChaosFlare.rb b/lib/bcdice/game_system/ChaosFlare.rb
--- a/lib/bcdice/game_system/ChaosFlare.rb
+++ b/lib/bcdice/game_system/ChaosFlare.rb
@@ -93,7 +93,7 @@ module BCDice
return "因果表(#{num}) > #{FATE_TABLE[num][0]}"
end
- dice1 = num / 10
+ dice1 = (num / 10).to_i
dice2 = num % 10
if !(1..6).include?(dice1) || !(1..6).include?(dice2)
return nil
@@ -104,7 +104,7 @@ module BCDice
end
index1 = dice1
- index2 = (dice2 / 2) - 1
+ index2 = (dice2 / 2).to_i - 1
return "因果表(#{dice1}#{dice2}) > #{FATE_TABLE[index1][index2]}"
end
diff --git a/lib/bcdice/game_system/Chill.rb b/lib/bcdice/game_system/Chill.rb
--- a/lib/bcdice/game_system/Chill.rb
+++ b/lib/bcdice/game_system/Chill.rb
@@ -34,9 +34,9 @@ module BCDice
Result.failure("失敗")
elsif total >= (target * 0.9)
Result.success("L成功")
- elsif total >= (target / 2)
+ elsif total >= (target / 2).to_i
Result.success("M成功")
- elsif total >= (target / 10)
+ elsif total >= (target / 10).to_i
Result.success("H成功")
else
Result.critical("C成功")
diff --git a/lib/bcdice/game_system/Chill3.rb b/lib/bcdice/game_system/Chill3.rb
--- a/lib/bcdice/game_system/Chill3.rb
+++ b/lib/bcdice/game_system/Chill3.rb
@@ -24,7 +24,7 @@ module BCDice
return nil unless cmp_op == :<=
# ゾロ目ならC-ResultかBotch
- tens = (dice_total / 10) % 10
+ tens = (dice_total / 10).to_i % 10
ones = dice_total % 10
if tens == ones
@@ -38,7 +38,7 @@ module BCDice
return Result.critical("Colossal Success")
end
elsif (total <= target) || (dice_total == 1) # 01は必ず成功
- if total <= (target / 2)
+ if total <= (target / 2).to_i
return Result.success("High Success")
else
return Result.success("Low Success")
diff --git a/lib/bcdice/game_system/ColossalHunter.rb b/lib/bcdice/game_system/ColossalHunter.rb
--- a/lib/bcdice/game_system/ColossalHunter.rb
+++ b/lib/bcdice/game_system/ColossalHunter.rb
@@ -72,24 +72,23 @@ module BCDice
# 出力文の生成
text = "(#{parsed}) > #{dice}[#{dice_str}]#{Format.modifier(modify)} > #{total}"
- result = get_judge_result(dice, total, parsed)
+ result = get_judge_result(dice, total, parsed, text)
- result.text = text + result.text
return result
end
# 成否判定
- def get_judge_result(dice, total, parsed)
+ def get_judge_result(dice, total, parsed, text)
if dice <= 5
- Result.fumble(" > ファンブル")
+ Result.fumble(text + " > ファンブル")
elsif total >= 16
- Result.critical(" > クリティカル")
+ Result.critical(text + " > クリティカル")
elsif parsed.cmp_op.nil?
- Result.new("")
+ Result.new(text)
elsif total >= parsed.target_number
- Result.success(" > 成功")
+ Result.success(text + " > 成功")
else
- Result.failure(" > 失敗")
+ Result.failure(text + " > 失敗")
end
end
diff --git a/lib/bcdice/game_system/Cthulhu.rb b/lib/bcdice/game_system/Cthulhu.rb
--- a/lib/bcdice/game_system/Cthulhu.rb
+++ b/lib/bcdice/game_system/Cthulhu.rb
@@ -170,7 +170,7 @@ module BCDice
def compare(total, target, broken_number = 0)
result = CompareResult.new(@locale)
- target_special = (target * @special_percentage / 100).clamp(1, 100)
+ target_special = (target * @special_percentage / 100).to_i.clamp(1, 100)
if (total <= target) && (total < 100)
result.success = true
diff --git a/lib/bcdice/game_system/Cthulhu7th.rb b/lib/bcdice/game_system/Cthulhu7th.rb
--- a/lib/bcdice/game_system/Cthulhu7th.rb
+++ b/lib/bcdice/game_system/Cthulhu7th.rb
@@ -121,9 +121,9 @@ module BCDice
ResultLevel.new(:critical)
elsif total >= fumble
ResultLevel.new(:fumble)
- elsif total <= (difficulty / 5)
+ elsif total <= (difficulty / 5).to_i
ResultLevel.new(:extreme_success)
- elsif total <= (difficulty / 2)
+ elsif total <= (difficulty / 2).to_i
ResultLevel.new(:hard_success)
elsif total <= difficulty
ResultLevel.new(:regular_success)
@@ -194,9 +194,9 @@ module BCDice
if difficulty == 0
difficulty = nil
elsif difficulty_level == "H"
- difficulty /= 2
+ difficulty = (difficulty / 2).to_i
elsif difficulty_level == "E"
- difficulty /= 5
+ difficulty = (difficulty / 5).to_i
elsif difficulty_level == "C"
difficulty = 0
end
diff --git a/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb b/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
--- a/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
+++ b/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb
@@ -113,8 +113,8 @@ module BCDice
def getCheckResultText(total, diff, fumbleable = false)
if total <= diff
return "決定性的成功" if total == 1
- return "極限的成功" if total <= (diff / 5)
- return "困難的成功" if total <= (diff / 2)
+ return "極限的成功" if total <= (diff / 5).to_i
+ return "困難的成功" if total <= (diff / 2).to_i
return "通常成功"
end
@@ -344,7 +344,7 @@ module BCDice
end
def getSetOfBullet(diff)
- bullet_set_count = diff / 10
+ bullet_set_count = (diff / 10).to_i
if (diff >= 1) && (diff < 10)
bullet_set_count = 1 # 技能值9以下的最低限度保障處理
@@ -354,7 +354,7 @@ module BCDice
end
def getHitBulletCountBase(diff, bullet_set_count)
- hit_bullet_count_base = (bullet_set_count / 2)
+ hit_bullet_count_base = (bullet_set_count / 2).to_i
if (diff >= 1) && (diff < 10)
hit_bullet_count_base = 1 # 技能值9以下的最低限度保障處理
diff --git a/lib/bcdice/game_system/Cthulhu7th_Korean.rb b/lib/bcdice/game_system/Cthulhu7th_Korean.rb
--- a/lib/bcdice/game_system/Cthulhu7th_Korean.rb
+++ b/lib/bcdice/game_system/Cthulhu7th_Korean.rb
@@ -110,8 +110,8 @@ module BCDice
def getCheckResultText(total, diff, fumbleable = false)
if total <= diff
return "대성공" if total == 1
- return "대단한 성공" if total <= (diff / 5)
- return "어려운 성공" if total <= (diff / 2)
+ return "대단한 성공" if total <= (diff / 5).to_i
+ return "어려운 성공" if total <= (diff / 2).to_i
return "보통 성공"
end
@@ -302,7 +302,7 @@ module BCDice
lost_bullet_count = bullet_count
end
- return hit_bullet_count, impale_bullet_count, lost_bullet_count
+ return hit_bullet_count.to_i, impale_bullet_count.to_i, lost_bullet_count.to_i
end
def getSuccessListImpaleBulletList(more_difficlty)
@@ -341,7 +341,7 @@ module BCDice
end
def getSetOfBullet(diff)
- bullet_set_count = diff / 10
+ bullet_set_count = (diff / 10).to_i
if (diff >= 1) && (diff < 10)
bullet_set_count = 1 # 기능 수치가 9 이하일 때의 최저수치 보장 처리
@@ -351,7 +351,7 @@ module BCDice
end
def getHitBulletCountBase(diff, bullet_set_count)
- hit_bullet_count_base = (bullet_set_count / 2)
+ hit_bullet_count_base = (bullet_set_count / 2).to_i
if (diff >= 1) && (diff < 10)
hit_bullet_count_base = 1 # 기능 수치가 9 이하일 때의 최저수치 보장
diff --git a/lib/bcdice/game_system/CthulhuTech.rb b/lib/bcdice/game_system/CthulhuTech.rb
--- a/lib/bcdice/game_system/CthulhuTech.rb
+++ b/lib/bcdice/game_system/CthulhuTech.rb
@@ -53,7 +53,7 @@ module BCDice
dice_values = randomizer.roll_barabara(@num, 10)
# ファンブル:出目の半分(小数点以下切り上げ)以上が1の場合
- fumble = dice_values.count(1) >= (dice_values.length + 1) / 2
+ fumble = dice_values.count(1) >= ((dice_values.length + 1) / 2).to_i
sorted_dice_values = dice_values.sort
roll_result = calculate_roll_result(sorted_dice_values)
diff --git a/lib/bcdice/game_system/DemonSpike.rb b/lib/bcdice/game_system/DemonSpike.rb
--- a/lib/bcdice/game_system/DemonSpike.rb
+++ b/lib/bcdice/game_system/DemonSpike.rb
@@ -51,7 +51,7 @@ module BCDice
is_fumble = step_list[0][:dice_sum] == 2
total = is_fumble ? 0 : step_list.sum { |s| s[:dice_sum] } + parsed.modify_number
- success_level = total / 10
+ success_level = (total / 10).floor
is_success = total >= 10
res =
diff --git a/lib/bcdice/game_system/Dracurouge.rb b/lib/bcdice/game_system/Dracurouge.rb
--- a/lib/bcdice/game_system/Dracurouge.rb
+++ b/lib/bcdice/game_system/Dracurouge.rb
@@ -89,7 +89,7 @@ module BCDice
one_count = dice_list.count(1)
six_count = dice_list.count(6)
- return (one_count / 2) + (six_count / 2)
+ return (one_count / 2).to_i + (six_count / 2).to_i
end
def apply_thirsty_point(dice_list, thirsty_point)
@@ -273,7 +273,7 @@ module BCDice
list = Array.new(times) do
randomizer.roll_barabara(sides.length, 6)
.reverse # テスト系の互換性のために反転する
- .map.with_index { |x, idx| x * (10**idx) }
+ .map.with_index { |x, idx| x * (10**idx).to_i }
.sum()
end
diff --git a/lib/bcdice/game_system/EarthDawn3.rb b/lib/bcdice/game_system/EarthDawn3.rb
--- a/lib/bcdice/game_system/EarthDawn3.rb
+++ b/lib/bcdice/game_system/EarthDawn3.rb
@@ -147,7 +147,7 @@ module BCDice
result = [0, 0, 0, 0, 0, 0, 0]
- loopCount = (overStep / stepRythm.size)
+ loopCount = (overStep / stepRythm.size).to_i
loopCount.times do
addStepToResult(result, baseStepInfo)
diff --git a/lib/bcdice/game_system/EarthDawn4.rb b/lib/bcdice/game_system/EarthDawn4.rb
--- a/lib/bcdice/game_system/EarthDawn4.rb
+++ b/lib/bcdice/game_system/EarthDawn4.rb
@@ -193,7 +193,7 @@ module BCDice
result = [0, 0, 0, 0, 0, 0, 0]
- loopCount = (overStep / stepRythm.size)
+ loopCount = (overStep / stepRythm.size).to_i
loopCount.times do
addStepToResult(result, overBounusStep)
@@ -225,7 +225,7 @@ module BCDice
return "失敗"
end
- level = (diff / 5) + 1
+ level = (diff / 5).to_i + 1
return "成功 レベル:#{level}"
end
diff --git a/lib/bcdice/game_system/EclipsePhase.rb b/lib/bcdice/game_system/EclipsePhase.rb
--- a/lib/bcdice/game_system/EclipsePhase.rb
+++ b/lib/bcdice/game_system/EclipsePhase.rb
@@ -21,7 +21,7 @@ module BCDice
return nil unless cmp_op == :<=
dice_value = total % 100 # 出目00は100ではなく00とする
- dice_ten_place = dice_value / 10
+ dice_ten_place = (dice_value / 10).to_i
dice_one_place = dice_value % 10
if dice_ten_place == dice_one_place
diff --git a/lib/bcdice/game_system/Emoklore.rb b/lib/bcdice/game_system/Emoklore.rb
--- a/lib/bcdice/game_system/Emoklore.rb
+++ b/lib/bcdice/game_system/Emoklore.rb
@@ -65,7 +65,7 @@ module BCDice
success_value = critical + success - fumble
result = compare_result(success_value)
- result.text = "#{values} > #{success_value} > #{translate('Emoklore.success_count', count: success_value)} #{result.text}"
+ result.text = "[#{values.join(', ')}] > #{success_value} > #{translate('Emoklore.success_count', count: success_value)} #{result.text}"
return result
end
diff --git a/lib/bcdice/game_system/GardenOrder.rb b/lib/bcdice/game_system/GardenOrder.rb
--- a/lib/bcdice/game_system/GardenOrder.rb
+++ b/lib/bcdice/game_system/GardenOrder.rb
@@ -52,12 +52,12 @@ module BCDice
def get_critical_border(critical_border_text, success_rate)
return critical_border_text.to_i unless critical_border_text.nil?
- critical_border = [success_rate / 5, 1].max
+ critical_border = [success_rate / 5, 1].max.to_i
return critical_border
end
def check_roll_repeat_attack(success_rate, repeat_count, critical_border)
- success_rate_per_one = success_rate / repeat_count
+ success_rate_per_one = (success_rate / repeat_count).to_i
# 連続攻撃は最終的な成功率が50%以上であることが必要 cf. p217
if repeat_count > 1 && success_rate_per_one < 50
return "D100<=#{success_rate_per_one}@#{critical_border} > 連続攻撃は成功率が50%以上必要です"
diff --git a/lib/bcdice/game_system/Gundog.rb b/lib/bcdice/game_system/Gundog.rb
--- a/lib/bcdice/game_system/Gundog.rb
+++ b/lib/bcdice/game_system/Gundog.rb
@@ -34,7 +34,7 @@ module BCDice
elsif target == "?"
Result.nothing
elsif total <= target
- dig10 = total / 10
+ dig10 = (total / 10).to_i
dig1 = total - dig10 * 10
dig10 = 0 if dig10 >= 10
dig1 = 0 if dig1 >= 10 # 条件的にはあり得ない(笑
diff --git a/lib/bcdice/game_system/GundogRevised.rb b/lib/bcdice/game_system/GundogRevised.rb
--- a/lib/bcdice/game_system/GundogRevised.rb
+++ b/lib/bcdice/game_system/GundogRevised.rb
@@ -45,7 +45,7 @@ module BCDice
elsif target == "?"
Result.nothing
elsif total <= target
- dig10 = total / 10
+ dig10 = (total / 10).to_i
dig1 = total - dig10 * 10
dig10 = 0 if dig10 >= 10
dig1 = 0 if dig1 >= 10 # 条件的にはあり得ない(笑
diff --git a/lib/bcdice/game_system/GurpsFW.rb b/lib/bcdice/game_system/GurpsFW.rb
--- a/lib/bcdice/game_system/GurpsFW.rb
+++ b/lib/bcdice/game_system/GurpsFW.rb
@@ -321,7 +321,7 @@ module BCDice
tableName = "財宝テーブル"
diff = Regexp.last_match(1)
depth = Regexp.last_match(2).to_i
- num = depth / 10
+ num = (depth / 10).to_i
if num >= 6
num = 5
end
diff --git a/lib/bcdice/game_system/HeroScale.rb b/lib/bcdice/game_system/HeroScale.rb
--- a/lib/bcdice/game_system/HeroScale.rb
+++ b/lib/bcdice/game_system/HeroScale.rb
@@ -159,11 +159,13 @@ module BCDice
def fate_body(natural_result)
modified_result = natural_result.dup
- modified_result.each do |result|
- if result == 4
- modified_result << @randomizer.roll_once(4)
- end
+ additional = natural_result.count(4)
+ while additional > 0
+ value = @randomizer.roll_once(4)
+ modified_result.push(value)
+ additional -= 1 if value != 4
end
+
subtotal = results_multiplication(natural_result)
total = results_multiplication(modified_result)
message = "肉体の超越 > #{subtotal}[#{natural_result.join(',')}] > #{total}[#{modified_result.join(',')}]"
@@ -297,7 +299,7 @@ module BCDice
def fate_acceptance(natural_result, order)
subtotal = results_multiplication(natural_result)
if order.length > 3 && order[2] =~ /^\d+$/ && order[3] =~ /^\d+$/
- change_result = natural_result.min(2)
+ change_result = natural_result.sort().take(2)
modified_result = natural_result.dup
modified_result[modified_result.index(change_result[0])] = order[2].to_i
modified_result[modified_result.index(change_result[1])] = order[3].to_i
@@ -460,7 +462,7 @@ module BCDice
subtotal = results_multiplication(natural_result)
modified_result = natural_result.dup
depravity_num1 = natural_result[0] % 10
- depravity_num10 = natural_result[0] / 10
+ depravity_num10 = (natural_result[0] / 10).to_i
if depravity_num10 > 1
modified_result << depravity_num10
end
@@ -476,7 +478,7 @@ module BCDice
modified_result = natural_result.dup
modified_result << @randomizer.roll_once(60)
subtotal = results_multiplication(natural_result)
- total = results_multiplication(modified_result) / 2
+ total = (results_multiplication(modified_result) / 2).to_i
message = "忘却の報い > #{subtotal}[#{natural_result.join(',')}] > #{total}[#{modified_result.join(',')}]"
return message
end
@@ -827,9 +829,9 @@ module BCDice
def result_raoundup(result)
if result.even?
- return result / 2
+ return (result / 2).to_i
else
- return result / 2 + 1
+ return (result / 2).to_i + 1
end
end
end
diff --git a/lib/bcdice/game_system/Hieizan.rb b/lib/bcdice/game_system/Hieizan.rb
--- a/lib/bcdice/game_system/Hieizan.rb
+++ b/lib/bcdice/game_system/Hieizan.rb
@@ -24,7 +24,7 @@ module BCDice
Result.fumble("大失敗")
elsif total >= 96
Result.failure("自動失敗")
- elsif total <= (target / 5)
+ elsif total <= (target / 5).to_i
Result.critical("大成功")
elsif total <= 1
Result.success("自動成功")
diff --git a/lib/bcdice/game_system/HunterTheReckoning5th.rb b/lib/bcdice/game_system/HunterTheReckoning5th.rb
--- a/lib/bcdice/game_system/HunterTheReckoning5th.rb
+++ b/lib/bcdice/game_system/HunterTheReckoning5th.rb
@@ -141,7 +141,7 @@ module BCDice
def get_critical_success(ten_dice)
# 10の目が2個毎に追加2成功
- return ((ten_dice / 2) * 2)
+ return ((ten_dice / 2).to_i * 2)
end
def make_dice_roll(dice_pool)
diff --git a/lib/bcdice/game_system/InfiniteFantasia.rb b/lib/bcdice/game_system/InfiniteFantasia.rb
--- a/lib/bcdice/game_system/InfiniteFantasia.rb
+++ b/lib/bcdice/game_system/InfiniteFantasia.rb
@@ -28,15 +28,15 @@ module BCDice
end
output =
- if total <= (target / 32)
+ if total <= (target / 32).to_i
"32レベル成功(32Lv+)"
- elsif total <= (target / 16)
+ elsif total <= (target / 16).to_i
"16レベル成功(16Lv+)"
- elsif total <= (target / 8)
+ elsif total <= (target / 8).to_i
"8レベル成功"
- elsif total <= (target / 4)
+ elsif total <= (target / 4).to_i
"4レベル成功"
- elsif total <= (target / 2)
+ elsif total <= (target / 2).to_i
"2レベル成功"
else
"1レベル成功"
diff --git a/lib/bcdice/game_system/KemonoNoMori.rb b/lib/bcdice/game_system/KemonoNoMori.rb
--- a/lib/bcdice/game_system/KemonoNoMori.rb
+++ b/lib/bcdice/game_system/KemonoNoMori.rb
@@ -71,7 +71,7 @@ module BCDice
# 行為判定の成功度は [目標値の10の位の数+1]
# 継続判定の成功度は固定で+1
- success_degree = is_action_judge ? target_total / 10 + 1 : 1
+ success_degree = is_action_judge ? (target_total / 10).to_i + 1 : 1
dice_total = @randomizer.roll_once(12)
debug('dice_total, target_total, success_degree = ', dice_total, target_total, success_degree)
diff --git a/lib/bcdice/game_system/LogHorizon.rb b/lib/bcdice/game_system/LogHorizon.rb
--- a/lib/bcdice/game_system/LogHorizon.rb
+++ b/lib/bcdice/game_system/LogHorizon.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require "bcdice/base"
+require "bcdice/arithmetic_evaluator"
module BCDice
module GameSystem
@@ -361,13 +362,13 @@ module BCDice
if index <= 6
translate("LogHorizon.TRS.below_lower_limit", value: 6) # 6以下の出目は未定義です
elsif index <= 62
- @items[index]
+ @items[index.to_s]
elsif index <= 72
- "#{@items[index - 10]}&80G"
+ "#{@items[(index - 10).to_s]}&80G"
elsif index <= 82
- "#{@items[index - 20]}&160G"
+ "#{@items[(index - 20).to_s]}&160G"
elsif index <= 87
- "#{@items[index - 30]}&260G"
+ "#{@items[(index - 30).to_s]}&260G"
else
translate("LogHorizon.TRS.exceed_upper_limit", value: 88) # 88以上の出目は未定義です
end
@@ -382,7 +383,7 @@ module BCDice
if index <= 6
translate("LogHorizon.TRS.below_lower_limit", value: 6)
elsif index <= 53
- @items[index]
+ @items[index.to_s]
else
translate("LogHorizon.TRS.exceed_upper_limit", value: 54)
end
@@ -397,13 +398,13 @@ module BCDice
if index <= 6
translate("LogHorizon.TRS.below_lower_limit", value: 6)
elsif index <= 162
- @items[index]
+ @items[index.to_s]
elsif index <= 172
- "#{@items[index - 10]}&200G"
+ "#{@items[(index - 10).to_s]}&200G"
elsif index <= 182
- "#{@items[index - 20]}&400G"
+ "#{@items[(index - 20).to_s]}&400G"
elsif index <= 187
- "#{@items[index - 30]}&600G"
+ "#{@items[(index - 30).to_s]}&600G"
else
translate("LogHorizon.TRS.exceed_upper_limit", value: 188)
end
@@ -512,7 +513,7 @@ module BCDice
table_name = translate("LogHorizon.ESTL.name")
table = translate("LogHorizon.ESTL.items")
- chosen = table[total].chomp
+ chosen = table[total.to_s].chomp
return "#{table_name}(#{total}#{dice_str})\n#{chosen}"
end
diff --git a/lib/bcdice/game_system/NightmareHunterDeep.rb b/lib/bcdice/game_system/NightmareHunterDeep.rb
--- a/lib/bcdice/game_system/NightmareHunterDeep.rb
+++ b/lib/bcdice/game_system/NightmareHunterDeep.rb
@@ -81,8 +81,8 @@ module BCDice
return total >= target ? "成功" : "失敗"
end
- success_lv = (total + 1) / 5
- success_nl = (total - 5) / 5
+ success_lv = ((total + 1) / 5).to_i
+ success_nl = ((total - 5) / 5).to_i
return success_lv > 0 ? "Lv#{success_lv}/NL#{success_nl}成功" : "失敗"
end
diff --git a/lib/bcdice/game_system/NinjaSlayer.rb b/lib/bcdice/game_system/NinjaSlayer.rb
--- a/lib/bcdice/game_system/NinjaSlayer.rb
+++ b/lib/bcdice/game_system/NinjaSlayer.rb
@@ -50,18 +50,18 @@ module BCDice
end
# 難易度の値の正規表現
- DIFFICULTY_VALUE_RE = /UH|[2-6KENH]/i.freeze
+ DIFFICULTY_VALUE_RE = 'UH|[2-6KENH]'.freeze
# 難易度の正規表現
- DIFFICULTY_RE = /\[(#{DIFFICULTY_VALUE_RE})\]|@(#{DIFFICULTY_VALUE_RE})/io.freeze
+ DIFFICULTY_RE = "(\\[(#{DIFFICULTY_VALUE_RE})\\]|@(#{DIFFICULTY_VALUE_RE}))".freeze
# 通常判定の正規表現
- NJ_RE = /\A(S)?NJ(\d+)#{DIFFICULTY_RE}?\z/io.freeze
+ NJ_RE = /^(S)?NJ(\d+)#{DIFFICULTY_RE}?$/io.freeze
# 回避判定の正規表現
- EV_RE = %r{\AEV(\d+)#{DIFFICULTY_RE}?(?:/(\d+))?\z}io.freeze
+ EV_RE = /^EV(\d+)#{DIFFICULTY_RE}?(?:\/(\d+))?$/io.freeze
# 近接攻撃の正規表現
- AT_RE = /\AAT(\d+)#{DIFFICULTY_RE}?\z/io.freeze
+ AT_RE = /^AT(\d+)#{DIFFICULTY_RE}?$/io.freeze
# 電子戦の正規表現
- EL_RE = /\AEL(\d+)#{DIFFICULTY_RE}?\z/io.freeze
+ EL_RE = /^EL(\d+)#{DIFFICULTY_RE}?$/io.freeze
# 回避判定のノード
EV = Struct.new(:num, :difficulty, :targetValue)
@@ -83,7 +83,7 @@ module BCDice
m = NJ_RE.match(str)
return str unless m
- b_roll = bRollCommand(m[2], integerValueOfDifficulty(m[3] || m[4]))
+ b_roll = bRollCommand(m[2], integerValueOfDifficulty(m[4] || m[5]))
return "#{m[1]}#{b_roll}"
end
@@ -129,8 +129,8 @@ module BCDice
# @return [EV]
def parseEV(m)
num = m[1].to_i
- difficulty = integerValueOfDifficulty(m[2] || m[3])
- targetValue = m[4]&.to_i
+ difficulty = integerValueOfDifficulty(m[3] || m[4])
+ targetValue = m[5]&.to_i
return EV.new(num, difficulty, targetValue)
end
@@ -140,7 +140,7 @@ module BCDice
# @return [AT]
def parseAT(m)
num = m[1].to_i
- difficulty = integerValueOfDifficulty(m[2] || m[3])
+ difficulty = integerValueOfDifficulty(m[3] || m[4])
return AT.new(num, difficulty)
end
@@ -150,7 +150,7 @@ module BCDice
# @return [EL]
def parseEL(m)
num = m[1].to_i
- difficulty = integerValueOfDifficulty(m[2] || m[3])
+ difficulty = integerValueOfDifficulty(m[3] || m[4])
return EL.new(num, difficulty)
end
@@ -220,7 +220,7 @@ module BCDice
def integerValueOfDifficulty(s)
return 4 unless s
- return s.to_i if /\A[2-6]\z/.match(s)
+ return s.to_i if /^[2-6]$/.match(s)
return DIFFICULTY_SYMBOL_TO_INTEGER.fetch(s.upcase)
end
diff --git a/lib/bcdice/game_system/RuinBreakers.rb b/lib/bcdice/game_system/RuinBreakers.rb
--- a/lib/bcdice/game_system/RuinBreakers.rb
+++ b/lib/bcdice/game_system/RuinBreakers.rb
@@ -67,8 +67,8 @@ module BCDice
return nil
end
- success_rate = ArithmeticEvaluator.eval(m[1])
- critical_border = m[4]&.to_i || [success_rate / 5, 1].max
+ success_rate = ArithmeticEvaluator.eval(m[1]).to_i
+ critical_border = m[4]&.to_i || [(success_rate / 5).to_i, 1].max
fumble_border = m[6]&.to_i || (success_rate < 100 ? 96 : 99)
total = @randomizer.roll_once(100)
diff --git a/lib/bcdice/game_system/RuneQuestRoleplayingInGlorantha.rb b/lib/bcdice/game_system/RuneQuestRoleplayingInGlorantha.rb
--- a/lib/bcdice/game_system/RuneQuestRoleplayingInGlorantha.rb
+++ b/lib/bcdice/game_system/RuneQuestRoleplayingInGlorantha.rb
@@ -135,7 +135,7 @@ module BCDice
Result.success("#{result_prefix_str} 成功\n#{note_str}")
else
# 上記全てが当てはまらない時に突破可能な能力値を算出
- "#{result_prefix_str} 相手側能力値#{active_ability_value + (50 + modifiy_value - roll_value) / 5}まで成功\n#{note_str}"
+ "#{result_prefix_str} 相手側能力値#{active_ability_value + ((50 + modifiy_value - roll_value) / 5).floor}まで成功\n#{note_str}"
end
end
diff --git a/lib/bcdice/game_system/Ryutama.rb b/lib/bcdice/game_system/Ryutama.rb
--- a/lib/bcdice/game_system/Ryutama.rb
+++ b/lib/bcdice/game_system/Ryutama.rb
@@ -86,14 +86,14 @@ module BCDice
diceBase = dice1
- dice1 = diceBase / 10
+ dice1 = (diceBase / 10).to_i
dice2 = diceBase % 10
if isValidDice(dice1, dice2)
return dice1, dice2
end
- dice1 = diceBase / 100
+ dice1 = (diceBase / 100).to_i
dice2 = diceBase % 100
if isValidDice(dice1, dice2)
diff --git a/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb b/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb
--- a/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb
+++ b/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb
@@ -45,7 +45,7 @@ module BCDice
def split_tens(value)
value %= 100
- ones = value / 10
+ ones = (value / 10).to_i
tens = value % 10
return [ones, tens]
diff --git a/lib/bcdice/game_system/Siren.rb b/lib/bcdice/game_system/Siren.rb
--- a/lib/bcdice/game_system/Siren.rb
+++ b/lib/bcdice/game_system/Siren.rb
@@ -50,7 +50,7 @@ module BCDice
return Result.failure("(1D100<=#{target}) > #{dice} > 失敗")
end
- dig10 = dice / 10
+ dig10 = (dice / 10).floor
dig1 = dice % 10
if dig10 == 0
dig10 = 10
@@ -74,7 +74,7 @@ module BCDice
dice = @randomizer.roll_once(100)
- dig10 = dice / 10
+ dig10 = (dice / 10).floor
dig1 = dice % 10
if dig10 == 0
dig10 = 10
diff --git a/lib/bcdice/game_system/Skynauts.rb b/lib/bcdice/game_system/Skynauts.rb
--- a/lib/bcdice/game_system/Skynauts.rb
+++ b/lib/bcdice/game_system/Skynauts.rb
@@ -78,7 +78,7 @@ module BCDice
debug("移動修正", bonus)
total = @randomizer.roll_once(6)
- move_point_base = (total / 2) <= 0 ? 1 : (total / 2)
+ move_point_base = (total / 2).to_i <= 0 ? 1 : (total / 2).to_i
movePoint = move_point_base + bonus
debug("移動エリア数", movePoint)
diff --git a/lib/bcdice/game_system/TensaiGunshiNiNaro.rb b/lib/bcdice/game_system/TensaiGunshiNiNaro.rb
--- a/lib/bcdice/game_system/TensaiGunshiNiNaro.rb
+++ b/lib/bcdice/game_system/TensaiGunshiNiNaro.rb
@@ -182,7 +182,7 @@ module BCDice