Class: BCDice::GameSystem::PhantasmAdventure

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

Constant Summary collapse

ID =

ゲームシステムの識別子

'PhantasmAdventure'
NAME =

ゲームシステム名

'ファンタズム・アドベンチャー'
SORT_KEY =

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

'ふあんたすむあとへんちやあ'
HELP_MESSAGE =

ダイスボットの使い方

<<~INFO_MESSAGE_TEXT
  成功、失敗、決定的成功、決定的失敗の表示とクリティカル・ファンブル値計算の実装。
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

#result_1d20(total, _dice_total, cmp_op, diff) ⇒ Object

ゲーム別成功度判定(1d20)



21
22
23
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
57
58
59
60
61
62
63
64
65
66
# File 'lib/bcdice/game_system/PhantasmAdventure.rb', line 21

def result_1d20(total, _dice_total, cmp_op, diff)
  return Result.nothing if diff == '?'
  return nil unless cmp_op == :<=

  # 技能値の修正を計算する
  skill_mod = 0
  if diff < 1
    skill_mod = diff - 1
  elsif diff > 20
    skill_mod = diff - 20
  end

  fumble = 20 + skill_mod
  fumble = 20 if fumble > 20
  critical = 1 + skill_mod
  dice_now = @randomizer.roll_once(20)

  if (total >= fumble) || (total >= 20)
    fum_num = dice_now - skill_mod
    fum_num = 20 if fum_num > 20
    fum_num = 1 if fum_num < 1

    fum_str = dice_now.to_s
    if skill_mod < 0
      fum_str += "+#{skill_mod * -1}=#{fum_num}"
    else
      fum_str += "-#{skill_mod}=#{fum_num}"
    end
    return Result.fumble("致命的失敗(#{fum_str})")

  elsif (total <= critical) || (total <= 1)
    crit_num = dice_now + skill_mod
    crit_num = 20 if crit_num > 20
    crit_num = 1 if crit_num < 1

    if skill_mod < 0
      return Result.success("成功")
    end

    return Result.critical("決定的成功(#{dice_now}+#{skill_mod}=#{crit_num})")
  elsif total <= diff
    return Result.success("成功")
  else
    return Result.failure("失敗")
  end
end