bcdice 3.15.0 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bcdice/base'
4
+
5
+ module BCDice
6
+ module GameSystem
7
+ class Ventangle_Korean < Ventangle
8
+ # ゲームシステムの識別子
9
+ ID = 'Ventangle:Korean'
10
+
11
+ # ゲームシステム名
12
+ NAME = '벤탱글'
13
+
14
+ # ゲームシステム名の読みがな
15
+ SORT_KEY = '国際化:Korean:벤탱글'
16
+
17
+ # ダイスボットの使い方
18
+ HELP_MESSAGE = <<~MESSAGETEXT
19
+ 기본 양식 VTn@s#f$g>=T n=주사위 개수(생략 시 2) s=스페셜치(생략 시 12) f=펌블치(생략 시 2) g=레벨 갭 판정치(생략 가능) T=목표치(생략 가능)
20
+
21
+ 예시:
22
+ VT 기본 스페셜치, 펌블치로 판정
23
+ VT@10#3 스페셜치 10、펌블치 3으로 판정
24
+ VT3@10#3 어드밴티지 1점을 사용해 스페셜치 10, 펌블치 3 판정을 주사위 3개로 판정
25
+
26
+ VT>=5 기본 스페셜치, 펌블치로 목표치 5 판정
27
+ VT@10#3>=5 스페셜치 10, 펌블치 3으로 목표치 5 판정
28
+ VT@10#3$5>=5 스페셜치 10, 펌블치 3으로 목표치 5 판정. 이때 달성치가 목표치보다 5이상 큰 경우, 갭 보너스를 표시
29
+ VT3@10#3>=5 어드밴티지 1점을 사용해 스페셜치 10, 펌블치 3, 목표치 5 판정을 주사위 3개로 판정
30
+ VT3@10#3$4>=5 어드밴티지 1점을 사용해 스페셜치 10, 펌블치 3, 목표치 5 판정을 주사위 3개로 판정. 이때 달성치가 목표치보다 4이상 큰 경우, 갭 보너스를 표시
31
+ MESSAGETEXT
32
+
33
+ # 既定のスペシャル値
34
+ DEFAULT_SPECIAL_VALUE = 12
35
+ # 既定のファンブル値
36
+ DEFAULT_FUMBLE_VALUE = 2
37
+ # 規定のダイス個数
38
+ DEFAULT_DICE_NUM = 2
39
+
40
+ # ダイスボットで使用するコマンドを配列で列挙する
41
+ register_prefix('VT')
42
+
43
+ def eval_game_system_specific_command(command)
44
+ debug("eval_game_system_specific_command Begin")
45
+
46
+ parser = Command::Parser.new('VT', round_type: round_type)
47
+ .enable_critical
48
+ .enable_fumble
49
+ .enable_dollar
50
+ .enable_suffix_number
51
+ .restrict_cmp_op_to(nil, :>=)
52
+ cmd = parser.parse(command)
53
+
54
+ unless cmd
55
+ return nil
56
+ end
57
+
58
+ dice_num = cmd.suffix_number || DEFAULT_DICE_NUM
59
+ if dice_num < DEFAULT_DICE_NUM
60
+ return nil
61
+ end
62
+
63
+ dice_list = @randomizer.roll_barabara(dice_num, 6)
64
+ if dice_num > 2
65
+ # 出目の順序を保存して上位2つの出目を取得
66
+ j = 0 # 安定ソートのために利用 cf. https://docs.ruby-lang.org/ja/latest/method/Enumerable/i/sort_by.html
67
+ using_list = dice_list.map.with_index { |x, i| {index: i, value: x} }
68
+ .sort_by { |x| [x[:value], j += 1] }.reverse.take(2)
69
+ .sort_by { |x| x[:index] }.map { |x| x[:value] }
70
+ else
71
+ using_list = dice_list
72
+ end
73
+ dice_total = using_list.sum
74
+ total = dice_total + cmd.modify_number
75
+
76
+ result = compare(dice_total, total, cmd)
77
+
78
+ advantage_str =
79
+ if dice_num > 2
80
+ using_list.to_s
81
+ end
82
+
83
+ modifier_str =
84
+ if cmd.modify_number > 0
85
+ "#{dice_total}#{Format.modifier(cmd.modify_number)}"
86
+ end
87
+
88
+ level_gap_str =
89
+ if cmd.target_number && cmd.dollar && result.success? && (gap = total - cmd.target_number) >= cmd.dollar
90
+ "갭 보너스(#{gap})"
91
+ end
92
+
93
+ sequence = [
94
+ cmd.to_s,
95
+ dice_list.to_s,
96
+ advantage_str,
97
+ modifier_str,
98
+ total.to_s,
99
+ result.text,
100
+ level_gap_str,
101
+ ].compact
102
+
103
+ result.text = sequence.join(" > ")
104
+
105
+ return result
106
+ end
107
+
108
+ def compare(dice_total, total, cmd)
109
+ special = cmd.critical || DEFAULT_SPECIAL_VALUE
110
+ fumble = cmd.fumble || DEFAULT_FUMBLE_VALUE
111
+
112
+ if dice_total <= fumble
113
+ return Result.fumble('펌블')
114
+ elsif dice_total >= special
115
+ return Result.critical('스페셜')
116
+ end
117
+
118
+ if cmd.target_number
119
+ if total.send(cmd.cmp_op, cmd.target_number)
120
+ return Result.success('성공')
121
+ else
122
+ return Result.failure('실패')
123
+ end
124
+ else
125
+ return Result.new(nil)
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end