Class: BCDice::GameSystem::RecordOfLodossWar

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

Constant Summary collapse

ID =
'RecordOfLodossWar'
NAME =
'ロードス島戦記RPG'
SORT_KEY =
'ろおとすとうせんきRPG'
HELP_MESSAGE =
<<~INFO_MESSAGE_TEXT
  ●判定
   LW<=(目標値)で判定。
   達成値が目標値の1/10(端数切り上げ)以下であれば大成功。1~10であれば自動成功。
   91~100であれば自動失敗となります。

  ●回避判定
   LWD<=(目標値)で回避判定。この時出目が51以上で自動失敗となります。

   判定と回避判定は、どちらもコマンドだけの場合、出目の表示と自動成功と自動失敗の判定のみを行います。
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, #initialize, prefixes_pattern, register_prefix, register_prefix_from_super_class, #sort_add_dice?, #sort_barabara_dice?

Methods included from Translate

#translate

Constructor Details

This class inherits a constructor from BCDice::Base

Instance Method Details

#eval_game_system_specific_command(command) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bcdice/game_system/RecordOfLodossWar.rb', line 24

def eval_game_system_specific_command(command)
  parser = Command::Parser.new("LWD", "LW", round_type: round_type)
                          .restrict_cmp_op_to(nil, :<=)
  cmd = parser.parse(command)

  if cmd.nil? || ![nil, :<=].include?(cmd.cmp_op)
    return nil
  end

  auto_failure = cmd.command == "LWD" ? 51 : 91
  critical = (cmd.target_number.to_f / 10).ceil

  dice_value = @randomizer.roll_once(100)

  result =
    if dice_value >= auto_failure
      "自動失敗(#{auto_failure})"
    elsif dice_value <= critical
      "大成功(#{critical})"
    elsif dice_value <= 10
      "自動成功"
    elsif cmd.cmp_op
      dice_value <= cmd.target_number ? "成功" : "失敗"
    end

  sequence = [
    "(1D100#{cmd.cmp_op}#{cmd.target_number})",
    dice_value.to_s,
    result
  ].compact

  return sequence.join("")
end