Skip to content

Commit

Permalink
Refactor: Modify access controls #26
Browse files Browse the repository at this point in the history
  • Loading branch information
jinios committed May 14, 2018
1 parent 414db39 commit a95f8d5
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions CardGameApp/CardGameApp/DelegateModel/DeckManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
Expand Down
6 changes: 2 additions & 4 deletions CardGameApp/CardGameApp/DelegateModel/StackManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

class WholeStackManager: CardStackDelegate,Stackable {
var stackManagers: [StackDelegate]!
private var stackManagers: [StackDelegate]!

init(stacks: [CardStack]) {
var stackManagers = [StackDelegate]()
Expand Down
2 changes: 1 addition & 1 deletion CardGameApp/CardGameApp/Model/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Card: CustomStringConvertible, Comparable, Hashable, ImageSelector {
}
}

var backImage = "card-back"
let backImage = "card-back"

var frontImage: String {
var shape = ""
Expand Down
6 changes: 3 additions & 3 deletions CardGameApp/CardGameApp/View/CardDeckView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions CardGameApp/CardGameApp/View/CardImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 10 additions & 7 deletions CardGameApp/CardGameApp/View/CardStacksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -105,5 +104,9 @@ class OneStack: UIView {
}
}

func getColumn() -> Int {
return self.column
}

}

6 changes: 3 additions & 3 deletions CardGameApp/CardGameApp/View/FoundationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion CardGameApp/CardGameApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a95f8d5

Please sign in to comment.