Squadra e Profilo: ace, attacchi, muri e punti dai + dello scout
Squadra → Stats: punti, ace e muri di squadra sommano i + delle valutazioni scout di tutte le partite. Profilo → Season: al posto di «Turni palloni» compaiono Attacchi, Muri, Ace e Punti (totale) del giocatore. Le partite del metodo precedente contano con le azioni. DD-008 aggiornata: dati solo informativi, fuori da badge e classifiche. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
263621456d
commit
1e4ec9113e
8 files changed
+130
-4
No files matched your search
@@ -291,6 +291,46 @@ export function totaliSquadra(matches: ScoutMatch[]) {
|
||||
return out;
|
||||
}
|
||||
|
||||
export type TotaliTecnici = { punti: number; ace: number; attacchi: number; muri: number };
|
||||
|
||||
/**
|
||||
* Somma, su tutte le partite scoutate, delle sole valutazioni **+** (battuta → ace, attacco →
|
||||
* attacchi, muro → muri; punti = ace + attacchi + muri, non la ricezione). Con `giocatoreId`
|
||||
* conta solo quel giocatore, altrimenti tutta la squadra. Una partita senza valutazioni (metodo
|
||||
* precedente) conta con le sue azioni; se ha entrambe valgono solo le valutazioni, per non
|
||||
* contare due volte.
|
||||
*/
|
||||
export function totaliTecnici(matches: ScoutMatch[], giocatoreId?: string): TotaliTecnici {
|
||||
const out = { punti: 0, ace: 0, attacchi: 0, muri: 0 };
|
||||
for (const m of matches) {
|
||||
if (m.valutazioni.length === 0) {
|
||||
for (const [id, t] of totaliPerGiocatore(m.azioni)) {
|
||||
if (giocatoreId !== undefined && id !== giocatoreId) continue;
|
||||
out.ace += t.ace;
|
||||
out.muri += t.muri;
|
||||
out.attacchi += t.punti - t.ace - t.muri;
|
||||
out.punti += t.punti;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (const v of m.valutazioni) {
|
||||
if (v.segno !== "+" || v.fondamentale === "ricezione") continue;
|
||||
if (giocatoreId !== undefined && v.giocatoreId !== giocatoreId) continue;
|
||||
if (v.fondamentale === "battuta") out.ace += 1;
|
||||
if (v.fondamentale === "attacco") out.attacchi += 1;
|
||||
if (v.fondamentale === "muro") out.muri += 1;
|
||||
out.punti += 1;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Punti, ace e muri di squadra per la tab Stats di `/squadra` (vedi `totaliTecnici`). */
|
||||
export function totaliSquadraValutazioni(matches: ScoutMatch[]) {
|
||||
const { punti, ace, muri } = totaliTecnici(matches);
|
||||
return { punti, ace, muri };
|
||||
}
|
||||
|
||||
/**
|
||||
* MVP ricavati dalle partite scoutate (mappa matchId → nome vincitore).
|
||||
* Le presenze personali restano su `risposte_presenze`, non sullo scout.
|
||||
|
||||
@@ -33,6 +33,7 @@ import {
|
||||
type GiocatoreSquadra,
|
||||
} from "@/lib/giocatori-squadra";
|
||||
import { esci } from "@/lib/auth";
|
||||
import { totaliTecnici, useScoutMatches } from "@/lib/scout-store";
|
||||
import { useIsAdmin } from "@/lib/ruoli";
|
||||
import { useEmailNotifiche } from "@/lib/preferenze-utente";
|
||||
import { Reveal } from "@/components/motion/Reveal";
|
||||
@@ -80,9 +81,12 @@ function ProfiloGiocatore() {
|
||||
const votiSocial = useVotiSocial();
|
||||
const g = useIo();
|
||||
const ultimoMese = usePresenzeUltimoMese(g?.id);
|
||||
const scoutMatches = useScoutMatches();
|
||||
|
||||
if (!g) return null;
|
||||
|
||||
const tecnici = totaliTecnici(scoutMatches, g.id);
|
||||
|
||||
const percPresenze = g.totaliEventi ? Math.round((g.presenze / g.totaliEventi) * 100) : 0;
|
||||
|
||||
return (
|
||||
@@ -122,9 +126,12 @@ function ProfiloGiocatore() {
|
||||
}
|
||||
label="Presenze di fila"
|
||||
/>
|
||||
<StatTile valore={g.mediaVoto || "—"} label="Media voto" />
|
||||
<StatTile valore={tecnici.attacchi} label="Attacchi" />
|
||||
<StatTile valore={tecnici.muri} label="Muri" />
|
||||
<StatTile valore={tecnici.ace} label="Ace" />
|
||||
<StatTile valore={tecnici.punti} label="Punti" hint="totale" />
|
||||
<StatTile valore={g.mvp} label="MVP" />
|
||||
<StatTile valore={g.palloni} label="Turni palloni" />
|
||||
<StatTile valore={g.mediaVoto || "—"} label="Media voto" />
|
||||
</div>
|
||||
<SerieGriglia g={g} />
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
useGiocatoriSquadra,
|
||||
} from "@/lib/giocatori-squadra";
|
||||
import { useSonoAllenatore } from "@/lib/user-store";
|
||||
import { totaliSquadra, useScoutMatches } from "@/lib/scout-store";
|
||||
import { totaliSquadraValutazioni, useScoutMatches } from "@/lib/scout-store";
|
||||
import { useCsi } from "@/lib/csi";
|
||||
import { partiteGiocate } from "@/lib/csi-core";
|
||||
import { mediaSquadra, usePagelle } from "@/lib/pagelle";
|
||||
@@ -110,7 +110,7 @@ function Squadra() {
|
||||
const [criterio, setCriterio] = useState<Criterio>("presenze");
|
||||
const [filtroAperto, setFiltroAperto] = useState(false);
|
||||
const obiettivi = useObiettivi();
|
||||
const team = totaliSquadra(scoutMatches);
|
||||
const team = totaliSquadraValutazioni(scoutMatches);
|
||||
const mediaPresenze = rosa.length
|
||||
? Math.round(
|
||||
(rosa.reduce((s, g) => s + g.presenze / (g.totaliEventi || 1), 0) / rosa.length) * 100,
|
||||
|
||||
Reference in new issue
Block a user