bcdice 3.9.0 → 3.10.0

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,133 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bcdice/base'
4
+
5
+ module BCDice
6
+ module GameSystem
7
+ class Ventangle < Base
8
+ # ゲームシステムの識別子
9
+ ID = 'Ventangle'
10
+
11
+ # ゲームシステム名
12
+ NAME = 'Ventangle'
13
+
14
+ # ゲームシステム名の読みがな
15
+ #
16
+ # 「ゲームシステム名の読みがなの設定方法」(docs/dicebot_sort_key.md)を参考にして
17
+ # 設定してください
18
+ SORT_KEY = 'うえんたんくる'
19
+
20
+ # ダイスボットの使い方
21
+ HELP_MESSAGE = <<~MESSAGETEXT
22
+ 基本書式 VTn@s#f$g>=T n=ダイス数(省略時2) s=スペシャル値(省略時12) f=ファンブル値(省略時2) g=レベルギャップ判定値(省略可) T=目標値(省略可)
23
+
24
+ 例:
25
+ VT デフォルトのスペシャル値・ファンブル値の判定を行う
26
+ VT@10#3 スペシャル値10、ファンブル値3の判定を行う
27
+ VT3@10#3 スペシャル値10、ファンブル値3の判定を、アドバンテージを1点消費してダイス3つで行う
28
+
29
+ VT>=5 デフォルトのスペシャル値・ファンブル値で目標値5の判定を行う
30
+ VT@10#3>=5 スペシャル値10、ファンブル値3で目標値5の判定を行う
31
+ VT@10#3$5>=5 スペシャル値10、ファンブル値3で目標値5の判定を行う。この際達成値が目標値より5以上大きい場合、ギャップボーナスを表示する
32
+ VT3@10#3>=5 スペシャル値10、ファンブル値3で目標値5の判定を、アドバンテージを1点消費してダイス3つで行う
33
+ VT3@10#3$4>=5 スペシャル値10、ファンブル値3で目標値5の判定を、アドバンテージを1点消費してダイス3つで行う。この際達成値が目標値より4以上大きい場合、ギャップボーナスを表示する
34
+ MESSAGETEXT
35
+
36
+ # 既定のスペシャル値
37
+ DEFAULT_SPECIAL_VALUE = 12
38
+ # 既定のファンブル値
39
+ DEFAULT_FUMBLE_VALUE = 2
40
+ # 規定のダイス個数
41
+ DEFAULT_DICE_NUM = 2
42
+
43
+ # ダイスボットで使用するコマンドを配列で列挙する
44
+ register_prefix('VT')
45
+
46
+ def eval_game_system_specific_command(command)
47
+ debug("eval_game_system_specific_command Begin")
48
+
49
+ parser = Command::Parser.new('VT', round_type: round_type)
50
+ .enable_critical
51
+ .enable_fumble
52
+ .enable_dollar
53
+ .enable_suffix_number
54
+ .restrict_cmp_op_to(nil, :>=)
55
+ cmd = parser.parse(command)
56
+
57
+ unless cmd
58
+ return nil
59
+ end
60
+
61
+ dice_num = cmd.suffix_number || DEFAULT_DICE_NUM
62
+ if dice_num < DEFAULT_DICE_NUM
63
+ return nil
64
+ end
65
+
66
+ dice_list = @randomizer.roll_barabara(dice_num, 6)
67
+ if dice_num > 2
68
+ # 出目の順序を保存して上位2つの出目を取得
69
+ j = 0 # 安定ソートのために利用 cf. https://docs.ruby-lang.org/ja/latest/method/Enumerable/i/sort_by.html
70
+ using_list = dice_list.map.with_index { |x, i| {index: i, value: x} }
71
+ .sort_by { |x| [x[:value], j += 1] }.reverse.take(2)
72
+ .sort_by { |x| x[:index] }.map { |x| x[:value] }
73
+ else
74
+ using_list = dice_list
75
+ end
76
+ dice_total = using_list.sum
77
+ total = dice_total + cmd.modify_number
78
+
79
+ result = compare(dice_total, total, cmd)
80
+
81
+ advantage_str =
82
+ if dice_num > 2
83
+ using_list.to_s
84
+ end
85
+
86
+ modifier_str =
87
+ if cmd.modify_number > 0
88
+ "#{dice_total}#{Format.modifier(cmd.modify_number)}"
89
+ end
90
+
91
+ level_gap_str =
92
+ if cmd.target_number && cmd.dollar && result.success? && (gap = total - cmd.target_number) >= cmd.dollar
93
+ "ギャップボーナス(#{gap})"
94
+ end
95
+
96
+ sequence = [
97
+ cmd.to_s,
98
+ dice_list.to_s,
99
+ advantage_str,
100
+ modifier_str,
101
+ total.to_s,
102
+ result.text,
103
+ level_gap_str,
104
+ ].compact
105
+
106
+ result.text = sequence.join(" > ")
107
+
108
+ return result
109
+ end
110
+
111
+ def compare(dice_total, total, cmd)
112
+ special = cmd.critical || DEFAULT_SPECIAL_VALUE
113
+ fumble = cmd.fumble || DEFAULT_FUMBLE_VALUE
114
+
115
+ if dice_total <= fumble
116
+ return Result.fumble('ファンブル')
117
+ elsif dice_total >= special
118
+ return Result.critical('スペシャル')
119
+ end
120
+
121
+ if cmd.target_number
122
+ if total.send(cmd.cmp_op, cmd.target_number)
123
+ return Result.success('成功')
124
+ else
125
+ return Result.failure('失敗')
126
+ end
127
+ else
128
+ return Result.new(nil)
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BCDice
2
4
  module GameSystem
3
5
  class Cthulhu7th < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bcdice/result"
2
4
  require "bcdice/translate"
3
5
 
@@ -100,6 +100,7 @@ require "bcdice/game_system/GURPS"
100
100
  require "bcdice/game_system/GurpsFW"
101
101
  require "bcdice/game_system/HarnMaster"
102
102
  require "bcdice/game_system/HatsuneMiku"
103
+ require "bcdice/game_system/HeroScale"
103
104
  require "bcdice/game_system/Hieizan"
104
105
  require "bcdice/game_system/HouraiGakuen"
105
106
  require "bcdice/game_system/HuntersMoon"
@@ -226,6 +227,7 @@ require "bcdice/game_system/TwilightGunsmoke"
226
227
  require "bcdice/game_system/UnsungDuet"
227
228
  require "bcdice/game_system/Utakaze"
228
229
  require "bcdice/game_system/VampireTheMasquerade5th"
230
+ require "bcdice/game_system/Ventangle"
229
231
  require "bcdice/game_system/Villaciel"
230
232
  require "bcdice/game_system/VisionConnect"
231
233
  require "bcdice/game_system/WARPS"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BCDice
4
- VERSION = "3.9.0"
4
+ VERSION = "3.10.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcdice
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SAKATA Sinji
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-25 00:00:00.000000000 Z
11
+ date: 2023-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -237,6 +237,7 @@ files:
237
237
  - lib/bcdice/game_system/GurpsFW.rb
238
238
  - lib/bcdice/game_system/HarnMaster.rb
239
239
  - lib/bcdice/game_system/HatsuneMiku.rb
240
+ - lib/bcdice/game_system/HeroScale.rb
240
241
  - lib/bcdice/game_system/Hieizan.rb
241
242
  - lib/bcdice/game_system/HouraiGakuen.rb
242
243
  - lib/bcdice/game_system/HunterTheReckoning5th.rb
@@ -363,6 +364,7 @@ files:
363
364
  - lib/bcdice/game_system/UnsungDuet.rb
364
365
  - lib/bcdice/game_system/Utakaze.rb
365
366
  - lib/bcdice/game_system/VampireTheMasquerade5th.rb
367
+ - lib/bcdice/game_system/Ventangle.rb
366
368
  - lib/bcdice/game_system/Villaciel.rb
367
369
  - lib/bcdice/game_system/VisionConnect.rb
368
370
  - lib/bcdice/game_system/WARPS.rb
@@ -450,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
450
452
  - !ruby/object:Gem::Version
451
453
  version: '0'
452
454
  requirements: []
453
- rubygems_version: 3.4.5
455
+ rubygems_version: 3.4.12
454
456
  signing_key:
455
457
  specification_version: 4
456
458
  summary: BCDice is a rolling dice engine for TRPG