ok
This commit is contained in:
@@ -377,6 +377,42 @@ class PlacarController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// ── TROCAR JOGADORES NO CAMPO ──────────────────────────────────────────────
|
||||
void swapCourtPlayers(String draggedPlayerData, String targetPlayerData) {
|
||||
// Verifica se são da mesma equipa (Minha Equipa)
|
||||
if (draggedPlayerData.startsWith("player_my_") && targetPlayerData.startsWith("player_my_")) {
|
||||
String id1 = draggedPlayerData.replaceAll("player_my_", "");
|
||||
String id2 = targetPlayerData.replaceAll("player_my_", "");
|
||||
|
||||
int idx1 = myCourt.indexOf(id1);
|
||||
int idx2 = myCourt.indexOf(id2);
|
||||
|
||||
if (idx1 != -1 && idx2 != -1) {
|
||||
myCourt[idx1] = id2;
|
||||
myCourt[idx2] = id1;
|
||||
}
|
||||
}
|
||||
// Verifica se são da mesma equipa (Adversário)
|
||||
else if (draggedPlayerData.startsWith("player_opp_") && targetPlayerData.startsWith("player_opp_")) {
|
||||
String id1 = draggedPlayerData.replaceAll("player_opp_", "");
|
||||
String id2 = targetPlayerData.replaceAll("player_opp_", "");
|
||||
|
||||
int idx1 = oppCourt.indexOf(id1);
|
||||
int idx2 = oppCourt.indexOf(id2);
|
||||
|
||||
if (idx1 != -1 && idx2 != -1) {
|
||||
oppCourt[idx1] = id2;
|
||||
oppCourt[idx2] = id1;
|
||||
}
|
||||
} else {
|
||||
// Se forem de equipas diferentes ou dados inválidos, ignora.
|
||||
return;
|
||||
}
|
||||
|
||||
_scheduleAutoSave();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void registerShotFromPopup(BuildContext context, String action, String targetPlayer, String zone, int points, double relativeX, double relativeY) {
|
||||
String playerId = targetPlayer.replaceAll("player_my_", "").replaceAll("player_opp_", "");
|
||||
bool isMake = action.startsWith("add_");
|
||||
@@ -672,7 +708,8 @@ class PlacarController extends ChangeNotifier {
|
||||
_autoSaveTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
Future<void> saveGameStats(BuildContext context) async {
|
||||
|
||||
Future<void> saveGameStats(BuildContext context) async {
|
||||
final supabase = Supabase.instance.client;
|
||||
isSaving = true;
|
||||
notifyListeners();
|
||||
@@ -784,7 +821,7 @@ Future<void> saveGameStats(BuildContext context) async {
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Preparar os Locais dos Lançamentos (MAPA DE CALOR) - O QUE FALTAVA
|
||||
// 3. Preparar os Locais dos Lançamentos (MAPA DE CALOR)
|
||||
List<Map<String, dynamic>> batchShots = [];
|
||||
for (var shot in matchShots) {
|
||||
if (!shot.playerId.startsWith("fake_")) {
|
||||
|
||||
Reference in New Issue
Block a user