Class: BCDice::GameSystem::SwordWorld::RatingParsed

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/game_system/sword_world/rating_parsed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rate, modifier) ⇒ RatingParsed

Returns a new instance of RatingParsed.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 40

def initialize(rate, modifier)
  @rate = rate
  @modifier = modifier
  @critical = 13
  @kept_modify = 0
  @first_to = 0
  @first_modify = 0
  @greatest_fortune = false
  @rateup = 0
  @semi_fixed_val = 0
  @tmp_fixed_val = 0
  @modifier_after_half = nil
end

Instance Attribute Details

#criticalInteger

Returns:

  • (Integer)


11
12
13
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 11

def critical
  @critical
end

#first_modifyInteger

Returns:

  • (Integer)


20
21
22
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 20

def first_modify
  @first_modify
end

#first_toInteger

Returns:

  • (Integer)


17
18
19
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 17

def first_to
  @first_to
end

#greatest_fortuneBoolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 26

def greatest_fortune
  @greatest_fortune
end

#kept_modifyInteger

Returns:

  • (Integer)


14
15
16
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 14

def kept_modify
  @kept_modify
end

#modifierInteger

Returns:

  • (Integer)


35
36
37
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 35

def modifier
  @modifier
end

#modifier_after_halfInteger?

Returns:

  • (Integer, nil)


38
39
40
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 38

def modifier_after_half
  @modifier_after_half
end

#rateInteger

Returns:

  • (Integer)


8
9
10
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 8

def rate
  @rate
end

#rateupInteger

Returns:

  • (Integer)


23
24
25
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 23

def rateup
  @rateup
end

#semi_fixed_valInteger

Returns:

  • (Integer)


29
30
31
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 29

def semi_fixed_val
  @semi_fixed_val
end

#tmp_fixed_valInteger

Returns:

  • (Integer)


32
33
34
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 32

def tmp_fixed_val
  @tmp_fixed_val
end

Instance Method Details

#halfBoolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 55

def half
  return !@modifier_after_half.nil?
end

#infinite_roll?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 69

def infinite_roll?
  return critical < min_critical
end

#min_criticalInteger

Returns:

  • (Integer)


60
61
62
63
64
65
66
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 60

def min_critical
  if @semi_fixed_val <= 1
    return 3
  else
    return (@semi_fixed_val + @kept_modify + 2).clamp(3, 13)
  end
end

#to_sString

Returns:

  • (String)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/bcdice/game_system/sword_world/rating_parsed.rb', line 74

def to_s()
  output = "KeyNo.#{@rate}"

  output += "c[#{critical}]" if critical < 13
  output += "m[#{Format.modifier(first_modify)}]" if first_modify != 0
  output += "m[#{first_to}]" if first_to != 0
  output += "r[#{rateup}]" if rateup != 0
  output += "gf" if @greatest_fortune
  output += "sf[#{semi_fixed_val}]" if semi_fixed_val != 0
  output += "tf[#{tmp_fixed_val}]" if tmp_fixed_val != 0
  output += "a[#{Format.modifier(kept_modify)}]" if kept_modify != 0

  if @modifier != 0
    output += Format.modifier(@modifier)
  end
  return output
end