Class: Mjai::Hora::PointsDatum

Inherits:
Object
  • Object
show all
Defined in:
lib/mjai/hora.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fu, fan, oya, hora_type) ⇒ PointsDatum

Returns a new instance of PointsDatum.



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
# File 'lib/mjai/hora.rb', line 35

def initialize(fu, fan, oya, hora_type)
  
  @fu = fu
  @fan = fan
  if @fan >= YAKUMAN_FAN
    @base_points = 8000 * (@fan / YAKUMAN_FAN)
  elsif @fan >= 13
    @base_points = 8000
  elsif @fan >= 11
    @base_points = 6000
  elsif @fan >= 8
    @base_points = 4000
  elsif @fan >= 6
    @base_points = 3000
  elsif @fan >= 5 || (@fan >= 4 && @fu >= 40) || (@fan >= 3 && @fu >= 70)
    @base_points = 2000
  else
    @base_points = @fu * (2 ** (@fan + 2))
  end
  
  if hora_type == :ron
    @oya_payment = @ko_payment = @points =
        ceil_points(@base_points * (oya ? 6 : 4))
  else
    if oya
      @ko_payment = ceil_points(@base_points * 2)
      @oya_payment = 0
      @points = @ko_payment * 3
    else
      @oya_payment = ceil_points(@base_points * 2)
      @ko_payment = ceil_points(@base_points)
      @points = @oya_payment + @ko_payment * 2
    end
  end
  
end

Instance Attribute Details

#fuObject (readonly)

Returns the value of attribute fu.



72
73
74
# File 'lib/mjai/hora.rb', line 72

def fu
  @fu
end

#ko_paymentObject (readonly)

Returns the value of attribute ko_payment.



72
73
74
# File 'lib/mjai/hora.rb', line 72

def ko_payment
  @ko_payment
end

#oya_paymentObject (readonly)

Returns the value of attribute oya_payment.



72
73
74
# File 'lib/mjai/hora.rb', line 72

def oya_payment
  @oya_payment
end

#pointsObject (readonly)

Returns the value of attribute points.



72
73
74
# File 'lib/mjai/hora.rb', line 72

def points
  @points
end

#yakuObject (readonly)

Returns the value of attribute yaku.



72
73
74
# File 'lib/mjai/hora.rb', line 72

def yaku
  @yaku
end

Instance Method Details

#ceil_points(points) ⇒ Object



74
75
76
# File 'lib/mjai/hora.rb', line 74

def ceil_points(points)
  return (points / 100.0).ceil * 100
end