diff --git a/src/diceBot/Fiasco.rb b/src/diceBot/Fiasco.rb new file mode 100644 index 000000000..34bee85de --- /dev/null +++ b/src/diceBot/Fiasco.rb @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# frozen_string_literal: true + +class Fiasco < DiceBot + # ゲームシステムの識別子 + ID = 'Fiasco' + + # ゲームシステム名 + NAME = 'フィアスコ' + + # ゲームシステム名の読みがな + SORT_KEY = 'ふいあすこ' + + # ダイスボットの使い方 + HELP_MESSAGE = < #{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 diff --git a/src/test/data/Fiasco.txt b/src/test/data/Fiasco.txt new file mode 100644 index 000000000..67599f2a7 --- /dev/null +++ b/src/test/data/Fiasco.txt @@ -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