class BCDice::GameSystem::TrinitySeven
Constants
- HELP_MESSAGE
ダイスボットの使い方
- ID
ゲームシステムの識別子
- NAME
ゲームシステム名
- NAME1
- NAME2
- SORT_KEY
ゲームシステム名の読みがな
Public Instance Methods
eval_game_system_specific_command(command)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 41 def eval_game_system_specific_command(command) # スパゲッティなコードだけど許して!!! → 絶対に許さない。全力でリファクタリングした。 debug("eval_game_system_specific_command command", command) roll_hit(command) || roll_damage(command) || roll_name(command) end
get_hit_roll_result(total, target, critical)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 71 def get_hit_roll_result(total, target, critical) if total >= 96 Result.fumble("ファンブル") elsif total <= critical Result.critical("クリティカル") elsif total <= target Result.success("成功") else Result.failure("失敗") end end
get_roll_damage_result(diceCount, critical, diceList, modify)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 104 def get_roll_damage_result(diceCount, critical, diceList, modify) if critical <= 0 total = diceList.sum() + modify return total, nil end restDice = diceList.clone critical = diceCount if critical > diceCount critical.times do restDice.shift diceList.shift diceList.push(7) end max = restDice.pop max = 1 if max.nil? total = max * (7**critical) + restDice.sum() + modify return total, diceList end
result_1d100(_total, dice_total, _cmp_op, _target)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 128 def result_1d100(_total, dice_total, _cmp_op, _target) if dice_total >= 96 Result.fumble("ファンブル") elsif dice_total <= 7 Result.critical("クリティカル") end end
roll_damage(command)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 83 def roll_damage(command) parser = Command::Parser.new(/\d+DM\d*/, round_type: round_type) .restrict_cmp_op_to(nil) cmd = parser.parse(command) return nil unless cmd dice_count, critical = cmd.command.split("DM", 2).map(&:to_i) modify = cmd.modify_number dice_list = @randomizer.roll_barabara(dice_count, 6).sort dice_text = dice_list.join(",") total, additionalList = get_roll_damage_result(dice_count, critical, dice_list, modify) additionalListText = additionalList.nil? ? "" : "→[#{additionalList.join(',')}]" text = "(#{cmd}) > [#{dice_text}]#{additionalListText}#{Format.modifier(modify)} > #{total}" return text end
roll_hit(command)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 49 def roll_hit(command) parser = Command::Parser.new(/TR\d*/, round_type: round_type) .restrict_cmp_op_to(:<=) cmd = parser.parse(command) return nil unless cmd modify = cmd.command[2..-1].to_i + cmd.modify_number critical = 7 + modify target = cmd.target_number total = @randomizer.roll_once(100) result = get_hit_roll_result(total, target, critical) cmd.command = "TR" cmd.modify_number = modify result.text = "(#{cmd}) > #{total} > #{result.text}" debug("eval_game_system_specific_command result text", result.text) result end
roll_name(command)
click to toggle source
# File lib/bcdice/game_system/TrinitySeven.rb, line 136 def roll_name(command) unless command == "TRNAME" return nil end first_name = NAME1.roll(@randomizer).last_body second_name = NAME2.roll(@randomizer).last_body text = "#{first_name} , #{second_name}" return text end