$bestProfit) { $bestProfit = $profit; $bestResult = $result; } } return $bestResult; } public static function checkWin(array $result, string $betType, string $betTarget): bool { $total = array_sum($result); switch ($betType) { case 'big_small': return ($betTarget === 'big' && $total >= 11) || ($betTarget === 'small' && $total <= 10); case 'odd_even': return ($betTarget === 'odd' && $total % 2 === 1) || ($betTarget === 'even' && $total % 2 === 0); case 'sum': return (int)$betTarget === $total; default: return false; } } public static function calculatePlatformProfit(array $result, array $bets): float { $totalBet = 0; $totalPayout = 0; foreach ($bets as $bet) { $amount = (float)$bet['amount']; $totalBet += $amount; if (self::checkWin($result, $bet['bet_type'], $bet['bet_target'] ?? $bet['bet_value'] ?? '')) { $totalPayout += $amount + $amount * (float)$bet['odds']; } } return $totalBet - $totalPayout; } public static function getResultTable(): ?string { return null; } public static function formatResultForStorage(array $result, int $periodId): array { return [ 'dice1' => $result[0], 'dice2' => $result[1], 'dice3' => $result[2], 'total' => array_sum($result), ]; } public static function parseResultFromDb(array $row): array { return [(int)($row['dice1'] ?? 0), (int)($row['dice2'] ?? 0), (int)($row['dice3'] ?? 0)]; } }