daviscodesbugs / gamepiece-json

A collection of json files describing the pieces of board games
GNU General Public License v3.0
12 stars 33 forks source link

Add Blink definition #51

Closed schmich closed 7 years ago

schmich commented 7 years ago

Sources: Amazon, BGG, and my own copy.

All cards in Blink are unique. There are 6 colors, 6 shapes, and 1-5 objects on a card, so you'd expect 6 * 6 * 5 = 180 cards, but there are only 60, so they don't include every color-shape-number combination.

I recorded the cards by hand and used a script to translate them to JSON.

require 'json'
require 'set'

cards = %w(
  3rb 3bc 1gc 1ys 4ed 2us 1yt 2gb 5gb 3bf 2rb 2yc 5rc 2yd 5ut
  1ec 3ed 3rs 5ef 1eb 3yb 5bs 3yf 1rd 2es 4us 5ud 3ud 2bd 4rt
  1ub 4ys 4yc 5rf 4rf 5yt 2gf 2ef 1bf 4gd 1bs 4bt 5es 2bt 4ec
  2ut 5bb 2rc 3uc 5yd 1uf 4ub 4gf 3gt 5gc 4bb 1rt 3gs 3et 1gd
)

raise 'Invalid data.' if Set.new(cards).count != 60

colors = {
  b: 'brown',
  r: 'red',
  g: 'gray',
  y: 'yellow',
  e: 'green',
  u: 'blue'
}

shapes = {
  c: 'crescent',
  b: 'bolt',
  s: 'star',
  d: 'droplet',
  f: 'flower',
  t: 'triangle'
}

cards = cards.map do |c|
  num, color, shape = c[0].to_i, colors[c[1].to_sym], shapes[c[2].to_sym]
  raise 'Invalid data.' if !color || !shape || num < 1 || num > 5
  { color: color, shape: shape, number: num, count: 1 }
end.sort_by { |c| [c[:color], c[:shape], c[:number]] }

puts JSON.pretty_generate(cards, indent: '    ')
daviscodesbugs commented 7 years ago

Very impressive! :+1: Merging.