diff --git a/CardGameApp/CardGameApp/DelegateModel/DeckManager.swift b/CardGameApp/CardGameApp/DelegateModel/DeckManager.swift index 87143ee8..2838b4fd 100644 --- a/CardGameApp/CardGameApp/DelegateModel/DeckManager.swift +++ b/CardGameApp/CardGameApp/DelegateModel/DeckManager.swift @@ -9,8 +9,8 @@ import Foundation class DeckManager: CardDeckDelegate { - var deck: CardDeck! - var openedDeck = [Card]() + private var deck: CardDeck! + private var openedDeck = [Card]() init(deck: CardDeck) { self.deck = deck diff --git a/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift b/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift index 5adef998..07adb0b8 100644 --- a/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift +++ b/CardGameApp/CardGameApp/DelegateModel/FoundationDelegate.swift @@ -9,9 +9,8 @@ import Foundation class FoundationManager: FoundationDelegate, Stackable { - static let range: CountableRange = 0..<4 - var foundations = [CardStack]() + private var foundations = [CardStack]() var lastCards: [Card?] { return foundations.map{ $0.last() } } diff --git a/CardGameApp/CardGameApp/DelegateModel/StackManager.swift b/CardGameApp/CardGameApp/DelegateModel/StackManager.swift index 63d5ca37..1d524e26 100644 --- a/CardGameApp/CardGameApp/DelegateModel/StackManager.swift +++ b/CardGameApp/CardGameApp/DelegateModel/StackManager.swift @@ -9,14 +9,12 @@ import Foundation class StackManager: StackDelegate { - private static var stackDelegates = [StackManager]() - + private var column: Int! + private var stack: CardStack! private var lastCard: Card? { return self.stack.last() } - private var column: Int! - private var stack: CardStack! init(oneStack: CardStack, column: Int) { self.stack = oneStack diff --git a/CardGameApp/CardGameApp/DelegateModel/WholeStackManager.swift b/CardGameApp/CardGameApp/DelegateModel/WholeStackManager.swift index be84fd7f..9b584296 100644 --- a/CardGameApp/CardGameApp/DelegateModel/WholeStackManager.swift +++ b/CardGameApp/CardGameApp/DelegateModel/WholeStackManager.swift @@ -9,7 +9,7 @@ import Foundation class WholeStackManager: CardStackDelegate,Stackable { - var stackManagers: [StackDelegate]! + private var stackManagers: [StackDelegate]! init(stacks: [CardStack]) { var stackManagers = [StackDelegate]() diff --git a/CardGameApp/CardGameApp/Model/Card.swift b/CardGameApp/CardGameApp/Model/Card.swift index 0f24f4bf..ba9bc2b2 100644 --- a/CardGameApp/CardGameApp/Model/Card.swift +++ b/CardGameApp/CardGameApp/Model/Card.swift @@ -34,7 +34,7 @@ class Card: CustomStringConvertible, Comparable, Hashable, ImageSelector { } } - var backImage = "card-back" + let backImage = "card-back" var frontImage: String { var shape = "" diff --git a/CardGameApp/CardGameApp/View/CardDeckView.swift b/CardGameApp/CardGameApp/View/CardDeckView.swift index 1ad94018..c8a1bc49 100644 --- a/CardGameApp/CardGameApp/View/CardDeckView.swift +++ b/CardGameApp/CardGameApp/View/CardDeckView.swift @@ -9,9 +9,9 @@ import UIKit class CardDeckView: UIView { - var gameManager: CardGameDelegate = CardGameManager.shared() - var closedCardDeck = CardImageView() - var deckManager: CardDeckDelegate! + private var gameManager: CardGameDelegate = CardGameManager.shared() + private var closedCardDeck = CardImageView() + private var deckManager: CardDeckDelegate! var lastCardView: CardImageView? { guard let lastView = subviews.last else { return nil } return lastView as? CardImageView diff --git a/CardGameApp/CardGameApp/View/CardImageView.swift b/CardGameApp/CardGameApp/View/CardImageView.swift index 0fe404ea..d76b352e 100644 --- a/CardGameApp/CardGameApp/View/CardImageView.swift +++ b/CardGameApp/CardGameApp/View/CardImageView.swift @@ -10,8 +10,8 @@ import UIKit class CardImageView: UIImageView { - var imageName: String! - var card: ImageSelector? + private var imageName: String! + private var card: ImageSelector? override func awakeFromNib() { super.awakeFromNib() diff --git a/CardGameApp/CardGameApp/View/CardStacksView.swift b/CardGameApp/CardGameApp/View/CardStacksView.swift index d8f771a0..3b2bb273 100644 --- a/CardGameApp/CardGameApp/View/CardStacksView.swift +++ b/CardGameApp/CardGameApp/View/CardStacksView.swift @@ -9,9 +9,8 @@ import UIKit class CardStacksView: UIView { - var gameManager: CardGameDelegate = CardGameManager.shared() - var wholeStackManager: (CardStackDelegate & Stackable)! - var oneStackViews = [OneStack]() + private var wholeStackManager: (CardStackDelegate & Stackable)! + private var oneStackViews = [OneStack]() override init(frame: CGRect) { super.init(frame: frame) @@ -21,7 +20,7 @@ class CardStacksView: UIView { convenience init() { self.init(frame: CGRect(x: 0, y: PositionY.bottom.value, width: 414, height: 736 - PositionY.bottom.value)) - self.wholeStackManager = gameManager.getWholeStackDelegate() + self.wholeStackManager = CardGameManager.shared().getWholeStackDelegate() } required init?(coder aDecoder: NSCoder) { @@ -47,9 +46,9 @@ class CardStacksView: UIView { } class OneStack: UIView { - var column: Int! - var wholeStackManager: (CardStackDelegate & Stackable)! - var stackManager: StackDelegate! + private var column: Int! + private var wholeStackManager: (CardStackDelegate & Stackable)! + private var stackManager: StackDelegate! var lastCardView: CardImageView? { guard let lastView = subviews.last else { return nil } return lastView as? CardImageView @@ -105,5 +104,9 @@ class OneStack: UIView { } } + func getColumn() -> Int { + return self.column + } + } diff --git a/CardGameApp/CardGameApp/View/FoundationView.swift b/CardGameApp/CardGameApp/View/FoundationView.swift index 3d8ca963..b6e7f090 100644 --- a/CardGameApp/CardGameApp/View/FoundationView.swift +++ b/CardGameApp/CardGameApp/View/FoundationView.swift @@ -9,9 +9,9 @@ import UIKit class FoundationView: UIView { - let gameManager: CardGameDelegate = CardGameManager.shared() - var foundationManager: FoundationDelegate! - let numberOfFoundation = 4 + private let gameManager: CardGameDelegate = CardGameManager.shared() + private var foundationManager: FoundationDelegate! + private let numberOfFoundation = 4 override init(frame: CGRect) { super.init(frame: frame) diff --git a/CardGameApp/CardGameApp/ViewController.swift b/CardGameApp/CardGameApp/ViewController.swift index 8be0d3a8..93960444 100644 --- a/CardGameApp/CardGameApp/ViewController.swift +++ b/CardGameApp/CardGameApp/ViewController.swift @@ -150,7 +150,7 @@ class ViewController: UIViewController { guard let userInfo = notification.userInfo else { return } guard let from = userInfo["from"] else { return } guard let fromView = from as? OneStack else { return } - let fromIndex = fromView.column! + let fromIndex = fromView.getColumn() let targetCard = fromView.lastCardView! let result = cardGameManager.movableFromStack(from: .fromStack, column: fromIndex)