|
|
|
|
@ -511,9 +511,13 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
* Adds a card with the selected [value] |
|
|
|
|
*/ |
|
|
|
|
fun cardValueSelected(value: Card.Value) { |
|
|
|
|
this.lastValue = value |
|
|
|
|
|
|
|
|
|
val row = this.rowRepresentables[this.currentSelection.index] as CardsRow |
|
|
|
|
if (isValueAvailable(value)) { |
|
|
|
|
row.valueSelected(value) |
|
|
|
|
} else { |
|
|
|
|
row.valueSelected(Card.Value.undefined) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
@ -523,17 +527,19 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
fun cardSuitSelected(suit: Card.Suit) { |
|
|
|
|
|
|
|
|
|
val row = this.rowRepresentables[this.currentSelection.index] as CardsRow |
|
|
|
|
val card = row.lastCardForSelectedSuit() |
|
|
|
|
if (card == null || isSuitAvailable(suit, card.value)) { |
|
|
|
|
row.suitSelected(suit) |
|
|
|
|
|
|
|
|
|
// TODO do we want to store the information right now ? |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
row.suitSelected(Card.Suit.UNDEFINED) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Deletes all the card of the selected street |
|
|
|
|
*/ |
|
|
|
|
fun clearCards() { |
|
|
|
|
this.lastValue = null |
|
|
|
|
// this.lastValue = null |
|
|
|
|
val row = this.rowRepresentables[this.currentSelection.index] as CardsRow |
|
|
|
|
row.clear() |
|
|
|
|
} |
|
|
|
|
@ -602,7 +608,7 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
/*** |
|
|
|
|
* The value of the last chosen card |
|
|
|
|
*/ |
|
|
|
|
private var lastValue: Card.Value? = null |
|
|
|
|
// private var lastValue: Card.Value? = null |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Returns true if the card [value] is available |
|
|
|
|
@ -615,8 +621,8 @@ class HandHistoryViewModel : ViewModel(), RowRepresentableDataSource, CardCentra |
|
|
|
|
/*** |
|
|
|
|
* Returns true if the [suit] is available for the given [value] |
|
|
|
|
*/ |
|
|
|
|
override fun isSuitAvailable(suit: Card.Suit, value: Card.Value?): Boolean { |
|
|
|
|
val usedValues = this.usedCards.filter { it.value == value?.value } |
|
|
|
|
override fun isSuitAvailable(suit: Card.Suit, value: Int?): Boolean { |
|
|
|
|
val usedValues = this.usedCards.filter { it.value == value } |
|
|
|
|
return !usedValues.map { it.suit }.contains(suit) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|