Created
August 9, 2012 01:47
-
-
Save Breefield/3300251 to your computer and use it in GitHub Desktop.
Make a Tile Layout
This file contains 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
def generate_tiles | |
# Pass the number of tiles into the main hash | |
tiles = { | |
ore: 3, # Ore | |
brick: 3, # Brick | |
wheat: 4, # Wheat | |
lumber: 4, # Trees | |
wool: 4, # Wool, Robber | |
robber: 1}.map { |k, v| | |
# After creating tile count, lets map them | |
# Object in what looks like an object, this is correct | |
# So we create a new array the number of times we specified in the tiles hash | |
# We store an object inside, with the key "kind" who's value is the key we're listing out | |
Array.new(v){{kind: k}} | |
# After that, we flatten that into one array, no more multidimensional array | |
# Then shuffle it so our board is unique | |
}.flatten.shuffle | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment