Dodaj igru Superheroji (glasovna) + admin tab
Igra: 1-5 igrača, nekoliko rundi (konfigurabilno). Svaku rundu svaki igrač kaže izmišljenog lika (širok pojam — bilo koji medij), Idriz presudi ko bi pobijedio i zašto. Pobjednik runde se banuje do kraja partije. Redoslijed se rotira svaku rundu (zadnji ima prednost). Najviše pobjeda runda = pobjednik partije. - idriz/gamestore.py: trajno skladište (heroji, Elo rejting, broj rundi), bez vanjskih zavisnosti (i admin ga uvozi). clear_favorite() drži borbe dosljedne kroz partije (jači heroj ne gubi od znatno slabijeg). - idriz/game.py: resolve_hero (najjači LLM gpt-5.5 + web search fallback samo kad ne zna lika), adjudicate (presuda + obrazloženje na bosanskom), Match (tok partije). - assistant.py: 4 realtime alata (nova_partija, izbor, presudi, kraj) + upute; igra ide odmah nazad modelu, ne kroz pozadinski posao. - config.py: game_model (default = text_model). - admin: tab "Superheroji" (broj rundi + rang-lista + reset pamćenja). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LzKpYaEsuWDevuNnvSjcFW
This commit is contained in:
37
admin/app.py
37
admin/app.py
@@ -7,14 +7,20 @@ Prijava ide preko PAM-a (Linux korisnik `idriz`).
|
||||
import os
|
||||
import secrets
|
||||
import subprocess
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
|
||||
import pam as pam_module
|
||||
from flask import (
|
||||
Flask, render_template, request, redirect, url_for, session, flash
|
||||
)
|
||||
|
||||
# Pristup skladištu igre (bez openai zavisnosti) iz glavnog idriz paketa.
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from idriz import gamestore # noqa: E402
|
||||
|
||||
# --- Konfiguracija -----------------------------------------------------------
|
||||
|
||||
# Samo ovaj Linux korisnik smije da se prijavi.
|
||||
@@ -195,6 +201,37 @@ def status():
|
||||
)
|
||||
|
||||
|
||||
@app.route("/superheroji", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def superheroji():
|
||||
if request.method == "POST":
|
||||
action = request.form.get("action")
|
||||
if action == "rounds":
|
||||
try:
|
||||
n = int(request.form.get("rounds", ""))
|
||||
saved = gamestore.save_rounds(n)
|
||||
flash(f"Broj rundi postavljen na {saved}.")
|
||||
except (ValueError, TypeError):
|
||||
flash("Neispravan broj rundi.")
|
||||
elif action == "reset":
|
||||
store = gamestore.HeroStore()
|
||||
store.heroes = {}
|
||||
store.aliases = {}
|
||||
store.save()
|
||||
flash("Pamćenje jačina heroja je obrisano.")
|
||||
return redirect(url_for("superheroji"))
|
||||
|
||||
store = gamestore.HeroStore()
|
||||
return render_template(
|
||||
"superheroji.html",
|
||||
rounds=gamestore.load_rounds(),
|
||||
min_rounds=gamestore.MIN_ROUNDS,
|
||||
max_rounds=gamestore.MAX_ROUNDS,
|
||||
heroes=store.leaderboard(),
|
||||
active_page="superheroji",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from waitress import serve
|
||||
print(f"Idriz admin na http://{LISTEN_HOST}:{LISTEN_PORT}")
|
||||
|
||||
@@ -98,6 +98,9 @@
|
||||
<a href="{{ url_for('status') }}" class="{{ 'active' if active_page == 'status' else '' }}">
|
||||
<span class="icon">●</span> Status servisa
|
||||
</a>
|
||||
<a href="{{ url_for('superheroji') }}" class="{{ 'active' if active_page == 'superheroji' else '' }}">
|
||||
<span class="icon">★</span> Superheroji
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-foot">
|
||||
{% if session.user %}<a href="{{ url_for('logout') }}">↩ Odjava</a>{% endif %}
|
||||
|
||||
66
admin/templates/superheroji.html
Normal file
66
admin/templates/superheroji.html
Normal file
@@ -0,0 +1,66 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Superheroji — Idriz Admin{% endblock %}
|
||||
{% block extra_css %}
|
||||
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
|
||||
padding: 20px 22px; margin-bottom: 22px; max-width: 640px; }
|
||||
.panel h2 { margin: 0 0 4px; font-size: 16px; }
|
||||
.panel p.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
|
||||
.row { display: flex; align-items: center; gap: 12px; }
|
||||
input[type=number] { width: 90px; padding: 9px 12px; font-size: 15px;
|
||||
border: 1px solid var(--line); border-radius: 8px; }
|
||||
button { padding: 9px 18px; font-size: 14px; font-weight: 600; color: #fff;
|
||||
background: var(--accent); border: none; border-radius: 8px; cursor: pointer; }
|
||||
button:hover { filter: brightness(1.05); }
|
||||
button.danger { background: var(--bad); }
|
||||
table { width: 100%; border-collapse: collapse; background: var(--panel);
|
||||
border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-width: 640px; }
|
||||
th, td { text-align: left; padding: 10px 14px; font-size: 14px; }
|
||||
th { background: #fafbfc; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
|
||||
tr:not(:last-child) td { border-bottom: 1px solid var(--line); }
|
||||
td.num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.rank { color: var(--muted); width: 30px; }
|
||||
.src { font-size: 11px; color: var(--muted); }
|
||||
.empty { color: var(--muted); font-style: italic; }
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h1>Superheroji</h1>
|
||||
<p class="sub">Podešavanje igre i pamćenje relativnih jačina likova.</p>
|
||||
|
||||
<div class="panel">
|
||||
<h2>Broj rundi po partiji</h2>
|
||||
<p class="hint">Koliko rundi traje jedna partija ({{ min_rounds }}–{{ max_rounds }}). Primjenjuje se na sljedeću partiju.</p>
|
||||
<form method="post" class="row">
|
||||
<input type="hidden" name="action" value="rounds">
|
||||
<input type="number" name="rounds" min="{{ min_rounds }}" max="{{ max_rounds }}" value="{{ rounds }}">
|
||||
<button type="submit">Sačuvaj</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<h2 style="font-size:16px; margin: 0 0 4px;">Rang-lista heroja</h2>
|
||||
<p class="sub">Snaga (rejting) raste kad heroj pobjeđuje. Idriz je koristi da borbe budu dosljedne kroz partije.</p>
|
||||
{% if heroes %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th class="rank">#</th><th>Heroj</th><th class="num">Snaga</th><th class="num">Pobjede</th><th class="num">Porazi</th><th class="num">Borbi</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for h in heroes %}
|
||||
<tr>
|
||||
<td class="rank">{{ loop.index }}</td>
|
||||
<td>{{ h.name }} {% if h.source == 'web' %}<span class="src">(web)</span>{% endif %}</td>
|
||||
<td class="num">{{ h.rating }}</td>
|
||||
<td class="num">{{ h.wins }}</td>
|
||||
<td class="num">{{ h.losses }}</td>
|
||||
<td class="num">{{ h.games }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<form method="post" onsubmit="return confirm('Obrisati sve zapamćene jačine heroja? Ovo se ne može poništiti.');" style="margin-top:16px;">
|
||||
<input type="hidden" name="action" value="reset">
|
||||
<button type="submit" class="danger">Obriši pamćenje</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="empty">Još nema odigranih borbi. Rang-lista se puni kako djeca igraju.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user