diff --git a/app/src/main/java/net/pokeranalytics/android/model/handhistory/BoardManager.kt b/app/src/main/java/net/pokeranalytics/android/model/handhistory/BoardManager.kt deleted file mode 100644 index 1a4080b1..00000000 --- a/app/src/main/java/net/pokeranalytics/android/model/handhistory/BoardManager.kt +++ /dev/null @@ -1,80 +0,0 @@ -package net.pokeranalytics.android.model.handhistory - -import net.pokeranalytics.android.exceptions.PAIllegalStateException -import net.pokeranalytics.android.model.realm.handhistory.Card - -/*** - * An interface used for board changes notifications - */ -interface BoardChangedListener { - fun boardChanged() -} - -/*** - * The BoardManager purpose is to manage the cards from a hand history board - * and notify its listener when a change occurs - */ -class BoardManager(cards: List, var listener: BoardChangedListener) { - - /*** - * The sorted list of cards - */ - private var sortedBoardCards: MutableList = mutableListOf() - - /*** - * All cards - */ - val allCards: List - get() { - return this.sortedBoardCards - } - - init { - this.sortedBoardCards = cards.sortedBy { it.index }.toMutableList() - } - - /*** - * Adds a card to the board, notifies the listener - */ - fun add(card: Card) { - - this.sortedBoardCards.lastOrNull()?.let { - if (it.suit == null) { - it.suit = Card.Suit.UNDEFINED - } - } - - if (this.sortedBoardCards.size == 5) { - throw PAIllegalStateException("Can't add anymore cards") - } - - card.index = this.sortedBoardCards.size - - this.sortedBoardCards.add(card) - this.listener.boardChanged() - } - - /*** - * Clears the street's cards, notifies the listener - */ - fun clearStreet(street: Street) { - this.sortedBoardCards.removeAll { it.street == street } - this.listener.boardChanged() - } - - /*** - * Returns the last card of a given [street] - */ - fun lastCard(street: Street) : Card? { - return this.sortedBoardCards.lastOrNull { it.street == street } - } - - /*** - * Remove the given [card], notifies the listener - */ - fun remove(card: Card) { - this.sortedBoardCards.remove(card) - this.listener.boardChanged() - } - -} \ No newline at end of file