Chip distribution test and fix

hh
Laurent 5 years ago
parent 2e73896659
commit 70b1324fdd
  1. 4
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/ReplayerConfiguration.kt
  2. 36
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt

@ -44,8 +44,8 @@ class ReplayerConfiguration(var handHistory: HandHistory) {
is Street -> { is Street -> {
when (this.currentFrame) { when (this.currentFrame) {
in (0 until framesForChipsAnimation) -> FrameType.GATHER_ANIMATION in (0 until framesForChipsAnimation) -> FrameType.GATHER_ANIMATION
framesForChipsAnimation -> FrameType.STATE in (framesForChipsAnimation until 2 * framesForChipsAnimation) -> FrameType.DISTRIBUTION_ANIMATION
else -> FrameType.DISTRIBUTION_ANIMATION else -> FrameType.STATE
} }
} }
else -> throw PAIllegalStateException("unmanaged step: $step") else -> throw PAIllegalStateException("unmanaged step: $step")

@ -11,7 +11,6 @@ import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction
import net.pokeranalytics.android.util.RANDOM_PLAYER import net.pokeranalytics.android.util.RANDOM_PLAYER
import net.pokeranalytics.android.util.extensions.formatted import net.pokeranalytics.android.util.extensions.formatted
import timber.log.Timber
data class ChipColor(val fillColor: Int, val borderColor: Int) { data class ChipColor(val fillColor: Int, val borderColor: Int) {
companion object { companion object {
@ -153,7 +152,15 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
when (config.currentStep) { when (config.currentStep) {
is Street -> { is Street -> {
when (config.frameType) { when (config.frameType) {
ReplayerConfiguration.FrameType.STATE -> {} ReplayerConfiguration.FrameType.STATE -> {
if (config.currentStep == Street.SUMMARY) {
val amount = 666.0
val color = colorForAmount(amount)
val circle = config.animatedChipCircleFromPot(i)
drawChipCircle(circle, color, canvas, context)
drawChipText(amount, config.chipText(i), canvas, context)
}
}
ReplayerConfiguration.FrameType.GATHER_ANIMATION -> { ReplayerConfiguration.FrameType.GATHER_ANIMATION -> {
lastCommittedAmount(i, config)?.let { amount -> lastCommittedAmount(i, config)?.let { amount ->
val color = colorForAmount(amount) val color = colorForAmount(amount)
@ -162,13 +169,19 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
} }
} }
ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> { ReplayerConfiguration.FrameType.DISTRIBUTION_ANIMATION -> {
Timber.d("won pots = ${config.handHistory.winnerPots}") val amount = 666.0
val winnerPots = config.handHistory.winnerPots.firstOrNull { it.position == i }
winnerPots?.let { pot -> val color = colorForAmount(amount)
val color = colorForAmount(pot.amount) val circle = config.animatedChipCircleFromPot(i)
val circle = config.animatedChipCircleFromPot(i) drawChipCircle(circle, color, canvas, context)
drawChipCircle(circle, color, canvas, context)
} // 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)
// }
} }
} }
} }
@ -256,14 +269,15 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
} }
private fun drawChip(amount: Double, chipText: ReplayerConfiguration.TextPoint, chipCircle: ReplayerConfiguration.Circle, canvas: Canvas, context: Context) { private fun drawChip(amount: Double, chipText: ReplayerConfiguration.TextPoint, chipCircle: ReplayerConfiguration.Circle, canvas: Canvas, context: Context) {
val color = colorForAmount(amount) val color = colorForAmount(amount)
drawChipCircle(chipCircle, color, canvas, context) drawChipCircle(chipCircle, color, canvas, context)
drawChipText(amount, chipText, canvas, context)
}
private fun drawChipText(amount: Double, chipText: ReplayerConfiguration.TextPoint, canvas: Canvas, context: Context) {
this.textPaint.textSize = chipText.fontSize this.textPaint.textSize = chipText.fontSize
this.textPaint.color = context.getColor(R.color.white) this.textPaint.color = context.getColor(R.color.white)
canvas.drawText(amount.formatted, chipText.x, chipText.y, this.textPaint) canvas.drawText(amount.formatted, chipText.x, chipText.y, this.textPaint)
} }
private fun colorForAmount(amount: Double): ChipColor { private fun colorForAmount(amount: Double): ChipColor {

Loading…
Cancel
Save