Skip to content

Instantly share code, notes, and snippets.

@benphelps
Created August 29, 2012 03:12
Show Gist options
  • Save benphelps/3506436 to your computer and use it in GitHub Desktop.
Save benphelps/3506436 to your computer and use it in GitHub Desktop.
class ArmorItem < ActiveRecord::Base
attr_accessible :armor_tier_id, :bonus_id, :enchant_id, :name, :stat_set_id
belongs_to :armor_tier
belongs_to :enchant
belongs_to :bonus
belongs_to :stat_set
attr_reader :stat, :agility, :stamina, :strength, :intellect
def stat
StatSet.find(stat_set_id)
end
def agility
ArmorTier.find(armor_tier_id).stat.agility + StatSet.find(stat_set_id).agility
end
def stamina
ArmorTier.find(armor_tier_id).stat.stamina + StatSet.find(stat_set_id).stamina
end
def strength
ArmorTier.find(armor_tier_id).stat.strength + StatSet.find(stat_set_id).strength
end
def intellect
ArmorTier.find(armor_tier_id).stat.intellect + StatSet.find(stat_set_id).intellect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment