-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* フィアスコダイスボットを作成。 * ・関数名修正 * 関数名修正 * フィアスコダイスボット追加 * コマンドの見直し(FSSx→FSx,FSWxBx→WxBx) WxBxコマンド時のダイス表記を削除し、白の合計、黒の合計を表記するように修正
- Loading branch information
1 parent
cd846c7
commit 1da010a
Showing
2 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# -*- coding: utf-8 -*- | ||
# frozen_string_literal: true | ||
|
||
class Fiasco < DiceBot | ||
# ゲームシステムの識別子 | ||
ID = 'Fiasco' | ||
|
||
# ゲームシステム名 | ||
NAME = 'フィアスコ' | ||
|
||
# ゲームシステム名の読みがな | ||
SORT_KEY = 'ふいあすこ' | ||
|
||
# ダイスボットの使い方 | ||
HELP_MESSAGE = <<INFO_MESSAGE_TEXT | ||
・判定コマンド(FSx, WxBx) | ||
相関図・転落要素用(FSx):相関図や転落要素のためにx個ダイスを振り、出目ごとに分類する | ||
黒白差分判定用(WxBx) :転落、残響のために白ダイス(W指定)と黒ダイス(B指定)で差分を求める | ||
※ WとBは片方指定(Bx, Wx)、入替指定(WxBx,BxWx)可能 | ||
INFO_MESSAGE_TEXT | ||
|
||
COMMAND_TYPE_INDEX = 1 | ||
|
||
START_DICE_INDEX = 2 | ||
|
||
BW_FIRST_DICE_INDEX = 2 | ||
BW_SECOND_DICE_INDEX = 5 | ||
BW_SECOND_DICE_TAG_INDEX = 4 | ||
|
||
START_COMMAND_TAG = "FS" | ||
W_DICEROLL_COMMAND_TAG = "W" | ||
B_DICEROLL_COMMAND_TAG = "B" | ||
|
||
setPrefixes(['(FS|[WB])(\d+).*']) | ||
|
||
def rollDiceCommand(command) | ||
m = /\A(FS|[WB])(\d+)(([WB])(\d+))?/.match(command) | ||
unless m | ||
return '' | ||
end | ||
|
||
type = m[COMMAND_TYPE_INDEX] | ||
if type == START_COMMAND_TAG | ||
return makeStartDiceRoll(m) | ||
else | ||
return makeWhiteBlackDiceRoll(type, m) | ||
end | ||
end | ||
|
||
def makeStartDiceRoll(m) | ||
dice = m[START_DICE_INDEX] | ||
_, diceText, = roll(dice, 6) | ||
|
||
diceList = [0, 0, 0, 0, 0, 0] | ||
|
||
diceText.split(',').each do |takeDice| | ||
diceList[takeDice.to_i - 1] += 1 | ||
end | ||
|
||
return "1 => #{diceList[0]}個 2 => #{diceList[1]}個 3 => #{diceList[2]}個 4 => #{diceList[3]}個 5 => #{diceList[4]}個 6 => #{diceList[5]}個" | ||
end | ||
|
||
def makeWhiteBlackDiceRoll(type, m) | ||
if type == W_DICEROLL_COMMAND_TAG | ||
whiteTotal, whiteDiceText, blackTotal, blackDiceText = makeArgsDiceRoll(m[BW_FIRST_DICE_INDEX], m[BW_SECOND_DICE_INDEX]) | ||
result = "白#{whiteTotal}[#{whiteDiceText}]" | ||
if blackDiceText | ||
if m[BW_SECOND_DICE_TAG_INDEX] == W_DICEROLL_COMMAND_TAG | ||
return "#{m}:白指定(#{W_DICEROLL_COMMAND_TAG})は重複できません。" | ||
end | ||
|
||
result += " 黒#{blackTotal}[#{blackDiceText}]" | ||
end | ||
elsif type == B_DICEROLL_COMMAND_TAG | ||
blackTotal, blackDiceText, whiteTotal, whiteDiceText = makeArgsDiceRoll(m[BW_FIRST_DICE_INDEX], m[BW_SECOND_DICE_INDEX]) | ||
result = "黒#{blackTotal}[#{blackDiceText}]" | ||
if whiteDiceText | ||
if m[BW_SECOND_DICE_TAG_INDEX] == B_DICEROLL_COMMAND_TAG | ||
return "#{m}:黒指定(#{B_DICEROLL_COMMAND_TAG})は重複できません。" | ||
end | ||
|
||
result += " 白#{whiteTotal}[#{whiteDiceText}]" | ||
end | ||
else | ||
return '' | ||
end | ||
|
||
if blackTotal > whiteTotal | ||
return "#{result} > 黒#{blackTotal - whiteTotal}" | ||
elsif blackTotal < whiteTotal | ||
return "#{result} > 白#{whiteTotal - blackTotal}" | ||
end | ||
|
||
return "#{result} > 0" | ||
end | ||
|
||
def makeArgsDiceRoll(firstDice, secondDice) | ||
secondTotal = 0 | ||
|
||
firstTotal, firstDiceText, = roll(firstDice, 6) | ||
|
||
if secondDice | ||
if secondDice.to_i > 0 | ||
secondTotal, secondDiceText, = roll(secondDice, 6) | ||
else | ||
secondDiceText = "0" | ||
end | ||
end | ||
|
||
return firstTotal, firstDiceText, secondTotal, secondDiceText | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
input: | ||
FS12 | ||
output: | ||
Fiasco : 1 => 3個 2 => 2個 3 => 1個 4 => 3個 5 => 1個 6 => 2個 | ||
rand:1/6,2/6,1/6,3/6,4/6,6/6,4/6,5/6,6/6,4/6,2/6,1/6 | ||
============================ | ||
input: | ||
W3B3 | ||
output: | ||
Fiasco : 白6[1,2,3] 黒15[4,5,6] > 黒9 | ||
rand:1/6,2/6,3/6,4/6,5/6,6/6 | ||
============================ | ||
input: | ||
W3B3 | ||
output: | ||
Fiasco : 白12[4,5,3] 黒8[1,5,2] > 白4 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
W6 | ||
output: | ||
Fiasco : 白20[4,5,3,1,5,2] > 白20 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
B6 | ||
output: | ||
Fiasco : 黒20[4,5,3,1,5,2] > 黒20 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
W6B0 | ||
output: | ||
Fiasco : 白20[4,5,3,1,5,2] 黒0[0] > 白20 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
B6W0 | ||
output: | ||
Fiasco : 黒20[4,5,3,1,5,2] 白0[0] > 黒20 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
B3W3 | ||
output: | ||
Fiasco : 黒8[1,5,2] 白8[1,5,2] > 0 | ||
rand:1/6,5/6,2/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
W3W3 | ||
output: | ||
Fiasco : W3W3:白指定(W)は重複できません。 | ||
rand:1/6,2/6,3/6,4/6,5/6,6/6 | ||
============================ | ||
input: | ||
B3B3 | ||
output: | ||
Fiasco : B3B3:黒指定(B)は重複できません。 | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SFS12 | ||
output: | ||
Fiasco : 1 => 3個 2 => 2個 3 => 1個 4 => 3個 5 => 1個 6 => 2個###secret dice### | ||
rand:1/6,2/6,1/6,3/6,4/6,6/6,4/6,5/6,6/6,4/6,2/6,1/6 | ||
============================ | ||
input: | ||
SW3B3 | ||
output: | ||
Fiasco : 白6[1,2,3] 黒15[4,5,6] > 黒9###secret dice### | ||
rand:1/6,2/6,3/6,4/6,5/6,6/6 | ||
============================ | ||
input: | ||
SW3B3 | ||
output: | ||
Fiasco : 白12[4,5,3] 黒8[1,5,2] > 白4###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SW6 | ||
output: | ||
Fiasco : 白20[4,5,3,1,5,2] > 白20###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SB6 | ||
output: | ||
Fiasco : 黒20[4,5,3,1,5,2] > 黒20###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SW6B0 | ||
output: | ||
Fiasco : 白20[4,5,3,1,5,2] 黒0[0] > 白20###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SB6W0 | ||
output: | ||
Fiasco : 黒20[4,5,3,1,5,2] 白0[0] > 黒20###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SB3W3 | ||
output: | ||
Fiasco : 黒8[1,5,2] 白8[1,5,2] > 0###secret dice### | ||
rand:1/6,5/6,2/6,1/6,5/6,2/6 | ||
============================ | ||
input: | ||
SW3W3 | ||
output: | ||
Fiasco : W3W3:白指定(W)は重複できません。###secret dice### | ||
rand:1/6,2/6,3/6,4/6,5/6,6/6 | ||
============================ | ||
input: | ||
SB3B3 | ||
output: | ||
Fiasco : B3B3:黒指定(B)は重複できません。###secret dice### | ||
rand:4/6,5/6,3/6,1/6,5/6,2/6 |