Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defaultGetStepRenderTime } from '../../../timing';
import { InterestingEvent, ReplayMode } from '../../../types';
import { PokerReplay, PokerReplayStepHistoryParsed } from './poker-replay-types';
import { RepeatedPokerStep } from './poker-steps-types';
import { RepeatedPokerStep, RepeatedPokerStepPlayer } from './poker-steps-types';

import { createVisualStepsFromRepeatedPokerReplay } from './repeatedPokerTransformerUtils';

Expand Down Expand Up @@ -70,16 +70,56 @@ export const getPokerStepRenderTime = (
};

export const getPokerStepInterestingEvents = (gameSteps: RepeatedPokerStep[]): InterestingEvent[] => {
console.log(gameSteps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove


const interestingEvents: InterestingEvent[] = [];
const largePotIndices = new Set(gameSteps.filter((s) => s.pot >= 300).map((s) => s.currentHandIndex));
const largePotIndices = new Set(
gameSteps
.filter((s) => {
return s.pot >= 350 && s.pot < 400;
})
.map((s) => s.currentHandIndex)
);
const showdownIndices = new Set(gameSteps.filter((s) => s.pot === 400).map((s) => s.currentHandIndex));
let lastHandIndex = -1;

for (const step of gameSteps) {
const hasLargePot = largePotIndices.has(step.currentHandIndex);
const hasShowdown = showdownIndices.has(step.currentHandIndex);

// Check for high hands
const highHandTypes = ['Full House', 'Four of a Kind', 'Straight Flush', 'Royal Flush'];
const handSteps = gameSteps.filter((s) => s.currentHandIndex === step.currentHandIndex);
const hasHighHand = handSteps.some((s) => s.bestHandRankTypes?.some((rank) => highHandTypes.includes(rank)));

// Check for upsets (winner had < 20% odds on turn or river)
const turnOrRiverStep = handSteps.find((s) => s.stepType === 'deal-turn' || s.stepType === 'deal-river');
const winnerIndex =
handSteps
.find((s) => s.stepType === 'final')
?.players.findIndex((p) => (p as RepeatedPokerStepPlayer).isWinner) ?? -1;
const hasUpset = turnOrRiverStep && turnOrRiverStep.winOdds && turnOrRiverStep.winOdds[winnerIndex * 2] < 0.2;

if (step.currentHandIndex > lastHandIndex) {
if (largePotIndices.has(step.currentHandIndex)) {
if (hasUpset) {
interestingEvents.push({
step: step.step,
description: 'Upset',
});
} else if (hasHighHand) {
interestingEvents.push({
step: step.step,
description: 'High Hand',
});
} else if (hasLargePot) {
interestingEvents.push({
step: step.step,
description: 'Big Pot',
});
} else if (hasShowdown) {
interestingEvents.push({
step: step.step,
description: `Big Pot`,
description: 'All-in Showdown',
});
}
lastHandIndex = step.currentHandIndex;
Expand Down