Skip to content

Resumo pós-partida (3.3.0) e correção do aviso de vida baixa - #4

Merged
guhttps merged 5 commits into
mainfrom
feature/post-match-report
Nov 3, 2026
Merged

guhttps merged 5 commits into
mainfrom
feature/post-match-report

Conversation

@guhttps

@guhttps guhttps commented Nov 3, 2026

Copy link
Copy Markdown
Owner

O que muda

Resumo pós-partida

Ao fim de cada partida, o coach salva em partidas/ e abre no navegador uma página com:

  • resultado, K/D/A, participação em abates, CS por minuto e aos 10 min, nível, placar de visão, itens finais e tempo com 1.800+ de ouro sem gastar;
  • análise do coach: 2 pontos fortes e 2 a treinar, escritos pela IA a partir dos números;
  • gráficos de CS e de ouro com as mortes marcadas;
  • linha do tempo com abates, mortes (e quem matou), itens, níveis, objetivos (com o time que pegou) e todas as falas do coach, inclusive as perguntas por voz.

Resumo de exemplo

Detalhes:

  • match_recorder.py coleta os dados; post_match_report.py monta a página (HTML autocontido, sem scripts nem recursos externos, todo texto dinâmico escapado) e chama a análise em segundo plano, sem travar o loop.
  • O resumo é salvo antes da análise e regravado quando ela chega; se a IA falhar, a página sai sem essa seção.
  • Ctrl+C no meio da partida salva um resumo parcial na hora. Trechos com menos de 3 minutos não geram resumo.
  • Novas variáveis: POST_MATCH_REPORT e POST_MATCH_OPEN. A pasta partidas/ está no .gitignore.
  • brain.py: a lógica de provedor e fallback de modelos virou _complete, reaproveitada pelas dicas e pela análise.

Bug corrigido: vida baixa nunca disparava

A Live Client API só traz championStats em activePlayer, mas a vida era lida de allPlayers, onde esse campo não existe. A vida chegava sempre como 0, o aviso de vida baixa nunca disparava e aliados e inimigos iam para a IA com vida zerada. Confirmei o formato no exemplo oficial da Riot; os testes agora usam esse formato.

Como testei

  • 83 testes (eram 46) e ruff check .
  • Simulação ponta a ponta: uma API do jogo falsa (HTTPS em 127.0.0.1:2999, no formato oficial) com uma partida de 28 min acelerada 10x, uma IA falsa compatível com OpenAI e o main.py real, com push-to-talk simulado e a voz desligada. O resumo saiu 12 s após o fim, com a análise, e a IA passou a receber a vida real (686/686). A partida simulada virou o fixture tests/fixtures/sample_match.json e o print do README.
  • Layout conferido em 1100 px e 390 px
  • scripts/build.ps1: o executável 3.3.0 abre e espera a partida
  • Partida real no LoL (não é possível daqui)

🤖 Generated with Claude Code

guhttps and others added 5 commits November 3, 2026 03:25
The Live Client API only exposes championStats on activePlayer; allPlayers
entries never have it. Health was read from the allPlayers entry, so it was
always 0, the low health trigger never fired, and every ally and enemy was
sent to the AI with 0 health. Read health from activePlayer for the local
player only and make the test fixtures match the real payload shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the provider, model fallback and error handling out of ask_coach into
_complete so a second kind of request can reuse it. ask_post_match_review
asks for 2 strengths and 2 points to train, parsed from "+"/"-" lines, with
a larger token budget than the 180 used for in-game tips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MatchRecorder keeps periodic samples (level, K/D/A, CS, unspent gold), a
timeline of kills, deaths with the killer, assists, finished items, level
milestones and objectives with the team that took them, plus every coach
reply. It also tracks CS at 10 minutes, time spent above the rich-gold
threshold, kill participation and the GameEnd result when the client
sends it. The summary now keeps the vision score and inhibitor and result
event fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the end of a match (or when a new one starts without an end) the coach
writes partidas/<date>_<champion>.html and .json, then asks the AI for the
review and rewrites the page with it, without blocking the main loop. The
page is self-contained (no scripts or external resources) and escapes
every dynamic text. Ctrl+C mid-match saves a partial report right away.
POST_MATCH_REPORT and POST_MATCH_OPEN control it; partidas/ is ignored by
git. The fixture comes from a simulated match run against the real coach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README section with a screenshot of the sample report, new .env settings,
architecture diagram and troubleshooting entry; changelog for 3.3.0;
contributing notes on previewing the report without playing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@guhttps
guhttps merged commit df27445 into main Nov 3, 2026
5 checks passed
@guhttps
guhttps deleted the feature/post-match-report branch November 3, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant