Skip to content

Instantly share code, notes, and snippets.

@apeiros
Last active November 24, 2017 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apeiros/807be6640d3ea4af6607e367f17de3dc to your computer and use it in GitHub Desktop.
Save apeiros/807be6640d3ea4af6607e367f17de3dc to your computer and use it in GitHub Desktop.
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