Show action amounts

hh
Laurent 5 years ago
parent 51b8482c6e
commit d60dcbb69f
  1. 8
      app/src/main/java/net/pokeranalytics/android/model/realm/handhistory/Action.kt
  2. 51
      app/src/main/java/net/pokeranalytics/android/ui/modules/handhistory/replayer/TableDrawer.kt

@ -243,4 +243,12 @@ open class Action : RealmObject() {
}
}
val displayedAmount: Double?
get() {
if (this.type?.isCall == true) {
return this.effectiveAmount
}
return this.amount
}
}

@ -8,7 +8,6 @@ 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.Action
import net.pokeranalytics.android.model.realm.handhistory.Card
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction
import net.pokeranalytics.android.util.RANDOM_PLAYER
@ -77,31 +76,31 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
initializeTable(config, canvas, context)
val step = config.currentStep
val street: Street
var computedAction: ComputedAction? = null
when (step) {
is Street -> {
street = step
config.lastActionBeforeStreet(street)?.let {
drawPot(it, config, canvas, context)
}
}
val street = when (step) {
is Street -> step
is ComputedAction -> {
street = step.street
computedAction = step
drawPot(step, config, canvas, context)
step.street
}
else -> throw PAIllegalStateException("Step unmanaged: $step")
}
// draw pot
val potAction = computedAction ?: config.lastActionBeforeStreet(street)
potAction?.let { drawPot(potAction, config, canvas, context) }
// draw board
drawBoardCards(street, config, canvas, context)
// draw player shapes and chips
val hh = config.handHistory
for (i in 0 until hh.numberOfPlayers) {
drawPlayerShapes(i, computedAction, config, canvas, context)
drawPlayerChips(i, config, canvas, context)
}
// show player cards
// draw player cards
config.activePositions.forEach {
drawCards(it, config, canvas, context)
}
@ -111,10 +110,9 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
private fun drawPlayerShapes(i: Int, computedAction: ComputedAction?, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
// draw player rectangles with action or name + stack
val actionType = computedAction?.action?.type
if (computedAction?.positionIndex == i && actionType != null) {
if (computedAction?.positionIndex == i) {
drawPlayerRectangle(i, true, config, canvas, context)
drawAction(i, actionType, config, canvas, context)
drawAction(i, computedAction, config, canvas, context)
} else {
val remainingStack = config.playerRemainingStack(i)
drawPlayerRectangle(i, false, config, canvas, context)
@ -341,11 +339,26 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) {
}
private fun drawAction(i: Int, type: Action.Type, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
val pnPoint = config.pointForPlayerAction(i)
this.textPaint.textSize = pnPoint.fontSize
private fun drawAction(i: Int, action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) {
action.action.type?.let { type ->
val actionName = context.getString(type.resId)
canvas.drawText(actionName, pnPoint.x, pnPoint.y, this.textPaint)
val actionPoint: ReplayerConfiguration.TextPoint
if (!type.isPassive) { // show action + amount
actionPoint = config.pointForPlayerName(i)
action.action.displayedAmount?.let { amount ->
val amountPoint = config.pointForPlayerStack(i)
this.textPaint.textSize = amountPoint.fontSize
canvas.drawText(amount.formatted, amountPoint.x, amountPoint.y, this.textPaint)
}
} else { // show action name only
actionPoint = config.pointForPlayerAction(i)
}
this.textPaint.textSize = actionPoint.fontSize
canvas.drawText(actionName, actionPoint.x, actionPoint.y, this.textPaint)
}
}
private fun drawBoardCards(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) {

Loading…
Cancel
Save