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

[BlindMythos] 守護星表チェックでResultを使用 #461

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 16 additions & 24 deletions lib/bcdice/game_system/BlindMythos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BlindMythos < Base
 BMSは振り足しを自動では行いません。
例)BM>=1 BM@3>=1 BMS2>=1

・判定振り足し:ReRollx,x,x...@y>=1
・判定振り足し:ReRollx,x,x...@y>=z
 x:振るダイスの個数
  y:目標難易度(省略可。デフォルト4)
  z:必要成功度
Expand All @@ -47,8 +47,8 @@ def eval_game_system_specific_command(command)
text, = reRoll(command, isStop)
return text unless text.nil?

text = getRulingPlanetDiceCommandResult(command)
return text unless text.nil?
result = getRulingPlanetDiceCommandResult(command)
return result unless result.nil?

text = getDurtyTableCommandReuslt(command)
return text unless text.nil?
Expand Down Expand Up @@ -252,44 +252,36 @@ def getSuccessResultText(diceList, judgeNumber)
end

def getRulingPlanetDiceCommandResult(command)
return nil unless command =~ /^RP(\d+)/i
m = /^RP(\d+)$/i.match(command)
return nil unless m

targetNumbers = Regexp.last_match(1).split(//).map(&:to_i)
targetNumbers = m[1].each_char.map(&:to_i)
diceList = getRulingPlanetDice

matchResult = "失敗"
targetNumbers.each do |i|
if diceList.include?(i)
matchResult = "発動"
break
end
end
condition = diceList.any? { |dice| targetNumbers.include?(dice) }

text = "守護星表チェック(#{targetNumbers.join(',')}) > #{diceList.count}D10[#{diceList.join(',')}] > #{matchResult}"
result = condition ? "発動" : "失敗"
text = "守護星表チェック(#{targetNumbers.join(',')}) > #{diceList.count}D10[#{diceList.join(',')}] > #{result}"

return text
Result.new.tap do |r|
r.text = text
r.condition = condition
end
end

def getRulingPlanetDice
dice1 = @randomizer.roll_once(10)
dice2 = dice1
dice1, dice2 = @randomizer.roll_barabara(2, 10)

while dice1 == dice2
dice2 = @randomizer.roll_once(10)
end

dice1 = changeRulingPlanetDice(dice1)
dice2 = changeRulingPlanetDice(dice2)
dice1 = 0 if dice1 == 10
dice2 = 0 if dice2 == 10

return dice1, dice2
end

def changeRulingPlanetDice(dice)
return 0 if dice == 10

return dice
end

def getDurtyTableCommandReuslt(command)
return nil unless /^DT$/i =~ command

Expand Down
3 changes: 3 additions & 0 deletions test/data/BlindMythos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ rands = [
game_system = "BlindMythos"
input = "RP123"
output = "守護星表チェック(1,2,3) > 2D10[1,0] > 発動"
success = true
rands = [
{ sides = 10, value = 1 },
{ sides = 10, value = 10 },
Expand All @@ -284,6 +285,7 @@ rands = [
game_system = "BlindMythos"
input = "RP258"
output = "守護星表チェック(2,5,8) > 2D10[1,4] > 失敗"
failure = true
rands = [
{ sides = 10, value = 1 },
{ sides = 10, value = 4 },
Expand All @@ -293,6 +295,7 @@ rands = [
game_system = "BlindMythos"
input = "RP890"
output = "守護星表チェック(8,9,0) > 2D10[3,0] > 発動"
success = true
rands = [
{ sides = 10, value = 3 },
{ sides = 10, value = 3 },
Expand Down