Skip to content

Commit

Permalink
BCDice: インスタンス変数を使わない
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Jan 7, 2021
1 parent bdd6e4c commit c7bfef4
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/rgrb/plugin/bcdice/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ module Bcdice
class Generator
include PluginBase::Generator

# ジェネレータを初期化する
def initialize
@game_systems = BCDice.all_game_systems.to_h do |gs|
[gs::ID, gs]
end
end

# プラグインがアダプタによって読み込まれた際の設定
#
# アダプタによってジェネレータが用意されたとき
Expand All @@ -48,11 +41,11 @@ def bcdice(command, specified_game_type = nil)
# そのため、デフォルト引数値では game_type を設定できない
game_type = specified_game_type || 'DiceBot'
# ダイスボットを探す
dice_bot = @game_systems[game_type]
dice_bot = BCDice.game_system_class(game_type)
# ダイスボットが見つからなかった場合は中断する
raise DiceBotNotFound, game_type unless dice_bot

result = dice_bot.new(command).eval
result = dice_bot.eval(command)
# 結果が返ってこなかった場合は中断する
raise InvalidCommandError.new(command, dice_bot) unless result

Expand Down

0 comments on commit c7bfef4

Please sign in to comment.