I have an array called shuffledDeck that holds 52 Int numbers shuffled I want to deal to each player individually
func dealCards1(){
for i in 0...25{
comp1PlayDeck += shuffledDeck[i]
}
}
Not quite sure what I should return I am doing this to learn not for anything important just wondering what I should do for the function declaration for exmp
func dealCards1(Int: Array) -> Int: Array{}
Im not sure how to return the array any help would be appreciated thank you! :D here is the full code so far
import Foundation
let comp1 = 1
let comp2 = 2
var dealDeck = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]
var shuffledDeck: [Int]
var comp1PlayDeck = [Int]()
var comp2PlayDeck: [Int]
var comp1WinDeck: [Int]
var comp2WinDeck: [Int]
var comp1CurrCard: Int
var comp2CurrCard: Int
//functions
//shuffles cards from dealDeck returns to shuffledDeck
func shuffle<T>(var list: Array<T>) -> Array<T> {
for i in 0..<list.count {
let j = Int(arc4random_uniform(UInt32(list.count - i))) + i
list.insert(list.removeAtIndex(j), atIndex: i)
}
return list
}
//shuffle deck
shuffledDeck = shuffle(dealDeck)
for num in shuffledDeck {
println(num)
}
//deals to player one
func dealCards1() -> [Int] {
for i in 0...25{
comp1PlayDeck += shuffledDeck[i]
}
return comp1PlayDeck
}
//deals to player two
func dealCards2(){
}
comp1PlayDeck = dealCards1()