|
|
|
|
@ -5,13 +5,13 @@ import android.graphics.* |
|
|
|
|
import androidx.core.content.res.ResourcesCompat |
|
|
|
|
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory |
|
|
|
|
import net.pokeranalytics.android.R |
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Position |
|
|
|
|
import net.pokeranalytics.android.model.handhistory.Street |
|
|
|
|
import net.pokeranalytics.android.model.realm.handhistory.Card |
|
|
|
|
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
|
|
|
|
import net.pokeranalytics.android.util.RANDOM_PLAYER |
|
|
|
|
import net.pokeranalytics.android.util.extensions.formatted |
|
|
|
|
import timber.log.Timber |
|
|
|
|
|
|
|
|
|
data class ChipColor(val fillColor: Int, val borderColor: Int) { |
|
|
|
|
companion object { |
|
|
|
|
@ -106,20 +106,12 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
initializeTable(config, canvas, context) |
|
|
|
|
|
|
|
|
|
val step = config.currentStep |
|
|
|
|
var computedAction: ComputedAction? = null |
|
|
|
|
val street = when (step) { |
|
|
|
|
is Street -> step |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
computedAction = step |
|
|
|
|
step.street |
|
|
|
|
} |
|
|
|
|
else -> throw PAIllegalStateException("Step unmanaged: $step") |
|
|
|
|
} |
|
|
|
|
val street = step.street |
|
|
|
|
|
|
|
|
|
val computedAction = step as? ComputedAction? |
|
|
|
|
|
|
|
|
|
// draw pot |
|
|
|
|
drawPot(street, computedAction, config, canvas, context) |
|
|
|
|
// val potAction = computedAction ?: config.lastActionBeforeStreet(street) |
|
|
|
|
// potAction?.let { drawPot(potAction, config, canvas, context) } |
|
|
|
|
|
|
|
|
|
// draw board |
|
|
|
|
drawBoardCards(street, config, canvas, context) |
|
|
|
|
@ -159,45 +151,65 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
private fun drawPlayerChips(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
when (config.currentStep) { |
|
|
|
|
is Street -> { // animate chips |
|
|
|
|
if (!config.isLastFrame) { |
|
|
|
|
lastCommitedAmount(i, config)?.let { amount -> |
|
|
|
|
val color = colorForAmount(amount) |
|
|
|
|
val circle = config.animatedChipCircle(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
is Street -> { |
|
|
|
|
when (config.frameType) { |
|
|
|
|
ReplayerConfiguration.FrameType.STATE -> {} |
|
|
|
|
ReplayerConfiguration.FrameType.GATHER_ANIMATION -> { |
|
|
|
|
lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
val color = colorForAmount(amount) |
|
|
|
|
val circle = config.animatedChipCircleToPot(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> { |
|
|
|
|
Timber.d("won pots = ${config.handHistory.winnerPots}") |
|
|
|
|
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i } |
|
|
|
|
winnerPots?.let { pot -> |
|
|
|
|
val color = colorForAmount(pot.amount) |
|
|
|
|
val circle = config.animatedChipCircleFromPot(i) |
|
|
|
|
drawChipCircle(circle, color, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
is ComputedAction -> { |
|
|
|
|
drawChipForAction(i, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// is HandStep.GatherChips -> { |
|
|
|
|
// lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
// val color = colorForAmount(amount) |
|
|
|
|
// val circle = config.animatedChipCircleToPot(i) |
|
|
|
|
// drawChipCircle(circle, color, canvas, context) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// is HandStep.DistributeChips -> { |
|
|
|
|
// config.handHistory.winnerPots.firstOrNull { it.position == i }?.let { pot -> |
|
|
|
|
// val color = colorForAmount(pot.amount) |
|
|
|
|
// val circle = config.animatedChipCircleFromPot(i) |
|
|
|
|
// drawChipCircle(circle, color, canvas, context) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// is Street -> { // animate chips |
|
|
|
|
// if (!config.isLastFrame) { |
|
|
|
|
// lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
// val color = colorForAmount(amount) |
|
|
|
|
// val circle = config.animatedChipCircle(i) |
|
|
|
|
// drawChipCircle(circle, color, canvas, context) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawChipForAction(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
lastCommitedAmount(i, config)?.let { amount -> |
|
|
|
|
lastCommittedAmount(i, config)?.let { amount -> |
|
|
|
|
drawChip(amount, i, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// config.lastChipCommittingActionOfPlayer(i)?.let { action -> |
|
|
|
|
// when { |
|
|
|
|
// action.action.type?.isSignificant == true -> { |
|
|
|
|
// action.action.amount?.let { amount -> |
|
|
|
|
// drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// action.action.type?.isCall == true -> { |
|
|
|
|
// action.getStreetLastSignificantAction()?.action?.amount?.let { amount -> |
|
|
|
|
// drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// else -> {} |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun lastCommitedAmount(i: Int, config: ReplayerConfiguration): Double? { |
|
|
|
|
private fun lastCommittedAmount(i: Int, config: ReplayerConfiguration): Double? { |
|
|
|
|
var committingAction = config.lastChipCommittingActionOfPlayer(i) |
|
|
|
|
if (committingAction?.action?.type?.isCall == true) { |
|
|
|
|
committingAction = committingAction.getStreetLastSignificantAction() |
|
|
|
|
@ -420,13 +432,11 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// when the step is the street, we wait for the last frame to display the board |
|
|
|
|
if ((config.currentStep == street && config.isLastFrame) || config.currentStep != street) { |
|
|
|
|
|
|
|
|
|
val cards = config.handHistory.cardsForStreet(street) |
|
|
|
|
config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF -> |
|
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if ((config.currentStep == street && config.isLastFrame) || config.currentStep != street) { |
|
|
|
|
// } |
|
|
|
|
val cards = config.handHistory.cardsForStreet(street) |
|
|
|
|
config.boardCardRects.take(street.totalBoardCards).forEachIndexed { index, rectF -> |
|
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|