Skip to content

Commit

Permalink
Merge pull request #286 from bcdice/find_by_id
Browse files Browse the repository at this point in the history
IDを指定してゲームシステムを取得するように
ysakasin authored Nov 8, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
renovate-bot Mend Renovate
2 parents bb62822 + 60e0306 commit 47f7933
Showing 29 changed files with 1,485 additions and 1,480 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,13 @@
### 追加機能
- ログ・ホライズンTRPG: LHZB1とLHZB2両方の財宝表をサポート、消耗表ロールを追加、財宝表ロールを追加、区切り文字を変更 ([#279](https://github.com/bcdice/BCDice/pull/279))

### 変更
- 真・女神転生TRPG 覚醒篇: IDを `ShinMegamiTenseiKakuseihen` に変更 ([#286](https://github.com/bcdice/BCDice/pull/286))
- トーグ: IDを `Torg` に変更 ([#286](https://github.com/bcdice/BCDice/pull/286))
- トーグ1.5版: IDを `Torg1.5` に変更 ([#286](https://github.com/bcdice/BCDice/pull/286))
- NJSLYRBATTLE: IDを `NjslyrBattle` に変更 ([#286](https://github.com/bcdice/BCDice/pull/286))
- ガープス: クラス名を `GURPS` に変更 ([#286](https://github.com/bcdice/BCDice/pull/286))

### バグ修正
- キルデスビジネス: 蘇生副作用表の誤植を修正。スイさんありがとうっ! ([#283](https://github.com/bcdice/BCDice/pull/283))

2 changes: 1 addition & 1 deletion lib/bcdice/game_system.rb
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@
require "bcdice/game_system/Gundog"
require "bcdice/game_system/GundogRevised"
require "bcdice/game_system/GundogZero"
require "bcdice/game_system/Gurps"
require "bcdice/game_system/GURPS"
require "bcdice/game_system/GurpsFW"
require "bcdice/game_system/HarnMaster"
require "bcdice/game_system/HatsuneMiku"
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

module BCDice
module GameSystem
class Gurps < Base
class GURLS < Base
# ゲームシステムの識別子
ID = 'GURPS'

2 changes: 1 addition & 1 deletion lib/bcdice/game_system/NjslyrBattle.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ module BCDice
module GameSystem
class NjslyrBattle < Base
# ゲームシステムの識別子
ID = 'NJSLYRBATTLE'
ID = 'NjslyrBattle'

# ゲームシステム名
NAME = 'NJSLYRBATTLE'
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ module BCDice
module GameSystem
class ShinMegamiTenseiKakuseihen < Base
# ゲームシステムの識別子
ID = 'SMTKakuseihen'
ID = 'ShinMegamiTenseiKakuseihen'

# ゲームシステム名
NAME = '真・女神転生TRPG 覚醒篇'
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Torg.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ module BCDice
module GameSystem
class Torg < Base
# ゲームシステムの識別子
ID = 'TORG'
ID = 'Torg'

# ゲームシステム名
NAME = 'トーグ'
2 changes: 1 addition & 1 deletion lib/bcdice/game_system/Torg1_5.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ module BCDice
module GameSystem
class Torg1_5 < Torg
# ゲームシステムの識別子
ID = 'TORG1.5'
ID = 'Torg1.5'

# ゲームシステム名
NAME = 'トーグ1.5版'
14 changes: 6 additions & 8 deletions lib/bcdice/loader.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module BCDice
class << self
# クラス名を指定してゲームシステムのクラスを取得する
# IDを指定してゲームシステムのクラスを取得する
#
# @param class_name [String] クラス名
# @param id [String] ID
# @return [Class, nil]
def game_system_class(class_name)
BCDice::GameSystem.const_get(class_name)
rescue NameError
return nil
def game_system_class(id)
all_game_systems.find { |game_system| game_system::ID == id }
end

# 現在ロードされているゲームシステムのクラス一覧を返す
@@ -29,8 +27,8 @@ def dynamic_load(class_name)

require "bcdice/game_system/#{class_name}"

return game_system_class(class_name)
rescue LoadError
return BCDice::GameSystem.const_get(class_name)
rescue LoadError, NameError
return nil
end
end
Loading

0 comments on commit 47f7933

Please sign in to comment.