vai te lixar github
This commit is contained in:
@@ -8,12 +8,17 @@ class ShotRecord {
|
||||
final double relativeY;
|
||||
final bool isMake;
|
||||
final String playerName;
|
||||
// 👇 AGORA ACEITA ZONAS E PONTOS!
|
||||
final String? zone;
|
||||
final int? points;
|
||||
|
||||
ShotRecord({
|
||||
required this.relativeX,
|
||||
required this.relativeY,
|
||||
required this.isMake,
|
||||
required this.playerName
|
||||
required this.playerName,
|
||||
this.zone,
|
||||
this.points,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -274,31 +279,74 @@ class PlacarController {
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 👇 A MÁGICA DOS PONTOS ACONTECE AQUI 👇
|
||||
// 👇 REGISTA PONTOS VINDO DO POP-UP AMARELO (E MARCA A BOLINHA)
|
||||
// =========================================================================
|
||||
void registerShotFromPopup(BuildContext context, String action, String targetPlayer, String zone, int points, double relativeX, double relativeY) {
|
||||
if (!isRunning) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('⏳ O relógio está parado! Inicie o tempo primeiro.'), backgroundColor: Colors.red));
|
||||
return;
|
||||
}
|
||||
|
||||
String name = targetPlayer.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
||||
bool isMyTeam = targetPlayer.startsWith("player_my_");
|
||||
bool isMake = action.startsWith("add_");
|
||||
|
||||
// 1. ATUALIZA A ESTATÍSTICA DO JOGADOR
|
||||
if (playerStats.containsKey(name)) {
|
||||
playerStats[name]!['fga'] = playerStats[name]!['fga']! + 1;
|
||||
|
||||
if (isMake) {
|
||||
playerStats[name]!['fgm'] = playerStats[name]!['fgm']! + 1;
|
||||
playerStats[name]!['pts'] = playerStats[name]!['pts']! + points;
|
||||
|
||||
// 2. ATUALIZA O PLACAR DA EQUIPA
|
||||
if (isMyTeam) {
|
||||
myScore += points;
|
||||
} else {
|
||||
opponentScore += points;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. CRIA A BOLINHA PARA APARECER NO CAMPO
|
||||
matchShots.add(ShotRecord(
|
||||
relativeX: relativeX,
|
||||
relativeY: relativeY,
|
||||
isMake: isMake,
|
||||
playerName: name,
|
||||
zone: zone,
|
||||
points: points,
|
||||
));
|
||||
|
||||
// 4. MANDA UMA MENSAGEM NO ECRÃ
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(isMake ? '🔥 $name MARCOU de $zone!' : '❌ $name FALHOU de $zone!'),
|
||||
backgroundColor: isMake ? Colors.green : Colors.red,
|
||||
duration: const Duration(seconds: 2),
|
||||
)
|
||||
);
|
||||
|
||||
// 5. ATUALIZA O ECRÃ
|
||||
onUpdate();
|
||||
}
|
||||
|
||||
|
||||
// MANTIDO PARA CASO USES A MARCAÇÃO CLÁSSICA DIRETAMENTE NO CAMPO ESCURO
|
||||
void registerShotLocation(BuildContext context, Offset position, Size size) {
|
||||
if (pendingAction == null || pendingPlayer == null) return;
|
||||
|
||||
bool is3Pt = pendingAction!.contains("_3");
|
||||
bool is2Pt = pendingAction!.contains("_2");
|
||||
|
||||
// O ÁRBITRO MATEMÁTICO COM AS TUAS VARIÁVEIS CALIBRADAS
|
||||
if (is3Pt || is2Pt) {
|
||||
bool isValid = _validateShotZone(position, size, is3Pt);
|
||||
|
||||
// SE A JOGADA FOI NO SÍTIO ERRADO
|
||||
if (!isValid) {
|
||||
|
||||
return; // <-- ESTE RETURN BLOQUEIA A GRAVAÇÃO DO PONTO!
|
||||
}
|
||||
if (!isValid) return;
|
||||
}
|
||||
|
||||
// SE A JOGADA FOI VÁLIDA:
|
||||
bool isMake = pendingAction!.startsWith("add_pts_");
|
||||
|
||||
double relX = position.dx / size.width;
|
||||
double relY = position.dy / size.height;
|
||||
|
||||
String name = pendingPlayer!.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
||||
|
||||
matchShots.add(ShotRecord(
|
||||
@@ -329,13 +377,10 @@ class PlacarController {
|
||||
|
||||
bool isInside2Pts;
|
||||
|
||||
// Lógica das laterais (Cantos)
|
||||
if (distFromCenterY > cornerY) {
|
||||
double distToBaseline = isLeftHalf ? relX : (1.0 - relX);
|
||||
isInside2Pts = distToBaseline <= hoopBaseX;
|
||||
}
|
||||
// Lógica da Curva Frontal
|
||||
else {
|
||||
} else {
|
||||
double dx = (relX - hoopX) * aspectRatio;
|
||||
double dy = (relY - hoopY);
|
||||
double distanceToHoop = math.sqrt((dx * dx) + (dy * dy));
|
||||
@@ -345,7 +390,6 @@ class PlacarController {
|
||||
if (is3Pt) return !isInside2Pts;
|
||||
return isInside2Pts;
|
||||
}
|
||||
// 👆 ===================================================================== 👆
|
||||
|
||||
void cancelShotLocation() {
|
||||
isSelectingShotLocation = false; pendingAction = null; pendingPlayer = null; onUpdate();
|
||||
|
||||
Reference in New Issue
Block a user