corrigir os pixel no botao de faltas
This commit is contained in:
@@ -140,13 +140,7 @@ class PlacarController extends ChangeNotifier {
|
|||||||
|
|
||||||
if (savedStats.containsKey(dbId)) {
|
if (savedStats.containsKey(dbId)) {
|
||||||
var s = savedStats[dbId];
|
var s = savedStats[dbId];
|
||||||
playerStats[dbId] = {
|
_loadSavedPlayerStats(dbId, s);
|
||||||
"pts": s['pts'] ?? 0, "rbs": s['rbs'] ?? 0, "ast": s['ast'] ?? 0,
|
|
||||||
"stl": s['stl'] ?? 0, "tov": s['tov'] ?? 0, "blk": s['blk'] ?? 0,
|
|
||||||
"fls": s['fls'] ?? 0, "fgm": s['fgm'] ?? 0, "fga": s['fga'] ?? 0,
|
|
||||||
"ftm": s['ftm'] ?? 0, "fta": s['fta'] ?? 0, "orb": s['orb'] ?? 0, "drb": s['drb'] ?? 0,
|
|
||||||
"p2m": s['p2m'] ?? 0, "p2a": s['p2a'] ?? 0, "p3m": s['p3m'] ?? 0, "p3a": s['p3a'] ?? 0,
|
|
||||||
};
|
|
||||||
myFouls += (s['fls'] as int? ?? 0);
|
myFouls += (s['fls'] as int? ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,13 +154,7 @@ class PlacarController extends ChangeNotifier {
|
|||||||
|
|
||||||
if (savedStats.containsKey(dbId)) {
|
if (savedStats.containsKey(dbId)) {
|
||||||
var s = savedStats[dbId];
|
var s = savedStats[dbId];
|
||||||
playerStats[dbId] = {
|
_loadSavedPlayerStats(dbId, s);
|
||||||
"pts": s['pts'] ?? 0, "rbs": s['rbs'] ?? 0, "ast": s['ast'] ?? 0,
|
|
||||||
"stl": s['stl'] ?? 0, "tov": s['tov'] ?? 0, "blk": s['blk'] ?? 0,
|
|
||||||
"fls": s['fls'] ?? 0, "fgm": s['fgm'] ?? 0, "fga": s['fga'] ?? 0,
|
|
||||||
"ftm": s['ftm'] ?? 0, "fta": s['fta'] ?? 0, "orb": s['orb'] ?? 0, "drb": s['drb'] ?? 0,
|
|
||||||
"p2m": s['p2m'] ?? 0, "p2a": s['p2a'] ?? 0, "p3m": s['p3m'] ?? 0, "p3a": s['p3a'] ?? 0,
|
|
||||||
};
|
|
||||||
opponentFouls += (s['fls'] as int? ?? 0);
|
opponentFouls += (s['fls'] as int? ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,6 +184,18 @@ class PlacarController extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _loadSavedPlayerStats(String dbId, Map<String, dynamic> s) {
|
||||||
|
playerStats[dbId] = {
|
||||||
|
"pts": s['pts'] ?? 0, "rbs": s['rbs'] ?? 0, "ast": s['ast'] ?? 0,
|
||||||
|
"stl": s['stl'] ?? 0, "tov": s['tov'] ?? 0, "blk": s['blk'] ?? 0,
|
||||||
|
"fls": s['fls'] ?? 0, "fgm": s['fgm'] ?? 0, "fga": s['fga'] ?? 0,
|
||||||
|
"ftm": s['ftm'] ?? 0, "fta": s['fta'] ?? 0, "orb": s['orb'] ?? 0, "drb": s['drb'] ?? 0,
|
||||||
|
"p2m": s['p2m'] ?? 0, "p2a": s['p2a'] ?? 0, "p3m": s['p3m'] ?? 0, "p3a": s['p3a'] ?? 0,
|
||||||
|
"so": s['so'] ?? 0, "il": s['il'] ?? 0, "li": s['li'] ?? 0,
|
||||||
|
"pa": s['pa'] ?? 0, "tres_s": s['tres_s'] ?? 0, "dr": s['dr'] ?? 0, "min": s['min'] ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void _registerPlayer({required String name, required String number, String? dbId, required bool isMyTeam, required bool isCourt}) {
|
void _registerPlayer({required String name, required String number, String? dbId, required bool isMyTeam, required bool isCourt}) {
|
||||||
String id = dbId ?? "fake_${DateTime.now().millisecondsSinceEpoch}_${math.Random().nextInt(9999)}";
|
String id = dbId ?? "fake_${DateTime.now().millisecondsSinceEpoch}_${math.Random().nextInt(9999)}";
|
||||||
|
|
||||||
@@ -205,7 +205,8 @@ class PlacarController extends ChangeNotifier {
|
|||||||
playerStats[id] = {
|
playerStats[id] = {
|
||||||
"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0,
|
"pts": 0, "rbs": 0, "ast": 0, "stl": 0, "tov": 0, "blk": 0,
|
||||||
"fls": 0, "fgm": 0, "fga": 0, "ftm": 0, "fta": 0, "orb": 0, "drb": 0,
|
"fls": 0, "fgm": 0, "fga": 0, "ftm": 0, "fta": 0, "orb": 0, "drb": 0,
|
||||||
"p2m": 0, "p2a": 0, "p3m": 0, "p3a": 0
|
"p2m": 0, "p2a": 0, "p3m": 0, "p3a": 0,
|
||||||
|
"so": 0, "il": 0, "li": 0, "pa": 0, "tres_s": 0, "dr": 0, "min": 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isMyTeam) {
|
if (isMyTeam) {
|
||||||
@@ -263,8 +264,6 @@ class PlacarController extends ChangeNotifier {
|
|||||||
matchShots = decodedShots.map((s) => ShotRecord.fromJson(s)).toList();
|
matchShots = decodedShots.map((s) => ShotRecord.fromJson(s)).toList();
|
||||||
|
|
||||||
playByPlay = List<String>.from(data['playByPlay'] ?? []);
|
playByPlay = List<String>.from(data['playByPlay'] ?? []);
|
||||||
|
|
||||||
debugPrint("🔄 AUTO-SAVE RECUPERADO COM SUCESSO!");
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("Erro ao carregar Auto-Save: $e");
|
debugPrint("Erro ao carregar Auto-Save: $e");
|
||||||
@@ -436,66 +435,34 @@ class PlacarController extends ChangeNotifier {
|
|||||||
int pts = int.parse(action.split("_").last);
|
int pts = int.parse(action.split("_").last);
|
||||||
if (isOpponent) opponentScore += pts; else myScore += pts;
|
if (isOpponent) opponentScore += pts; else myScore += pts;
|
||||||
stats["pts"] = stats["pts"]! + pts;
|
stats["pts"] = stats["pts"]! + pts;
|
||||||
|
|
||||||
if (pts == 2) { stats["fgm"] = stats["fgm"]! + 1; stats["fga"] = stats["fga"]! + 1; stats["p2m"] = stats["p2m"]! + 1; stats["p2a"] = stats["p2a"]! + 1; }
|
if (pts == 2) { stats["fgm"] = stats["fgm"]! + 1; stats["fga"] = stats["fga"]! + 1; stats["p2m"] = stats["p2m"]! + 1; stats["p2a"] = stats["p2a"]! + 1; }
|
||||||
if (pts == 3) { stats["fgm"] = stats["fgm"]! + 1; stats["fga"] = stats["fga"]! + 1; stats["p3m"] = stats["p3m"]! + 1; stats["p3a"] = stats["p3a"]! + 1; }
|
if (pts == 3) { stats["fgm"] = stats["fgm"]! + 1; stats["fga"] = stats["fga"]! + 1; stats["p3m"] = stats["p3m"]! + 1; stats["p3a"] = stats["p3a"]! + 1; }
|
||||||
if (pts == 1) { stats["ftm"] = stats["ftm"]! + 1; stats["fta"] = stats["fta"]! + 1; }
|
if (pts == 1) { stats["ftm"] = stats["ftm"]! + 1; stats["fta"] = stats["fta"]! + 1; }
|
||||||
|
|
||||||
logText = "marcou $pts pontos 🏀";
|
logText = "marcou $pts pontos 🏀";
|
||||||
}
|
}
|
||||||
else if (action.startsWith("sub_pts_")) {
|
|
||||||
int pts = int.parse(action.split("_").last);
|
|
||||||
if (isOpponent) { opponentScore = (opponentScore - pts < 0) ? 0 : opponentScore - pts; }
|
|
||||||
else { myScore = (myScore - pts < 0) ? 0 : myScore - pts; }
|
|
||||||
stats["pts"] = (stats["pts"]! - pts < 0) ? 0 : stats["pts"]! - pts;
|
|
||||||
|
|
||||||
if (pts == 2) {
|
|
||||||
if (stats["fgm"]! > 0) stats["fgm"] = stats["fgm"]! - 1;
|
|
||||||
if (stats["fga"]! > 0) stats["fga"] = stats["fga"]! - 1;
|
|
||||||
if (stats["p2m"]! > 0) stats["p2m"] = stats["p2m"]! - 1;
|
|
||||||
if (stats["p2a"]! > 0) stats["p2a"] = stats["p2a"]! - 1;
|
|
||||||
}
|
|
||||||
if (pts == 3) {
|
|
||||||
if (stats["fgm"]! > 0) stats["fgm"] = stats["fgm"]! - 1;
|
|
||||||
if (stats["fga"]! > 0) stats["fga"] = stats["fga"]! - 1;
|
|
||||||
if (stats["p3m"]! > 0) stats["p3m"] = stats["p3m"]! - 1;
|
|
||||||
if (stats["p3a"]! > 0) stats["p3a"] = stats["p3a"]! - 1;
|
|
||||||
}
|
|
||||||
if (pts == 1) {
|
|
||||||
if (stats["ftm"]! > 0) stats["ftm"] = stats["ftm"]! - 1;
|
|
||||||
if (stats["fta"]! > 0) stats["fta"] = stats["fta"]! - 1;
|
|
||||||
}
|
|
||||||
logText = "teve $pts pontos retirados ❌";
|
|
||||||
}
|
|
||||||
else if (action == "miss_1") { stats["fta"] = stats["fta"]! + 1; logText = "falhou lance livre ❌"; }
|
else if (action == "miss_1") { stats["fta"] = stats["fta"]! + 1; logText = "falhou lance livre ❌"; }
|
||||||
else if (action == "miss_2") { stats["fga"] = stats["fga"]! + 1; stats["p2a"] = stats["p2a"]! + 1; logText = "falhou lançamento de 2 ❌"; }
|
else if (action == "miss_2") { stats["fga"] = stats["fga"]! + 1; stats["p2a"] = stats["p2a"]! + 1; logText = "falhou lançamento de 2 ❌"; }
|
||||||
else if (action == "miss_3") { stats["fga"] = stats["fga"]! + 1; stats["p3a"] = stats["p3a"]! + 1; logText = "falhou lançamento de 3 ❌"; }
|
else if (action == "miss_3") { stats["fga"] = stats["fga"]! + 1; stats["p3a"] = stats["p3a"]! + 1; logText = "falhou lançamento de 3 ❌"; }
|
||||||
else if (action == "add_orb") { stats["orb"] = stats["orb"]! + 1; stats["rbs"] = stats["rbs"]! + 1; logText = "ganhou ressalto ofensivo 🔄"; }
|
else if (action == "add_orb") { stats["orb"] = stats["orb"]! + 1; stats["rbs"] = stats["rbs"]! + 1; logText = "ganhou ressalto ofensivo 🔄"; }
|
||||||
else if (action == "add_drb") { stats["drb"] = stats["drb"]! + 1; stats["rbs"] = stats["rbs"]! + 1; logText = "ganhou ressalto defensivo 🛡️"; }
|
else if (action == "add_drb") { stats["drb"] = stats["drb"]! + 1; stats["rbs"] = stats["rbs"]! + 1; logText = "ganhou ressalto defensivo 🛡️"; }
|
||||||
else if (action == "add_ast") {
|
else if (action == "add_ast") { stats["ast"] = stats["ast"]! + 1; logText = "fez uma assistência 🤝"; }
|
||||||
stats["ast"] = stats["ast"]! + 1;
|
|
||||||
if (playByPlay.isNotEmpty && playByPlay[0].contains("marcou") && !playByPlay[0].contains("Assistência")) {
|
|
||||||
playByPlay[0] = "${playByPlay[0]} (Assistência: $name 🤝)";
|
|
||||||
_saveLocalBackup();
|
|
||||||
notifyListeners();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
logText = "fez uma assistência 🤝";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (action == "add_stl") { stats["stl"] = stats["stl"]! + 1; logText = "roubou a bola 🥷"; }
|
else if (action == "add_stl") { stats["stl"] = stats["stl"]! + 1; logText = "roubou a bola 🥷"; }
|
||||||
else if (action == "add_tov") { stats["tov"] = stats["tov"]! + 1; logText = "perdeu a bola (turnover) 🤦"; }
|
|
||||||
else if (action == "add_blk") { stats["blk"] = stats["blk"]! + 1; logText = "fez um desarme (bloco) ✋"; }
|
else if (action == "add_blk") { stats["blk"] = stats["blk"]! + 1; logText = "fez um desarme (bloco) ✋"; }
|
||||||
else if (action == "add_foul") {
|
else if (action == "add_foul") {
|
||||||
stats["fls"] = stats["fls"]! + 1;
|
stats["fls"] = stats["fls"]! + 1;
|
||||||
if (isOpponent) { opponentFouls++; } else { myFouls++; }
|
if (isOpponent) opponentFouls++; else myFouls++;
|
||||||
logText = "cometeu falta ⚠️";
|
logText = "cometeu falta ⚠️";
|
||||||
}
|
}
|
||||||
else if (action == "sub_foul") {
|
else if (action == "add_so") { stats["so"] = stats["so"]! + 1; logText = "sofreu uma falta 🤕"; }
|
||||||
if (stats["fls"]! > 0) stats["fls"] = stats["fls"]! - 1;
|
else if (action == "add_il") { stats["il"] = stats["il"]! + 1; logText = "intercetou um lançamento 🛑"; }
|
||||||
if (isOpponent) { if (opponentFouls > 0) opponentFouls--; } else { if (myFouls > 0) myFouls--; }
|
else if (action == "add_li") { stats["li"] = stats["li"]! + 1; logText = "teve o lançamento intercetado 🚫"; }
|
||||||
logText = "teve falta anulada 🔄";
|
|
||||||
}
|
// Registo avançado de Bolas Perdidas (TOV)
|
||||||
|
else if (action == "add_tov") { stats["tov"] = stats["tov"]! + 1; logText = "fez um passe ruim 🤦"; }
|
||||||
|
else if (action == "add_pa") { stats["pa"] = stats["pa"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "cometeu passos 🚶"; }
|
||||||
|
else if (action == "add_3s") { stats["tres_s"] = stats["tres_s"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "violação de 3 segundos ⏱️"; }
|
||||||
|
else if (action == "add_24s") { stats["tov"] = stats["tov"]! + 1; logText = "violação de 24 segundos ⏱️"; }
|
||||||
|
else if (action == "add_dr") { stats["dr"] = stats["dr"]! + 1; stats["tov"] = stats["tov"]! + 1; logText = "fez drible duplo 🏀"; }
|
||||||
|
|
||||||
if (logText.isNotEmpty) {
|
if (logText.isNotEmpty) {
|
||||||
String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}";
|
String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}";
|
||||||
@@ -517,76 +484,54 @@ class PlacarController extends ChangeNotifier {
|
|||||||
String topPtsName = '---'; int maxPts = -1;
|
String topPtsName = '---'; int maxPts = -1;
|
||||||
String topAstName = '---'; int maxAst = -1;
|
String topAstName = '---'; int maxAst = -1;
|
||||||
String topRbsName = '---'; int maxRbs = -1;
|
String topRbsName = '---'; int maxRbs = -1;
|
||||||
String topDefName = '---'; int maxDef = -1;
|
String mvpName = '---'; double maxMvpScore = -999.0;
|
||||||
String mvpName = '---'; int maxMvpScore = -1;
|
|
||||||
|
|
||||||
playerStats.forEach((playerId, stats) {
|
playerStats.forEach((playerId, stats) {
|
||||||
int pts = stats['pts'] ?? 0;
|
int pts = stats['pts'] ?? 0;
|
||||||
int ast = stats['ast'] ?? 0;
|
int ast = stats['ast'] ?? 0;
|
||||||
int rbs = stats['rbs'] ?? 0;
|
int rbs = stats['rbs'] ?? 0;
|
||||||
int stl = stats['stl'] ?? 0;
|
|
||||||
int blk = stats['blk'] ?? 0;
|
|
||||||
|
|
||||||
int defScore = stl + blk;
|
int minJogados = (stats['min'] ?? 0) > 0 ? stats['min']! : 40;
|
||||||
int mvpScore = pts + ast + rbs + defScore;
|
int tr = rbs;
|
||||||
|
int br = stats['stl'] ?? 0;
|
||||||
|
int bp = stats['tov'] ?? 0;
|
||||||
|
int lFalhados = (stats['fga'] ?? 0) - (stats['fgm'] ?? 0);
|
||||||
|
int llFalhados = (stats['fta'] ?? 0) - (stats['ftm'] ?? 0);
|
||||||
|
|
||||||
|
double mvpScore = ((pts * 0.30) + (tr * 0.20) + (ast * 0.35) + (br * 0.15)) -
|
||||||
|
((bp * 0.35) + (lFalhados * 0.30) + (llFalhados * 0.35));
|
||||||
|
mvpScore = mvpScore * (minJogados / 40.0);
|
||||||
|
|
||||||
String pName = playerNames[playerId] ?? '---';
|
String pName = playerNames[playerId] ?? '---';
|
||||||
|
|
||||||
if (pts > maxPts && pts > 0) { maxPts = pts; topPtsName = '$pName ($pts)'; }
|
if (pts > maxPts && pts > 0) { maxPts = pts; topPtsName = '$pName ($pts)'; }
|
||||||
if (ast > maxAst && ast > 0) { maxAst = ast; topAstName = '$pName ($ast)'; }
|
if (ast > maxAst && ast > 0) { maxAst = ast; topAstName = '$pName ($ast)'; }
|
||||||
if (rbs > maxRbs && rbs > 0) { maxRbs = rbs; topRbsName = '$pName ($rbs)'; }
|
if (rbs > maxRbs && rbs > 0) { maxRbs = rbs; topRbsName = '$pName ($rbs)'; }
|
||||||
if (defScore > maxDef && defScore > 0) { maxDef = defScore; topDefName = '$pName ($defScore)'; }
|
if (mvpScore > maxMvpScore) { maxMvpScore = mvpScore; mvpName = '$pName (${mvpScore.toStringAsFixed(1)})'; }
|
||||||
if (mvpScore > maxMvpScore && mvpScore > 0) { maxMvpScore = mvpScore; mvpName = pName; }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await supabase.from('games').update({
|
await supabase.from('games').update({
|
||||||
'my_score': myScore,
|
'my_score': myScore, 'opponent_score': opponentScore,
|
||||||
'opponent_score': opponentScore,
|
|
||||||
'remaining_seconds': durationNotifier.value.inSeconds,
|
'remaining_seconds': durationNotifier.value.inSeconds,
|
||||||
'my_timeouts': myTimeoutsUsed,
|
'my_timeouts': myTimeoutsUsed, 'opp_timeouts': opponentTimeoutsUsed,
|
||||||
'opp_timeouts': opponentTimeoutsUsed,
|
'current_quarter': currentQuarter, 'status': newStatus,
|
||||||
'current_quarter': currentQuarter,
|
'top_pts_name': topPtsName, 'top_ast_name': topAstName,
|
||||||
'status': newStatus,
|
'top_rbs_name': topRbsName, 'mvp_name': mvpName,
|
||||||
'top_pts_name': topPtsName,
|
|
||||||
'top_ast_name': topAstName,
|
|
||||||
'top_rbs_name': topRbsName,
|
|
||||||
'top_def_name': topDefName,
|
|
||||||
'mvp_name': mvpName,
|
|
||||||
'play_by_play': playByPlay,
|
'play_by_play': playByPlay,
|
||||||
}).eq('id', gameId);
|
}).eq('id', gameId);
|
||||||
|
|
||||||
if (isGameFinishedNow && !gameWasAlreadyFinished && myTeamDbId != null && oppTeamDbId != null) {
|
|
||||||
final teamsData = await supabase.from('teams').select('id, wins, losses, draws').inFilter('id', [myTeamDbId, oppTeamDbId]);
|
|
||||||
Map<String, dynamic> myTeamUpdate = {};
|
|
||||||
Map<String, dynamic> oppTeamUpdate = {};
|
|
||||||
|
|
||||||
for(var t in teamsData) {
|
|
||||||
if(t['id'].toString() == myTeamDbId) myTeamUpdate = Map.from(t);
|
|
||||||
if(t['id'].toString() == oppTeamDbId) oppTeamUpdate = Map.from(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myScore > opponentScore) {
|
|
||||||
myTeamUpdate['wins'] = (myTeamUpdate['wins'] ?? 0) + 1; oppTeamUpdate['losses'] = (oppTeamUpdate['losses'] ?? 0) + 1;
|
|
||||||
} else if (myScore < opponentScore) {
|
|
||||||
myTeamUpdate['losses'] = (myTeamUpdate['losses'] ?? 0) + 1; oppTeamUpdate['wins'] = (oppTeamUpdate['wins'] ?? 0) + 1;
|
|
||||||
} else {
|
|
||||||
myTeamUpdate['draws'] = (myTeamUpdate['draws'] ?? 0) + 1; oppTeamUpdate['draws'] = (oppTeamUpdate['draws'] ?? 0) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
await supabase.from('teams').update({'wins': myTeamUpdate['wins'], 'losses': myTeamUpdate['losses'], 'draws': myTeamUpdate['draws']}).eq('id', myTeamDbId!);
|
|
||||||
await supabase.from('teams').update({'wins': oppTeamUpdate['wins'], 'losses': oppTeamUpdate['losses'], 'draws': oppTeamUpdate['draws']}).eq('id', oppTeamDbId!);
|
|
||||||
|
|
||||||
gameWasAlreadyFinished = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Map<String, dynamic>> batchStats = [];
|
List<Map<String, dynamic>> batchStats = [];
|
||||||
playerStats.forEach((playerId, stats) {
|
playerStats.forEach((playerId, stats) {
|
||||||
if (!playerId.startsWith("fake_") && stats.values.any((val) => val > 0)) {
|
if (!playerId.startsWith("fake_")) {
|
||||||
bool isMyTeamPlayer = myCourt.contains(playerId) || myBench.contains(playerId);
|
bool isMyTeamPlayer = myCourt.contains(playerId) || myBench.contains(playerId);
|
||||||
batchStats.add({
|
batchStats.add({
|
||||||
'game_id': gameId, 'member_id': playerId, 'team_id': isMyTeamPlayer ? myTeamDbId! : oppTeamDbId!,
|
'game_id': gameId, 'member_id': playerId, 'team_id': isMyTeamPlayer ? myTeamDbId! : oppTeamDbId!,
|
||||||
'pts': stats['pts'], 'rbs': stats['rbs'], 'ast': stats['ast'], 'stl': stats['stl'], 'blk': stats['blk'], 'tov': stats['tov'], 'fls': stats['fls'], 'fgm': stats['fgm'], 'fga': stats['fga'], 'ftm': stats['ftm'], 'fta': stats['fta'], 'orb': stats['orb'], 'drb': stats['drb'],
|
'pts': stats['pts'], 'rbs': stats['rbs'], 'ast': stats['ast'], 'stl': stats['stl'], 'blk': stats['blk'],
|
||||||
'p2m': stats['p2m'], 'p2a': stats['p2a'], 'p3m': stats['p3m'], 'p3a': stats['p3a'],
|
'tov': stats['tov'], 'fls': stats['fls'], 'fgm': stats['fgm'], 'fga': stats['fga'], 'ftm': stats['ftm'],
|
||||||
|
'fta': stats['fta'], 'orb': stats['orb'], 'drb': stats['drb'], 'p2m': stats['p2m'], 'p2a': stats['p2a'],
|
||||||
|
'p3m': stats['p3m'], 'p3a': stats['p3a'],
|
||||||
|
'so': stats['so'], 'il': stats['il'], 'li': stats['li'], 'pa': stats['pa'], 'tres_s': stats['tres_s'],
|
||||||
|
'dr': stats['dr'], 'min': stats['min'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -594,24 +539,10 @@ class PlacarController extends ChangeNotifier {
|
|||||||
await supabase.from('player_stats').delete().eq('game_id', gameId);
|
await supabase.from('player_stats').delete().eq('game_id', gameId);
|
||||||
if (batchStats.isNotEmpty) await supabase.from('player_stats').insert(batchStats);
|
if (batchStats.isNotEmpty) await supabase.from('player_stats').insert(batchStats);
|
||||||
|
|
||||||
List<Map<String, dynamic>> batchShots = [];
|
|
||||||
for (var shot in matchShots) {
|
|
||||||
if (!shot.playerId.startsWith("fake_")) {
|
|
||||||
batchShots.add({
|
|
||||||
'game_id': gameId, 'member_id': shot.playerId, 'player_name': shot.playerName,
|
|
||||||
'relative_x': shot.relativeX, 'relative_y': shot.relativeY, 'is_make': shot.isMake,
|
|
||||||
'zone': shot.zone ?? 'Desconhecida', 'points': shot.points ?? (shot.isMake ? 2 : 0),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await supabase.from('shot_locations').delete().eq('game_id', gameId);
|
|
||||||
if (batchShots.isNotEmpty) await supabase.from('shot_locations').insert(batchShots);
|
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.remove('backup_$gameId');
|
await prefs.remove('backup_$gameId');
|
||||||
|
|
||||||
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Estatísticas, Mapa de Calor e Resultados guardados com Sucesso!'), backgroundColor: Colors.green));
|
if (context.mounted) ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Guardado com Sucesso!'), backgroundColor: Colors.green));
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("Erro ao gravar estatísticas: $e");
|
debugPrint("Erro ao gravar estatísticas: $e");
|
||||||
@@ -627,4 +558,6 @@ class PlacarController extends ChangeNotifier {
|
|||||||
timer?.cancel();
|
timer?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void registerFoul(String s, String foulType, String t) {}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user