Class: BCDice::GameSystem::RokumonSekai2

Inherits:
Base
  • Object
show all
Defined in:
lib/bcdice/game_system/RokumonSekai2.rb

Constant Summary collapse

ID =

ゲームシステムの識別子

'RokumonSekai2'
NAME =

ゲームシステム名

'六門世界RPG セカンドエディション'
SORT_KEY =

ゲームシステム名の読みがな

'ろくもんせかいRPG2'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  ・判定
  aRSm<=t
  能力値a,修正値m,目標値tで判定ロールを行います。
  Rコマンド(3R6m<=t[a])に読み替えます。
  成功度、評価、ボーナスダイスを自動表示します。
   例) 3RS+1<=9 3R6+1<=9[3]
INFO_MESSAGE_TEXT

Instance Attribute Summary

Attributes inherited from Base

#d66_sort_type, #default_cmp_op, #default_target_number, #randomizer, #reroll_dice_reroll_threshold, #round_type, #sides_implicit_d, #upper_dice_reroll_threshold

Instance Method Summary collapse

Methods inherited from Base

#change_text, #check_result, command_pattern, #enable_debug, #enabled_d9?, eval, #eval, #grich_text, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

#initialize(command) ⇒ RokumonSekai2

Returns a new instance of RokumonSekai2.



27
28
29
30
31
# File 'lib/bcdice/game_system/RokumonSekai2.rb', line 27

def initialize(command)
  super(command)

  @sort_add_dice = true
end

Instance Method Details

#eval_game_system_specific_command(string) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/bcdice/game_system/RokumonSekai2.rb', line 40

def eval_game_system_specific_command(string)
  string = replace_text(string)
  unless /3R6([+\-\d]*)<=(\d+)\[(\d+)\]/i =~ string
    return nil
  end

  modText = Regexp.last_match(1)
  target = Regexp.last_match(2).to_i
  abl = Regexp.last_match(3).to_i

  mod = 0
  if modText
    mod = ArithmeticEvaluator.eval(modText)
  end

  dstr, suc, sum = rokumon2_roll(mod, target, abl)
  output = "#{sum}[#{dstr}] > #{suc} > 評価#{rokumon2_suc_rank(suc)}"

  if suc != 0
    output += "(+#{suc}d6)"
  end

  output = "(#{string}) > #{output}"

  return output
end

#replace_text(string) ⇒ Object



33
34
35
36
37
38
# File 'lib/bcdice/game_system/RokumonSekai2.rb', line 33

def replace_text(string)
  string = string.gsub(/(\d+)RS([+-][+\-\d]+)<=(\d+)/i) { "3R6#{Regexp.last_match(2)}<=#{Regexp.last_match(3)}[#{Regexp.last_match(1)}]" }
  string = string.gsub(/(\d+)RS<=(\d+)/i) { "3R6<=#{Regexp.last_match(2)}[#{Regexp.last_match(1)}]" }

  return string
end

#rokumon2_roll(mod, target, abl) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bcdice/game_system/RokumonSekai2.rb', line 67

def rokumon2_roll(mod, target, abl)
  suc = 0

  dice = @randomizer.roll_barabara(3 + mod.abs, 6).sort
  dicestr = dice.join(",")

  mod.abs.times do |_i|
    if mod < 0
      dice.shift
    else
      dice.pop
    end
  end

  cnt5 = 0
  cnt2 = 0
  sum = 0

  dice.each do |die1|
    cnt5 += 1 if die1 >= 5
    cnt2 += 1 if die1 <= 2
    suc += 1  if die1 <= abl
    sum += die1
  end

  if sum < target
    suc += 2
  elsif sum == target
    suc += 1
  end

  suc = 0 if cnt5 >= 3
  suc = 5 if cnt2 >= 3

  return dicestr, suc, sum
end

#rokumon2_suc_rank(suc) ⇒ Object



104
105
106
107
# File 'lib/bcdice/game_system/RokumonSekai2.rb', line 104

def rokumon2_suc_rank(suc)
  suc_rank = ['E', 'D', 'C', 'B', 'A', 'S']
  return suc_rank[suc]
end