Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

『トレイル・オブ・クトゥルー』専用ダイスを作成しました #728

Merged
merged 10 commits into from
Jun 27, 2024

Conversation

Faceless192x
Copy link
Contributor

『トレイル・オブ・クトゥルー』( https://www.groupsne.co.jp/products/ToC/index.html )の専用ダイスを作成しました。
今度は中身が入っています。

    ■技能判定 TCb[>=t]   b:消費プール・ポイント t:難易度(省略可能)

    例)TC2>=5:消費プール・ポイント2,難易度5で技能判定し、その結果を表示する。
       TC>=3: 難易度3で技能判定し、その結果を表示する。
       TC:    難易度指定せずに技能判定する。
       TC3:   消費プール・ポイント3,難易度指定せずに技能判定する。

    ■神話的狂気表 MMT[a,b]   a,b:除外する神話的狂気(省略時は全神話的狂気を表示する)

    例)MMT[1,8]: 神話的狂気のうち、1番と8番を除外してロールし、神話的狂気を決定する。
       MMT2,6:   神話的狂気のうち、2番と6番を除外してロールし、神話的狂気を決定する。
       MMT:      神話的狂気を1番から8番まで列挙する。

以上の二つのコマンドを実装しました。rubocop通過済み。

お手隙の際にご確認ください。

m = /^TC([+\d]*)(>=(\d+))?/.match(command)
return nil unless m

bonus = ArithmeticEvaluator.eval(m[1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BCDice::ArithmeticEvaluator.eval() は不正な式の場合でも 0 を返すため、非推奨です。BCDice::Arithmetic.eval() を使うようにしてください。また、不正な式の場合にはnilを返してコマンドを実行しないようにするのが理想かと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解しました!
式の内容を見て、不正式の場合はnilを返すようにしてみます。

].freeze

def roll_mythos_madness_table(command)
m = /^MMT(\[?([,\d]+)\]?)?/.match(command)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この正規表現だと MMT[,] のような入力をした時に意図しない動作をしそうなので、/^MMT(\[?([1-8],[1-8])\]?)?$/ のように、決め打ちにしてもよいかもしれません。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解しました!
そのように修正します。

@ysakasin ysakasin merged commit 2593803 into bcdice:master Jun 27, 2024
6 checks passed
@ysakasin
Copy link
Member

@Faceless192x
ありがとうございます! マージしました

@Faceless192x
Copy link
Contributor Author

ありがとうございます!

@Faceless192x Faceless192x deleted the feature/TrailOfCthulhu branch June 27, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants