diff --git a/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift b/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift index 580c918f..52ddc465 100644 --- a/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift +++ b/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift @@ -53,4 +53,8 @@ class FoundationDelegate: FoundationManageable, Stackable { return self.foundations[at.column].getCard(at: at.row) } + func cards(in column: Int) -> [Card] { + return self.foundations[column].getCards() + } + } diff --git a/CardGameApp/CardGameApp/Model/CardStack.swift b/CardGameApp/CardGameApp/Model/CardStack.swift index 0333cfaf..ad237fda 100644 --- a/CardGameApp/CardGameApp/Model/CardStack.swift +++ b/CardGameApp/CardGameApp/Model/CardStack.swift @@ -96,6 +96,9 @@ struct CardStack { return (self.cards.count == 0) } + func getCards()-> [Card] { + return self.cards + } } diff --git a/CardGameApp/CardGameApp/Model/CustomProtocols.swift b/CardGameApp/CardGameApp/Model/CustomProtocols.swift index 9182e277..afef7f91 100644 --- a/CardGameApp/CardGameApp/Model/CustomProtocols.swift +++ b/CardGameApp/CardGameApp/Model/CustomProtocols.swift @@ -46,6 +46,7 @@ protocol CardStackManageable { protocol FoundationManageable { func cardInTurn(at:(column: Int, row: Int)) -> Card func countOfCards(of: Int) -> Int + func cards(in column: Int) -> [Card] } protocol StackManageable { diff --git a/CardGameApp/CardGameApp/View/FoundationView.swift b/CardGameApp/CardGameApp/View/FoundationView.swift index 9cb4af97..98704843 100644 --- a/CardGameApp/CardGameApp/View/FoundationView.swift +++ b/CardGameApp/CardGameApp/View/FoundationView.swift @@ -45,23 +45,19 @@ class FoundationView: UIView { func redraw() { self.subviews.forEach({ $0.removeFromSuperview() }) - for i in FoundationDelegate.range { let newOrigin = CGPoint(x: PositionX.allValues[i].value, y: PositionY.upper.value) let frameForDraw = CGRect(origin: newOrigin, size: ViewController.cardSize) - if foundationManager.countOfCards(of: i) == 0 { self.drawEmptyDock(in: frameForDraw) } else { - for j in 0..