Skip to content

Instantly share code, notes, and snippets.

@apeiros apeiros/char_stats.rb
Last active Nov 24, 2017

Embed
What would you like to do?
Stats = Struct.new(:strength, :dexterity, :endurance, :intelligence, :education, :social_status) do
def self.random(min: 5, max: 10)
new(*Array.new(6) { rand(min..max) })
end
def +(other)
self.class.new(
strength+other.strength,
dexterity+other.dexterity,
endurance+other.endurance,
intelligence+other.intelligence,
education+other.education,
social_status+other.social_status,
)
end
end
roll = Stats.random
mod = Stats.new(0,0,1,2,0,1)
after_career = roll + mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.