|
import React, { useMemo } from 'react'; |
|
import { TrendingUp, Calculator, Target, AlertCircle } from 'lucide-react'; |
|
import { LotomaniaGame, LotomaniaResult } from '../types'; |
|
|
|
interface GameProfitabilityAnalysisProps { |
|
verticalGame: LotomaniaGame; |
|
horizontalGame: LotomaniaGame; |
|
latestResult: LotomaniaResult; |
|
getNumbersFromGame: (game: LotomaniaGame) => number[]; |
|
className?: string; |
|
} |
|
|
|
const GameProfitabilityAnalysis: React.FC<GameProfitabilityAnalysisProps> = ({ |
|
verticalGame, |
|
horizontalGame, |
|
latestResult, |
|
getNumbersFromGame, |
|
className = '' |
|
}) => { |
|
|
|
const profitabilityAnalysis = useMemo(() => { |
|
const verticalNumbers = getNumbersFromGame(verticalGame); |
|
const horizontalNumbers = getNumbersFromGame(horizontalGame); |
|
|
|
|
|
const verticalMatches = verticalNumbers.filter(num => latestResult.numeros.includes(num)).length; |
|
const horizontalMatches = horizontalNumbers.filter(num => latestResult.numeros.includes(num)).length; |
|
|
|
|
|
const getWinnings = (matches: number) => { |
|
const premio = latestResult.premiacoes?.find(p => p.acertos === matches); |
|
return premio?.valorPremio || 0; |
|
}; |
|
|
|
const verticalWinnings = getWinnings(verticalMatches); |
|
const horizontalWinnings = getWinnings(horizontalMatches); |
|
|
|
|
|
const gameCost = 3.00; |
|
const totalCost = gameCost * 2; |
|
|
|
|
|
const totalWinnings = verticalWinnings + horizontalWinnings; |
|
const netProfit = totalWinnings - totalCost; |
|
const profitMargin = totalCost > 0 ? (netProfit / totalCost) * 100 : 0; |
|
|
|
|
|
const calculateOdds = (matches: number) => { |
|
|
|
const oddsTable: Record<number, number> = { |
|
20: 11372635, |
|
19: 352384, |
|
18: 24192, |
|
17: 2776, |
|
16: 472, |
|
15: 112, |
|
0: 11372635 |
|
}; |
|
return oddsTable[matches] || 0; |
|
}; |
|
|
|
return { |
|
vertical: { |
|
matches: verticalMatches, |
|
winnings: verticalWinnings, |
|
cost: gameCost, |
|
profit: verticalWinnings - gameCost, |
|
odds: calculateOdds(verticalMatches) |
|
}, |
|
horizontal: { |
|
matches: horizontalMatches, |
|
winnings: horizontalWinnings, |
|
cost: gameCost, |
|
profit: horizontalWinnings - gameCost, |
|
odds: calculateOdds(horizontalMatches) |
|
}, |
|
combined: { |
|
totalWinnings, |
|
totalCost, |
|
netProfit, |
|
profitMargin, |
|
isProfit: netProfit > 0 |
|
} |
|
}; |
|
}, [verticalGame, horizontalGame, latestResult, getNumbersFromGame]); |
|
|
|
|
|
const formatCurrency = (value: number) => |
|
new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(value); |
|
|
|
const formatPercentage = (value: number) => |
|
`${value >= 0 ? '+' : ''}${value.toFixed(1)}%`; |
|
|
|
const formatOdds = (odds: number) => |
|
odds > 0 ? `1 em ${new Intl.NumberFormat('pt-BR').format(odds)}` : 'N/A'; |
|
|
|
|
|
const getStrategyAnalysis = () => { |
|
const { combined } = profitabilityAnalysis; |
|
|
|
if (combined.netProfit > 1000) { |
|
return { |
|
level: 'excellent', |
|
title: '🏆 Excelente Resultado!', |
|
description: 'Estratégia muito lucrativa neste concurso.', |
|
color: 'from-green-500 to-emerald-600' |
|
}; |
|
} else if (combined.netProfit > 100) { |
|
return { |
|
level: 'good', |
|
title: '✅ Bom Resultado', |
|
description: 'Estratégia rendeu lucro positivo.', |
|
color: 'from-green-400 to-green-500' |
|
}; |
|
} else if (combined.netProfit > 0) { |
|
return { |
|
level: 'break-even', |
|
title: '💰 Lucro Pequeno', |
|
description: 'Estratégia cobriu os custos com pequeno lucro.', |
|
color: 'from-yellow-400 to-yellow-500' |
|
}; |
|
} else if (combined.netProfit > -20) { |
|
return { |
|
level: 'small-loss', |
|
title: '📉 Pequena Perda', |
|
description: 'Perda controlada dentro do esperado.', |
|
color: 'from-orange-400 to-orange-500' |
|
}; |
|
} else { |
|
return { |
|
level: 'loss', |
|
title: '❌ Prejuízo', |
|
description: 'Estratégia não foi lucrativa neste concurso.', |
|
color: 'from-red-400 to-red-500' |
|
}; |
|
} |
|
}; |
|
|
|
const strategy = getStrategyAnalysis(); |
|
|
|
return ( |
|
<div className={`bg-white rounded-2xl shadow-xl border border-gray-100 ${className}`}> |
|
{/* Header */} |
|
<div className={`bg-gradient-to-r ${strategy.color} text-white p-6 rounded-t-2xl`}> |
|
<div className="flex items-center justify-between"> |
|
<div className="flex items-center space-x-3"> |
|
<Calculator className="w-8 h-8" /> |
|
<div> |
|
<h2 className="text-2xl font-bold">Análise de Rentabilidade</h2> |
|
<p className="text-white/90">Concurso {latestResult.concurso}</p> |
|
</div> |
|
</div> |
|
<div className="text-right"> |
|
<p className="text-white/90 text-sm">Resultado da Estratégia</p> |
|
<p className="text-3xl font-bold">{strategy.title.split(' ')[0]}</p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div className="p-6"> |
|
{/* Resumo Geral */} |
|
<div className="bg-gray-50 rounded-xl p-6 mb-6"> |
|
<h3 className="text-lg font-semibold text-gray-800 mb-4">{strategy.title}</h3> |
|
<p className="text-gray-600 mb-4">{strategy.description}</p> |
|
|
|
<div className="grid grid-cols-1 md:grid-cols-4 gap-4"> |
|
<div className="text-center"> |
|
<p className="text-sm text-gray-600">Investimento Total</p> |
|
<p className="text-2xl font-bold text-gray-800"> |
|
{formatCurrency(profitabilityAnalysis.combined.totalCost)} |
|
</p> |
|
</div> |
|
<div className="text-center"> |
|
<p className="text-sm text-gray-600">Prêmios Ganhos</p> |
|
<p className="text-2xl font-bold text-blue-600"> |
|
{formatCurrency(profitabilityAnalysis.combined.totalWinnings)} |
|
</p> |
|
</div> |
|
<div className="text-center"> |
|
<p className="text-sm text-gray-600">Lucro Líquido</p> |
|
<p className={`text-2xl font-bold ${ |
|
profitabilityAnalysis.combined.netProfit >= 0 ? 'text-green-600' : 'text-red-600' |
|
}`}> |
|
{formatCurrency(profitabilityAnalysis.combined.netProfit)} |
|
</p> |
|
</div> |
|
<div className="text-center"> |
|
<p className="text-sm text-gray-600">Margem de Lucro</p> |
|
<p className={`text-2xl font-bold ${ |
|
profitabilityAnalysis.combined.profitMargin >= 0 ? 'text-green-600' : 'text-red-600' |
|
}`}> |
|
{formatPercentage(profitabilityAnalysis.combined.profitMargin)} |
|
</p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
{/* Análise por Jogo */} |
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6"> |
|
{/* Jogo Vertical */} |
|
<div className="bg-blue-50 border border-blue-200 rounded-xl p-5"> |
|
<div className="flex items-center space-x-3 mb-4"> |
|
<div className="bg-blue-500 text-white p-2 rounded-lg"> |
|
<Target className="w-5 h-5" /> |
|
</div> |
|
<div> |
|
<h4 className="font-semibold text-blue-800">Jogo Vertical #{verticalGame.id}</h4> |
|
<p className="text-sm text-blue-600">Estratégia por Colunas</p> |
|
</div> |
|
</div> |
|
|
|
<div className="space-y-3"> |
|
<div className="flex justify-between"> |
|
<span className="text-blue-700">Acertos:</span> |
|
<span className="font-bold text-blue-800"> |
|
{profitabilityAnalysis.vertical.matches} números |
|
</span> |
|
</div> |
|
<div className="flex justify-between"> |
|
<span className="text-blue-700">Prêmio:</span> |
|
<span className="font-bold text-green-600"> |
|
{formatCurrency(profitabilityAnalysis.vertical.winnings)} |
|
</span> |
|
</div> |
|
<div className="flex justify-between"> |
|
<span className="text-blue-700">Custo:</span> |
|
<span className="font-bold text-gray-600"> |
|
{formatCurrency(profitabilityAnalysis.vertical.cost)} |
|
</span> |
|
</div> |
|
<div className="flex justify-between border-t border-blue-200 pt-2"> |
|
<span className="text-blue-700 font-medium">Lucro:</span> |
|
<span className={`font-bold ${ |
|
profitabilityAnalysis.vertical.profit >= 0 ? 'text-green-600' : 'text-red-600' |
|
}`}> |
|
{formatCurrency(profitabilityAnalysis.vertical.profit)} |
|
</span> |
|
</div> |
|
<div className="text-xs text-blue-600"> |
|
Probabilidade: {formatOdds(profitabilityAnalysis.vertical.odds)} |
|
</div> |
|
</div> |
|
</div> |
|
|
|
{/* Jogo Horizontal */} |
|
<div className="bg-green-50 border border-green-200 rounded-xl p-5"> |
|
<div className="flex items-center space-x-3 mb-4"> |
|
<div className="bg-green-500 text-white p-2 rounded-lg"> |
|
<Target className="w-5 h-5" /> |
|
</div> |
|
<div> |
|
<h4 className="font-semibold text-green-800">Jogo Horizontal #{horizontalGame.id}</h4> |
|
<p className="text-sm text-green-600">Estratégia por Linhas</p> |
|
</div> |
|
</div> |
|
|
|
<div className="space-y-3"> |
|
<div className="flex justify-between"> |
|
<span className="text-green-700">Acertos:</span> |
|
<span className="font-bold text-green-800"> |
|
{profitabilityAnalysis.horizontal.matches} números |
|
</span> |
|
</div> |
|
<div className="flex justify-between"> |
|
<span className="text-green-700">Prêmio:</span> |
|
<span className="font-bold text-green-600"> |
|
{formatCurrency(profitabilityAnalysis.horizontal.winnings)} |
|
</span> |
|
</div> |
|
<div className="flex justify-between"> |
|
<span className="text-green-700">Custo:</span> |
|
<span className="font-bold text-gray-600"> |
|
{formatCurrency(profitabilityAnalysis.horizontal.cost)} |
|
</span> |
|
</div> |
|
<div className="flex justify-between border-t border-green-200 pt-2"> |
|
<span className="text-green-700 font-medium">Lucro:</span> |
|
<span className={`font-bold ${ |
|
profitabilityAnalysis.horizontal.profit >= 0 ? 'text-green-600' : 'text-red-600' |
|
}`}> |
|
{formatCurrency(profitabilityAnalysis.horizontal.profit)} |
|
</span> |
|
</div> |
|
<div className="text-xs text-green-600"> |
|
Probabilidade: {formatOdds(profitabilityAnalysis.horizontal.odds)} |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
{/* Insights e Recomendações */} |
|
<div className="bg-yellow-50 border border-yellow-200 rounded-xl p-5"> |
|
<div className="flex items-center space-x-3 mb-4"> |
|
<AlertCircle className="w-6 h-6 text-yellow-600" /> |
|
<h4 className="font-semibold text-yellow-800">Insights e Recomendações</h4> |
|
</div> |
|
|
|
<div className="space-y-3 text-sm"> |
|
{profitabilityAnalysis.combined.isProfit ? ( |
|
<div className="bg-green-100 border border-green-300 rounded-lg p-3"> |
|
<p className="text-green-800"> |
|
<strong>✅ Estratégia Lucrativa:</strong> Sua combinação de jogos vertical e horizontal |
|
gerou lucro neste concurso. Continue monitorando os padrões! |
|
</p> |
|
</div> |
|
) : ( |
|
<div className="bg-red-100 border border-red-300 rounded-lg p-3"> |
|
<p className="text-red-800"> |
|
<strong>⚠️ Prejuízo:</strong> Neste concurso a estratégia não foi lucrativa. |
|
Lembre-se que a Lotomania é um jogo de probabilidade e resultados variam. |
|
</p> |
|
</div> |
|
)} |
|
|
|
<div className="bg-blue-100 border border-blue-300 rounded-lg p-3"> |
|
<p className="text-blue-800"> |
|
<strong>📊 Análise Estatística:</strong> Jogos com {profitabilityAnalysis.vertical.matches} |
|
e {profitabilityAnalysis.horizontal.matches} acertos têm probabilidades de |
|
{formatOdds(profitabilityAnalysis.vertical.odds)} e {formatOdds(profitabilityAnalysis.horizontal.odds)} respectivamente. |
|
</p> |
|
</div> |
|
|
|
<div className="bg-purple-100 border border-purple-300 rounded-lg p-3"> |
|
<p className="text-purple-800"> |
|
<strong>🎯 Dica Estratégica:</strong> Para otimizar resultados, considere diversificar |
|
suas estratégias e jogar responsavelmente dentro de suas possibilidades financeiras. |
|
</p> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
{/* ROI Histórico Simulado */} |
|
<div className="mt-6 bg-indigo-50 border border-indigo-200 rounded-xl p-5"> |
|
<div className="flex items-center space-x-3 mb-4"> |
|
<TrendingUp className="w-6 h-6 text-indigo-600" /> |
|
<h4 className="font-semibold text-indigo-800">Simulação de ROI</h4> |
|
</div> |
|
|
|
<p className="text-sm text-indigo-700 mb-3"> |
|
Se você jogasse esta estratégia nos últimos 10 concursos (simulação baseada em probabilidades médias): |
|
</p> |
|
|
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-center"> |
|
<div> |
|
<p className="text-indigo-600 text-sm">Investimento Total</p> |
|
<p className="text-xl font-bold text-indigo-800"> |
|
{formatCurrency(60)} {/* 10 concursos × R$ 6 */} |
|
</p> |
|
</div> |
|
<div> |
|
<p className="text-indigo-600 text-sm">Retorno Estimado</p> |
|
<p className="text-xl font-bold text-green-600"> |
|
{formatCurrency(45)} {/* Simulação conservadora */} |
|
</p> |
|
</div> |
|
<div> |
|
<p className="text-indigo-600 text-sm">ROI Estimado</p> |
|
<p className="text-xl font-bold text-orange-600"> |
|
-25.0% {/* Realista para loteria */} |
|
</p> |
|
</div> |
|
</div> |
|
|
|
<p className="text-xs text-indigo-600 mt-3 text-center"> |
|
* Simulação baseada em probabilidades. Resultados reais podem variar significativamente. |
|
</p> |
|
</div> |
|
</div> |
|
</div> |
|
); |
|
}; |
|
|
|
export default GameProfitabilityAnalysis; |
|
|