|
|
|
|
@ -13,7 +13,6 @@ 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 |
|
|
|
|
|
|
|
|
|
class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
@ -93,7 +92,17 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
|
drawPlayerShapes(i, computedAction, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// show player cards |
|
|
|
|
config.activePositions.forEach { |
|
|
|
|
drawCards(it, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
@ -103,14 +112,20 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
} else { |
|
|
|
|
val remainingStack = config.playerRemainingStack(i) |
|
|
|
|
drawPlayerRectangle(i, false, config, canvas, context) |
|
|
|
|
drawPositionAndStack(i, remainingStack, config, canvas, context) |
|
|
|
|
drawPositionAndStack(i, remainingStack, config, canvas) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// draw chips |
|
|
|
|
// when does a chip appears ? |
|
|
|
|
// when the player has put some money during the current street |
|
|
|
|
config.lastSignificantActionOfPlayer(i)?.let { action -> |
|
|
|
|
drawPlayerChips(i, config, canvas, context) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Draw chips |
|
|
|
|
* A chip should appears when the player has put some money during the current street |
|
|
|
|
*/ |
|
|
|
|
private fun drawPlayerChips(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
config.lastSignificantActionOfPlayer(i)?.let { action -> |
|
|
|
|
when { |
|
|
|
|
action.action.type?.isSignificant == true -> { |
|
|
|
|
action.action.amount?.let { amount -> |
|
|
|
|
@ -125,14 +140,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
else -> {} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// show player cards |
|
|
|
|
config.activePositions.forEach { |
|
|
|
|
drawCards(it, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
@ -147,28 +154,13 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
Timber.d("Getting player $i setup ") |
|
|
|
|
val playerSetup = hh.playerSetupForPosition(i) |
|
|
|
|
|
|
|
|
|
// drawCards(i, config, canvas, context) |
|
|
|
|
drawPlayerRectangle(i,false, config, canvas, context) |
|
|
|
|
// drawPositionAndStack(i, playerSetup?.stack, config, canvas, context) |
|
|
|
|
|
|
|
|
|
drawPlayerCircle(i, config, canvas, context) |
|
|
|
|
|
|
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun drawCards(indexes: List<Int>, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
// val hh = config.handHistory |
|
|
|
|
for (i in indexes) { |
|
|
|
|
drawCards(i, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawDealerButton(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// Dealer button |
|
|
|
|
@ -190,9 +182,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
private fun drawChip(amount: Double, chipText: ReplayerConfiguration.TextPoint, chipCircle: ReplayerConfiguration.Circle, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// clearText(chipText, canvas) |
|
|
|
|
// clearCircle(chipCircle, canvas) |
|
|
|
|
|
|
|
|
|
this.fillPaint.color = context.getColor(R.color.green) |
|
|
|
|
canvas.drawCircle(chipCircle.x, chipCircle.y, chipCircle.radius, this.fillPaint) |
|
|
|
|
this.chipBorderPaint.color = context.getColor(R.color.white) |
|
|
|
|
@ -208,18 +197,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// private fun clearText(textPoint: ReplayerConfiguration.TextPoint, canvas: Canvas) { |
|
|
|
|
// this.clearRect(textPoint.toRect(), canvas) |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// private fun clearCircle(circle: ReplayerConfiguration.Circle, canvas: Canvas) { |
|
|
|
|
// this.clearRect(circle.toRect(), canvas) |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// private fun clearRect(rect: RectF, canvas: Canvas) { |
|
|
|
|
// canvas.drawRect(rect, this.backgroundPaint) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
private fun drawCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
val playerSetup = config.handHistory.playerSetupForPosition(playerIndex) |
|
|
|
|
@ -242,12 +219,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// private fun clearCards(playerIndex: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
// config.cardRects(playerIndex).forEach { |
|
|
|
|
// clearRect(it, canvas) |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
private fun drawCard(card: Card, cardRect: RectF, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
fillPaint.color = context.getColor(R.color.white) |
|
|
|
|
@ -264,44 +235,10 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPlayerPositionAndStack(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
drawPlayerRectangle(action.positionIndex,false, config, canvas, context) |
|
|
|
|
drawPositionAndStack(action.positionIndex, action.stackAfterActing, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawAction(action: ComputedAction, highlighted: Boolean = true, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
// show that action is on the player by highlighting |
|
|
|
|
drawPlayerRectangle(action.positionIndex, highlighted, config, canvas, context) |
|
|
|
|
|
|
|
|
|
// redraw previous player rectangle |
|
|
|
|
action.previousAction?.let { previousAction -> |
|
|
|
|
drawPlayerPositionAndStack(previousAction, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// show action name : call, bet, check... |
|
|
|
|
drawAction(action.positionIndex, action.action.type!!, config, canvas, context) |
|
|
|
|
|
|
|
|
|
// show chips image + text, if applicable |
|
|
|
|
when { |
|
|
|
|
action.action.type?.isSignificant == true -> { |
|
|
|
|
action.action.amount?.let { amount -> |
|
|
|
|
drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
drawPot(action, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
action.action.type?.isCall == true -> { |
|
|
|
|
action.getStreetLastSignificantAction()?.action?.amount?.let { amount -> |
|
|
|
|
drawChip(amount, action.positionIndex, config, canvas, context) |
|
|
|
|
drawPot(action, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// action.action.type == Action.Type.FOLD -> { |
|
|
|
|
// clearCards(action.positionIndex, config, canvas, context) |
|
|
|
|
// private fun drawPlayerPositionAndStack(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
// drawPlayerRectangle(action.positionIndex,false, config, canvas, context) |
|
|
|
|
// drawPositionAndStack(action.positionIndex, action.stackAfterActing, config, canvas, context) |
|
|
|
|
// } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPlayerCircle(i: Int, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
|
|
|
|
|
@ -341,16 +278,26 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
|
|
|
|
|
val color = if (highlighted) R.color.kaki else R.color.green_darker |
|
|
|
|
fillPaint.color = context.getColor(color) |
|
|
|
|
canvas.drawRoundRect(config.stackRectForPlayer(i), rectRadius, rectRadius, this.fillPaint) |
|
|
|
|
canvas.drawRoundRect( |
|
|
|
|
config.stackRectForPlayer(i), |
|
|
|
|
rectRadius, |
|
|
|
|
rectRadius, |
|
|
|
|
this.fillPaint |
|
|
|
|
) |
|
|
|
|
strokePaint.color = context.getColor(R.color.green) |
|
|
|
|
canvas.drawRoundRect(config.stackRectForPlayer(i), rectRadius, rectRadius, this.strokePaint) |
|
|
|
|
canvas.drawRoundRect( |
|
|
|
|
config.stackRectForPlayer(i), |
|
|
|
|
rectRadius, |
|
|
|
|
rectRadius, |
|
|
|
|
this.strokePaint |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if (i == config.handHistory.heroIndex) { // refresh dealer button |
|
|
|
|
drawDealerButton(config, canvas, context) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPositionAndStack(i: Int, stack: Double?, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
private fun drawPositionAndStack(i: Int, stack: Double?, config: ReplayerConfiguration, canvas: Canvas) { |
|
|
|
|
|
|
|
|
|
val hh = config.handHistory |
|
|
|
|
// Player position |
|
|
|
|
@ -382,20 +329,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
drawCard(cards[index], rectF, config, canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Clear all chips |
|
|
|
|
// val hh = config.handHistory |
|
|
|
|
// for (i in 0 until hh.numberOfPlayers) { |
|
|
|
|
// val pc = config.chipCircle(i) |
|
|
|
|
// clearCircle(pc, canvas) |
|
|
|
|
// val pct = config.chipText(i) |
|
|
|
|
// clearText(pct, canvas) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// Clear last action before street |
|
|
|
|
// config.lastActionBeforeStreet(street)?.let { action -> |
|
|
|
|
// drawPlayerPositionAndStack(action, config, canvas, context) |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun drawPot(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
|
|
|
|
@ -408,7 +341,6 @@ class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
|
|
|
|
this.textPaint.textSize = tpTextPoint.fontSize |
|
|
|
|
this.textPaint.color = context.getColor(R.color.white) |
|
|
|
|
|
|
|
|
|
// clearText(config.totalPotTextPoint, canvas) |
|
|
|
|
canvas.drawText(totalPot.formatted, config.totalPotTextPoint.x, config.totalPotTextPoint.y, this.textPaint) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|