Created
March 26, 2013 07:19
-
-
Save RyanScottLewis/5243660 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
object Character | |
object Statistics | |
attribute accessor character, type: Float, default: 1.0 | |
object PrimaryStatistics < Statistics | |
attribute accessor strength , type: Float, default: 1.0 | |
attribute accessor perception , type: Float, default: 1.0 | |
attribute accessor endurance , type: Float, default: 1.0 | |
attribute accessor charisma , type: Float, default: 1.0 | |
attribute accessor intelligence, type: Float, default: 1.0 | |
attribute accessor agility , type: Float, default: 1.0 | |
attribute accessor luck , type: Float, default: 1.0 | |
object DerivedStatistics < Statistics | |
attribute accessor hit_points, default: -> { 95 + (character.endurance * 20) } | |
attribute reader carry_weight, default: -> { 150 + (character.strength * 10) } | |
attribute reader melee_damage, default: -> { 95 + (character.strength / 2) } | |
attribute reader reload_speed, default: -> { character.agility < 5 ? character.agility / 10 : 0.5 } | |
alias hit_points as hp | |
attribute accessor name, type: String, default: 'Player' | |
attribute reader primary_statistics, type: PrimaryStatistics, default: -> { PrimaryStatistics.new } | |
attribute reader derived_statistics, type: DerivedStatistics, default: -> { DerivedStatistics.new } | |
delegate strength, perception, endurance, charisma, intelligence, agility, luck to primary_statistics | |
delegate hit_points, hp, carry_weight, melee_damage, reload_speed to derived_statistics | |
method attack(character <Character>) | |
force = strength * luck.random_between(0) | |
character.attacked_by( character: self, force: force ) | |
method attacked_by(character <Character>, force <Float>) | |
hp -= force * luck.random_between(luck/2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment