This commit is contained in:
2026-04-18 02:56:44 +01:00
parent 4f2a220cd6
commit ce25fe6499
3 changed files with 641 additions and 463 deletions

View File

@@ -192,7 +192,9 @@ class PlacarController extends ChangeNotifier {
"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,
"pa": s['pa'] ?? 0, "tres_s": s['tres_seg'] ?? 0, "dr": s['dr'] ?? 0,
"min": s['minutos_jogados'] ?? 0,
"sec": (s['minutos_jogados'] ?? 0) * 60,
};
}
@@ -206,7 +208,8 @@ class PlacarController extends ChangeNotifier {
"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,
"p2m": 0, "p2a": 0, "p3m": 0, "p3a": 0,
"so": 0, "il": 0, "li": 0, "pa": 0, "tres_s": 0, "dr": 0, "min": 0
"so": 0, "il": 0, "li": 0, "pa": 0, "tres_s": 0, "dr": 0,
"min": 0, "sec": 0
};
if (isMyTeam) {
@@ -278,6 +281,21 @@ class PlacarController extends ChangeNotifier {
timer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (durationNotifier.value.inSeconds > 0) {
durationNotifier.value -= const Duration(seconds: 1);
void addTimeToCourt(List<String> court) {
for (String id in court) {
if (playerStats.containsKey(id)) {
int currentSec = playerStats[id]!["sec"] ?? 0;
playerStats[id]!["sec"] = currentSec + 1;
playerStats[id]!["min"] = (currentSec + 1) ~/ 60;
}
}
}
addTimeToCourt(myCourt);
addTimeToCourt(oppCourt);
notifyListeners();
} else {
timer.cancel();
isRunning = false;
@@ -363,7 +381,6 @@ class PlacarController extends ChangeNotifier {
String finalAction = isMake ? "add_pts_$points" : "miss_$points";
commitStat(finalAction, targetPlayer);
notifyListeners();
}
@@ -423,6 +440,39 @@ class PlacarController extends ChangeNotifier {
isSelectingShotLocation = false; pendingAction = null; pendingPlayerId = null; notifyListeners();
}
void registerFoul(String committerData, String foulType, String victimData) {
bool isOpponent = committerData.startsWith("player_opp_");
String committerId = committerData.replaceAll("player_my_", "").replaceAll("player_opp_", "");
final committerStats = playerStats[committerId]!;
final committerName = playerNames[committerId] ?? "Jogador";
committerStats["fls"] = committerStats["fls"]! + 1;
if (isOpponent) opponentFouls++; else myFouls++;
if (foulType == "Desqualificante") {
committerStats["fls"] = 5;
}
String logText = "cometeu Falta $foulType";
if (victimData.isNotEmpty) {
String victimId = victimData.replaceAll("player_my_", "").replaceAll("player_opp_", "");
final victimStats = playerStats[victimId]!;
final victimName = playerNames[victimId] ?? "Jogador";
victimStats["so"] = victimStats["so"]! + 1;
logText += " sobre $victimName ⚠️";
} else {
logText += " (Equipa/Banco) ⚠️";
}
String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}";
playByPlay.insert(0, "P$currentQuarter - $time: $committerName $logText");
_saveLocalBackup();
notifyListeners();
}
void commitStat(String action, String playerData) {
bool isOpponent = playerData.startsWith("player_opp_");
String playerId = playerData.replaceAll("player_my_", "").replaceAll("player_opp_", "");
@@ -440,6 +490,40 @@ class PlacarController extends ChangeNotifier {
if (pts == 1) { stats["ftm"] = stats["ftm"]! + 1; stats["fta"] = stats["fta"]! + 1; }
logText = "marcou $pts pontos 🏀";
}
else if (action.startsWith("sub_pts_")) {
int ptsToAnul = int.parse(action.split("_").last);
int lastShotIndex = matchShots.lastIndexWhere((s) =>
s.playerId == playerId &&
s.isMake == true &&
s.points == ptsToAnul
);
if (lastShotIndex != -1) {
matchShots.removeAt(lastShotIndex);
if (isOpponent) opponentScore -= ptsToAnul; else myScore -= ptsToAnul;
stats["pts"] = stats["pts"]! - ptsToAnul;
if (ptsToAnul == 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;
} else if (ptsToAnul == 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;
} else if (ptsToAnul == 1) {
if(stats["ftm"]! > 0) stats["ftm"] = stats["ftm"]! - 1;
if(stats["fta"]! > 0) stats["fta"] = stats["fta"]! - 1;
}
logText = "anulou cesto de $ptsToAnul pts ⏪";
} else {
return;
}
}
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_3") { stats["fga"] = stats["fga"]! + 1; stats["p3a"] = stats["p3a"]! + 1; logText = "falhou lançamento de 3 ❌"; }
@@ -448,28 +532,30 @@ class PlacarController extends ChangeNotifier {
else if (action == "add_ast") { stats["ast"] = stats["ast"]! + 1; logText = "fez uma assistência 🤝"; }
else if (action == "add_stl") { stats["stl"] = stats["stl"]! + 1; logText = "roubou a bola 🥷"; }
else if (action == "add_blk") { stats["blk"] = stats["blk"]! + 1; logText = "fez um desarme (bloco) ✋"; }
else if (action == "add_foul") {
stats["fls"] = stats["fls"]! + 1;
if (isOpponent) opponentFouls++; else myFouls++;
logText = "cometeu falta ⚠️";
}
else if (action == "add_so") { stats["so"] = stats["so"]! + 1; logText = "sofreu uma falta 🤕"; }
else if (action == "add_il") { stats["il"] = stats["il"]! + 1; logText = "intercetou um lançamento 🛑"; }
else if (action == "add_li") { stats["li"] = stats["li"]! + 1; logText = "teve o lançamento intercetado 🚫"; }
// 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 🏀"; }
else if (action == "sub_foul") {
if (stats["fls"]! > 0) stats["fls"] = stats["fls"]! - 1;
if (isOpponent) { if (opponentFouls > 0) opponentFouls--; } else { if (myFouls > 0) myFouls--; }
logText = "teve falta anulada 🔄";
}
if (logText.isNotEmpty) {
String time = "${durationNotifier.value.inMinutes.toString().padLeft(2, '0')}:${durationNotifier.value.inSeconds.remainder(60).toString().padLeft(2, '0')}";
playByPlay.insert(0, "P$currentQuarter - $time: $name $logText");
}
_saveLocalBackup();
notifyListeners();
}
Future<void> saveGameStats(BuildContext context) async {
@@ -491,7 +577,9 @@ class PlacarController extends ChangeNotifier {
int ast = stats['ast'] ?? 0;
int rbs = stats['rbs'] ?? 0;
int minJogados = (stats['min'] ?? 0) > 0 ? stats['min']! : 40;
double minJogados = (stats['sec'] ?? 0) / 60.0;
if (minJogados <= 0) minJogados = 40.0;
int tr = rbs;
int br = stats['stl'] ?? 0;
int bp = stats['tov'] ?? 0;
@@ -530,8 +618,8 @@ class PlacarController extends ChangeNotifier {
'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'],
'so': stats['so'], 'il': stats['il'], 'li': stats['li'], 'pa': stats['pa'], 'tres_seg': stats['tres_s'],
'dr': stats['dr'], 'minutos_jogados': stats['min'],
});
}
});
@@ -558,6 +646,4 @@ class PlacarController extends ChangeNotifier {
timer?.cancel();
super.dispose();
}
void registerFoul(String s, String foulType, String t) {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -109,10 +109,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.4.1"
clock:
dependency: transitive
description:
@@ -468,18 +468,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
url: "https://pub.dev"
source: hosted
version: "0.12.17"
version: "0.12.18"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b"
url: "https://pub.dev"
source: hosted
version: "0.11.1"
version: "0.13.0"
meta:
dependency: transitive
description:
@@ -873,10 +873,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
url: "https://pub.dev"
source: hosted
version: "0.7.7"
version: "0.7.9"
typed_data:
dependency: transitive
description: