Created
August 29, 2012 04:00
-
-
Save benphelps/3506669 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| end | |
| [:agility, :stamina, :strength, :intellect].each do |stat| | |
| define_method stat do | |
| armor_tier.stat.send(stat) + stat_set.send(stat) | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArmorMaterial < ActiveRecord::Base | |
| attr_accessible :name | |
| has_many :armor_tiers | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArmorTier < ActiveRecord::Base | |
| attr_accessible :level, :name, :deviation, :stat_set_id, :armor_material_id | |
| belongs_to :armor_material | |
| belongs_to :stat_set | |
| attr_reader :stat | |
| def stat | |
| StatSet.find(stat_set_id) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Bonus < ActiveRecord::Base | |
| attr_accessible :name | |
| has_many :stat_set | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Character < ActiveRecord::Base | |
| attr_accessible :level, :name | |
| belongs_to :order | |
| belongs_to :user | |
| has_one :armor | |
| [:agility, :stamina, :strength, :intellect].each do |stat| | |
| define_method stat do | |
| armor_tier.stat.stat) + stat_set.send(stat) | |
| (level.to_f * order.send(stat)).round | |
| end | |
| end | |
| def health | |
| ((level.to_f * 10) + (order.stamina * level.to_f)).round | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment