Skip to content

Instantly share code, notes, and snippets.

@rodrickbrown
Created July 8, 2014 17:13
Show Gist options
  • Save rodrickbrown/2dd8a1ec1a645b703f4e to your computer and use it in GitHub Desktop.
Save rodrickbrown/2dd8a1ec1a645b703f4e to your computer and use it in GitHub Desktop.
//
// main.swift
// Bukimur
//
// Created by Rodrick Brown on 7/8/14.
// Copyright (c) 2014 Rodrick Brown. All rights reserved.
//
import Foundation
class Bukimur {
var players = 0
var bag: [Dictionary<String, AnyObject>] = []
init(players: Int) {
self.players = players
}
func shuffle<T>() -> [Dictionary<String, AnyObject>] {
for i in 0...bag.count {
let j = Int(arc4random_uniform(UInt32(bag.count - i))) + i
bag.insert(bag.removeAtIndex(j), atIndex: i)
}
return bag
}
func initalizeGame() -> Bool {
let decks = [0,1]
let colors = ["yellow", "black", "red", "blue"]
let numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13]
for color in colors {
for deck in decks {
for num in numbers {
bag.append(["color": color, "deck": deck, "number": num])
}
}
}
self.shuffle()
if bag.count != 104 {
return false
}
return true
}
}
var game = Bukimur(players: 4)
game.initalizeGame()
println(game.bag[0])
println(game.bag.count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment