Skip to content

Instantly share code, notes, and snippets.

View benphelps's full-sized avatar
🇺🇦
Slava Ukrayini!

Ben Phelps benphelps

🇺🇦
Slava Ukrayini!
View GitHub Profile
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
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
class Armor < ActiveRecord::Base
attr_accessible :back_id, :character_id, :chest_id, :feet_id, :hands_id, :head_id, :legs_id, :shoulder_id, :waist_id, :finger_id
belongs_to :character
attr_reader :back, :chest, :feet, :hands, :head, :legs, :shoulder, :waist, :finger
def hands
ArmorItem.find(hands_id)
end
Character
Armor
Armor Item
Item Tier (Base stats all tier items share)
Item (Specific item stats)
Item Bonus (Bonus stats added via other means)
Enchant (Bonus stats added via an enchant)
Enchant + Bonus + Item + Tier = Item stats
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
class Armor < ActiveRecord::Base
attr_accessible :back_id, :character_id, :chest_id, :feet_id, :hands_id, :head_id, :legs_id, :shoulder_id, :waist_id, :finger_id
belongs_to :character
[:back, :chest, :feet, :hands, :head, :legs, :shoulder, :waist, :finger].each do |part|
belongs_to part, :class_name => 'ArmorItem'
define_method part do
# what do I place here? I'm using :class_name to route it to an ArmorItem
ArmorItem.find(:part[_id])
class Armor < ActiveRecord::Base
attr_accessible :back_id, :character_id, :chest_id, :feet_id, :hands_id, :head_id, :legs_id, :shoulder_id, :waist_id, :finger_id
belongs_to :character
[:back, :chest, :feet, :hands, :head, :legs, :shoulder, :waist, :finger].each do |part|
belongs_to part, :class_name => 'ArmorItem'
end
end
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
def stat
StatSet.find(stat_set_id)
<div class="armor">
<% @armor.each do |a| if a != nil then %>
<div class="armor-item">
<h1><%= a.name %> <%= a.armor_tier.name %></h1>
<span class="stat-bonus"><%= a.stat.agility %> Agility</span>
<span class="stat-bonus"><%= a.stat.stamina %> Stamina</span>
<span class="stat-bonus"><%= a.stat.strength %> Strength</span>
<span class="stat-bonus"><%= a.stat.intellect %> Strength</span>
<span class="stat-level">Level <%= a.armor_tier.level %></span>
</div>
DEPRECATION WARNING: Database connections will not be closed automatically, please close your database connection at the end of the thread by calling `close` on your connection. For example: ActiveRecord::Base.connection.close