Class: Improvement

Inherits:
ApplicationRecord show all
Defined in:
app/models/improvement.rb

Overview

Improvements are associated with Playbooks These are the options the Hunter can choose from when upgrading their character.

Schema Information

Table name: improvements

Indexes

index_improvements_on_playbook_id  (playbook_id)

Foreign Keys

fk_rails_...  (playbook_id => playbooks.id)

Constant Summary collapse

IMPROVEMENT_TYPES =
%w[Improvement
Improvements::AdvancedMove
Improvements::AnotherMove
Improvements::ChangePlaybook
Improvements::GainLuck
Improvements::HavenMove
Improvements::PlaybookMove
Improvements::RatingBoost
Improvements::Retire].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#advancedBoolean

Returns:

  • (Boolean)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#created_atTime

Returns:

  • (Time)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#descriptionString

Returns:

  • (String)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#idObject

Returns [].

Returns:


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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#playbook_idObject

Returns [].

Returns:


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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#ratingInteger

Returns:

  • (Integer)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#stat_limitInteger

Returns:

  • (Integer)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#typeString

Returns:

  • (String)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

#updated_atTime

Returns:

  • (Time)

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
# File 'app/models/improvement.rb', line 37

class Improvement < ApplicationRecord
  IMPROVEMENT_TYPES = %w[Improvement
                         Improvements::AdvancedMove
                         Improvements::AnotherMove
                         Improvements::ChangePlaybook
                         Improvements::GainLuck
                         Improvements::HavenMove
                         Improvements::PlaybookMove
                         Improvements::RatingBoost
                         Improvements::Retire].freeze

  belongs_to :playbook

  enum rating: { charm: 0, cool: 1, sharp: 2, tough: 3, weird: 4 }

  scope :advanced, -> { where(advanced: true) }
  scope :not_advanced, -> { where(advanced: [nil, false]) }

  validates :description, presence: true
  validates :type, inclusion: { in: IMPROVEMENT_TYPES }, allow_blank: true

  # This is the Pundit Policy that governs Improvement access
  #
  # @see ApplicationPolicy
  def self.policy_class
    ApplicationPolicy
  end

  # Determines if a hunter is eligible for Advanced Improvements
  #
  # @param hunter [Hunter] check this hunter's eligiblity
  def self.advanced_eligible?(hunter)
    hunter.hunters_improvements.size >= 5
  end

  def improvable_options(_hunter)
    {}
  end
end

Class Method Details

.advanced_eligible?(hunter) ⇒ Boolean

Determines if a hunter is eligible for Advanced Improvements

Parameters:

  • hunter (Hunter)

    check this hunter's eligiblity

Returns:

  • (Boolean)

68
69
70
# File 'app/models/improvement.rb', line 68

def self.advanced_eligible?(hunter)
  hunter.hunters_improvements.size >= 5
end

.policy_classObject

This is the Pundit Policy that governs Improvement access

See Also:


61
62
63
# File 'app/models/improvement.rb', line 61

def self.policy_class
  ApplicationPolicy
end

Instance Method Details

#improvable_options(_hunter) ⇒ Object


72
73
74
# File 'app/models/improvement.rb', line 72

def improvable_options(_hunter)
  {}
end