Class: BCDice::GameSystem::ZombiLine
- Defined in:
- lib/bcdice/game_system/ZombiLine.rb
Direct Known Subclasses
Constant Summary collapse
- ID =
ゲームシステムの識別子
"ZombiLine"- NAME =
ゲームシステム名
"ゾンビライン"- SORT_KEY =
ゲームシステム名の読みがな
"そんひらいん"- HELP_MESSAGE =
<<~TEXT ■ 判定 (xZL<=y) x:ダイス数(省略時は1) y:成功率 ■ 各種表 ストレス症状表 SST 食材表 IT TEXT
- TABLES =
translate_tables(:ja_jp).freeze
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
- #check_action(command) ⇒ Object
- #eval_game_system_specific_command(command) ⇒ Object
-
#initialize(command) ⇒ ZombiLine
constructor
A new instance of ZombiLine.
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
Constructor Details
#initialize(command) ⇒ ZombiLine
Returns a new instance of ZombiLine.
25 26 27 28 |
# File 'lib/bcdice/game_system/ZombiLine.rb', line 25 def initialize(command) super(command) @sides_implicit_d = 10 end |
Instance Method Details
#check_action(command) ⇒ Object
34 35 36 37 38 39 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bcdice/game_system/ZombiLine.rb', line 34 def check_action(command) parser = Command::Parser.new("ZL", round_type: @round_type) .enable_prefix_number .disable_modifier .restrict_cmp_op_to(:<=) parsed = parser.parse(command) return nil unless parsed dice_count = parsed.prefix_number || 1 target_num = parsed.target_number debug(dice_count) dice_list = @randomizer.(dice_count, 100).sort is_success = dice_list.any? { |i| i <= target_num } is_critical = dice_list.any? { |i| i <= 5 } is_fumble = dice_list.any? { |i| i >= 96 && i > target_num } if is_critical && is_fumble is_critical = false is_fumble = false end = if is_success && is_critical translate("ZombiLine.success_critical") elsif is_success && is_fumble translate("ZombiLine.success_fumble") elsif is_success translate("ZombiLine.success") elsif is_fumble translate("ZombiLine.failure_fumble") else translate("ZombiLine.failure") end sequence = [ "(#{parsed})", "[#{dice_list.join(',')}]", ] Result.new.tap do |r| r.text = sequence.join(" > ") r.condition = is_success r.critical = is_critical r.fumble = is_fumble end end |
#eval_game_system_specific_command(command) ⇒ Object
30 31 32 |
# File 'lib/bcdice/game_system/ZombiLine.rb', line 30 def eval_game_system_specific_command(command) return check_action(command) || roll_tables(command, self.class::TABLES) end |