Bestenliste, Expeditionen, Ereignisse, Dreizack und Netz, aufrechte Schilde, dunkle Haut

Stand von main 82292b5c.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 14:53:03 +01:00
parent bdcf9a4a2c
commit 62bc7cc8b3
13 changed files with 751 additions and 31 deletions

View File

@@ -115,7 +115,8 @@ namespace GladiatorIdle
string picks = string.Join(",", st.Picks.OrderBy(p => p.Key).Select(p => $"{p.Key}:{p.Value}")); string picks = string.Join(",", st.Picks.OrderBy(p => p.Key).Select(p => $"{p.Key}:{p.Value}"));
DevShot.Log($"arena {arena} done at {H(time)} (+{(time - st.Start) / 60:0} min): fights={st.Fights} W/L={st.Wins}/{st.Losses} " + DevShot.Log($"arena {arena} done at {H(time)} (+{(time - st.Start) / 60:0} min): fights={st.Fights} W/L={st.Wins}/{st.Losses} " +
$"auto={st.Autos} champTries={st.ChampTries} picks=[{picks}] avgRatio={st.RatioSum / Math.Max(1, st.RatioN):0.00} " + $"auto={st.Autos} champTries={st.ChampTries} picks=[{picks}] avgRatio={st.RatioSum / Math.Max(1, st.RatioN):0.00} " +
$"lv={gs.CharLevel} pow={gs.Power():0.##e0}"); $"lv={gs.CharLevel} pow={gs.Power():0.##e0} exp=[" +
string.Join(",", RegionDef.All.Where(gs.RegionOpen).Select(r => $"{r.Id}:{gs.ExpeditionChance(r):P0}")) + "]");
} }
} }
} }

View File

@@ -524,5 +524,21 @@
"duel.super": "RASEREI!", "duel.super": "RASEREI!",
"duel.super.ready": "Wut voll – drück R!", "duel.super.ready": "Wut voll – drück R!",
"duel.super.key": "R: RASEREI", "duel.super.key": "R: RASEREI",
"duel.rage": "Wut" "duel.rage": "Wut",
"menu.leaderboard": "Bestenliste",
"lb.title": "Bestenliste",
"lb.tab.power": "Stärkste Gladiatoren",
"lb.tab.fastest": "Schnellste Freiheit",
"lb.loading": "Bestenliste wird geladen …",
"lb.offline": "Die Bestenliste ist gerade nicht erreichbar.",
"lb.retry": "Nochmal versuchen",
"lb.empty": "Noch keine Einträge – sei der Erste!",
"lb.empty.fastest": "Noch hat niemand die Freiheit errungen.",
"lb.back": "Zurück",
"lb.col.rank": "#",
"lb.col.name": "Name",
"lb.col.class": "Klasse",
"lb.col.freedoms": "Freiheiten",
"lb.you": "du",
"lb.yourrank": "Dein Platz: {0} von {1}"
} }

View File

@@ -524,5 +524,21 @@
"duel.super": "FURY!", "duel.super": "FURY!",
"duel.super.ready": "Fury ready – press R!", "duel.super.ready": "Fury ready – press R!",
"duel.super.key": "R: FURY ATTACK", "duel.super.key": "R: FURY ATTACK",
"duel.rage": "Fury" "duel.rage": "Fury",
"menu.leaderboard": "Leaderboard",
"lb.title": "Leaderboard",
"lb.tab.power": "Strongest gladiators",
"lb.tab.fastest": "Fastest freedom",
"lb.loading": "Loading the leaderboard…",
"lb.offline": "The leaderboard is not reachable right now.",
"lb.retry": "Try again",
"lb.empty": "No entries yet – be the first!",
"lb.empty.fastest": "Nobody has won their freedom yet.",
"lb.back": "Back",
"lb.col.rank": "#",
"lb.col.name": "Name",
"lb.col.class": "Class",
"lb.col.freedoms": "Freedoms",
"lb.you": "you",
"lb.yourrank": "Your rank: {0} of {1}"
} }

View File

@@ -524,5 +524,21 @@
"duel.super": "¡FURIA!", "duel.super": "¡FURIA!",
"duel.super.ready": "Furia lista: ¡pulsa R!", "duel.super.ready": "Furia lista: ¡pulsa R!",
"duel.super.key": "R: ATAQUE DE FURIA", "duel.super.key": "R: ATAQUE DE FURIA",
"duel.rage": "Furia" "duel.rage": "Furia",
"menu.leaderboard": "Clasificación",
"lb.title": "Clasificación",
"lb.tab.power": "Gladiadores más fuertes",
"lb.tab.fastest": "Libertad más rápida",
"lb.loading": "Cargando la clasificación…",
"lb.offline": "La clasificación no está disponible ahora.",
"lb.retry": "Reintentar",
"lb.empty": "Aún no hay entradas: ¡sé el primero!",
"lb.empty.fastest": "Nadie ha ganado aún su libertad.",
"lb.back": "Volver",
"lb.col.rank": "#",
"lb.col.name": "Nombre",
"lb.col.class": "Clase",
"lb.col.freedoms": "Libertades",
"lb.you": "tú",
"lb.yourrank": "Tu puesto: {0} de {1}"
} }

View File

@@ -25,11 +25,13 @@ namespace GladiatorIdle.Arena
void InitModel(int color) void InitModel(int color)
{ {
_model = Model3D.Load(_art); _model = Model3D.Load(_art);
bool own = _model != null;
foreach (var alt in Fallbacks(_art)) _model ??= Model3D.Load(alt); foreach (var alt in Fallbacks(_art)) _model ??= Model3D.Load(alt);
_model ??= Model3D.Load(DefaultModel); _model ??= Model3D.Load(DefaultModel);
// Vorlage mit dunkler Haut, aber noch ohne eigenes Modell: Haut des Ersatzmodells abdunkeln
if (!own && _model != null && DarkSkin.Contains(_art)) _model.SetSkin(1);
if (_model == null || _model.Clips.Count == 0) { _model = null; return; } if (_model == null || _model.Clips.Count == 0) { _model = null; return; }
_model.AddSword(); _model.Arm(_art);
_model.AddShield();
_model.SetColor(color); _model.SetColor(color);
var idle = Clip3("idle"); var idle = Clip3("idle");
_model.Pose(idle, 0, true); _model.Pose(idle, 0, true);
@@ -49,6 +51,10 @@ namespace GladiatorIdle.Arena
_mfx.SpecularPower = 24; _mfx.SpecularPower = 24;
} }
/// Aussehen-Vorlagen mit dunkler Haut (Bilder hero_<klasse>_2).
static readonly System.Collections.Generic.HashSet<string> DarkSkin = new()
{ "hero_murmillo_2", "hero_secutor_2", "hero_thraex_2", "hero_retiarius_2" };
/// Figuren ohne eigenes Modell: eine ähnliche vorhandene (in eigener Teamfarbe), bis es eines gibt. /// Figuren ohne eigenes Modell: eine ähnliche vorhandene (in eigener Teamfarbe), bis es eines gibt.
static System.Collections.Generic.IEnumerable<string> Fallbacks(string art) static System.Collections.Generic.IEnumerable<string> Fallbacks(string art)
{ {

View File

@@ -0,0 +1,204 @@
using System;
using System.Linq;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// Expeditionen (Schublade: Regionen, Dauer, Aufbruch; unterwegs: Fortschritt statt Gegnerwahl),
/// Rückkehr-Bericht und Ereignis-Karten mit Entscheidungen (beides als Fenster über dem Hub),
/// dazu die laufenden Segen unter der Kopfleiste.
internal sealed partial class HubScene
{
string _expRegion = "gallia";
int _expDuration;
string? _eventShown; // Ereignis, dessen Karte offen ist
string? _eventOutcome; // Text-Key des Ausgangs, nach der Entscheidung
string? _eventSeen; // für den Klang beim Erscheinen
static string DurationLabel(int i) => NumberFormat.Duration(Adventures.Durations[i]);
static int LootCount(int duration) => 1 + 2 * duration;
static Color ChanceColor(double c) => c >= 0.75 ? D.Green : c >= 0.4 ? D.Gold : D.Red;
/// Ein Fenster liegt über dem Hub (Bericht oder Ereignis): darunter nichts anklickbar.
bool Modal => _game.ExpeditionResult != null || _game.PendingEvent != null || _eventShown != null;
void UpdateAdventure()
{
if (_game.PendingEvent is string id && _eventSeen != id) { _eventSeen = id; SoundManager.PlayChapterSting(); }
}
Texture2D? Picture(string art) => Assets.Sprite(art, "jpg");
static void DrawPicture(SpriteBatch sb, Texture2D? tex, RectangleF r, float alpha = 1)
{
if (tex == null) { D.Rect(sb, r, new Color(30, 22, 15)); return; }
// "cover": Bild füllt das Rechteck, mittig beschnitten
float k = MathF.Max(r.Width / tex.Width, r.Height / tex.Height);
int sw = (int)(r.Width / k), sh = (int)(r.Height / k);
var src = new Rectangle((tex.Width - sw) / 2, (tex.Height - sh) / 2, sw, sh);
sb.Draw(tex, new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height), src, Color.White * alpha);
}
// ── Schublade: Regionen und Aufbruch ────────────────────────
void DrawExpeditions(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, w = r.Width - 60, y = r.Y + 40;
D.Text(sb, Assets.Serif, 34, L.t("exp.title"), new Vector2(x, y), D.Gold);
D.TextWrap(sb, Assets.Sans, 17, L.t("exp.intro"), new RectangleF(x, y + 26, w, 44), D.Sand);
if (_game.Away == null && !_game.RegionOpen(RegionDef.Get(_expRegion)))
_expRegion = RegionDef.All.Last(reg => _game.RegionOpen(reg)).Id;
const float GX = 20, GY = 18;
float cw = (w - 2 * GX) / 3, ch = 250, y0 = y + 84;
for (int i = 0; i < RegionDef.All.Length; i++)
{
var reg = RegionDef.All[i];
var cr = new RectangleF(x + i % 3 * (cw + GX), y0 + i / 3 * (ch + GY), cw, ch);
bool open = _game.RegionOpen(reg), sel = reg.Id == (_game.Away?.Region ?? _expRegion);
D.Rect(sb, cr, new Color(24, 18, 12) * 0.95f);
DrawPicture(sb, Picture(reg.Art), new RectangleF(cr.X + 5, cr.Y + 5, cr.Width - 10, ch - 80), open ? 1 : 0.3f);
D.Text(sb, Assets.Serif, 22, L.t(reg.Key).ToUpperInvariant(), new Vector2(cr.X + 14, cr.Bottom - 54), open ? D.Gold : D.Dim);
string info = open ? string.Format(L.t("exp.chance"), NumberFormat.Percent(_game.ExpeditionChance(reg)))
: string.Format(L.t("exp.locked"), L.t(ArenaDef.All[reg.Unlock].Key));
D.Text(sb, Assets.Sans, 16, info, new Vector2(cr.X + 14, cr.Bottom - 24), open ? ChanceColor(_game.ExpeditionChance(reg)) : D.Dim);
D.Frame(sb, cr, sel ? D.Gold : D.Border, sel ? 4 : 2);
if (open && _game.Away == null && _ui.Hover(cr) && _ui.Hit(cr)) { _expRegion = reg.Id; SoundManager.PlayClick(); }
}
float by = y0 + 2 * (ch + GY) + 10;
if (_game.Away is { } a) { DrawAwayStatus(sb, new RectangleF(x, by, w, 80), a); return; }
float bw = 240;
for (int d = 0; d < 3; d++)
if (_ui.Button(sb, new RectangleF(x + d * (bw + 12), by + 6, bw, 60), string.Format(L.t("exp.duration"), DurationLabel(d), LootCount(d)),
selected: _expDuration == d, size: 18))
_expDuration = d;
if (_ui.Button(sb, new RectangleF(x + w - 300, by + 6, 300, 60), L.t("exp.start"),
_game.RegionOpen(RegionDef.Get(_expRegion)) && !_game.FreedomEarned, selected: true, size: 24, accent: D.Gold))
if (_game.StartExpedition(_expRegion, _expDuration)) { SoundManager.PlayStart(); _drawer = Drawer.None; }
}
void DrawAwayStatus(SpriteBatch sb, RectangleF r, Expedition a)
{
var reg = RegionDef.Get(a.Region);
double total = Adventures.Durations[a.Duration];
float bw = r.Width - 380;
D.Text(sb, Assets.SansBold, 22, string.Format(L.t("exp.away"), L.t(reg.Key)), new Vector2(r.X, r.Y + 14), D.Gold);
D.Text(sb, Assets.Sans, 18, string.Format(L.t("exp.left"), NumberFormat.Duration(a.Left)), new Vector2(r.X, r.Y + 44), D.Sand);
D.Bar(sb, new RectangleF(r.X, r.Y + 64, bw, 14), (float)(1 - a.Left / total), (float)(1 - a.Left / total), D.Gold);
if (_ui.Button(sb, new RectangleF(r.Right - 340, r.Y + 10, 340, 60), L.t("exp.recall"), size: 18, accent: D.Red))
{ _game.Recall(); SoundManager.PlayBoo(); }
}
/// Statt der Gegnerwahl, solange der Gladiator unterwegs ist: Bild der Region und Fortschritt.
void DrawAwayCard(SpriteBatch sb, Expedition a)
{
var reg = RegionDef.Get(a.Region);
var r = new RectangleF(Camera.W - 860, 150, 820, 640);
Ui.Panel(sb, r, D.Gold, 0.92f);
DrawPicture(sb, Picture(reg.Art), new RectangleF(r.X + 20, r.Y + 20, r.Width - 40, 430));
DrawAwayStatus(sb, new RectangleF(r.X + 30, r.Y + 470, r.Width - 60, 90), a);
}
// ── Segen ───────────────────────────────────────────────────
void DrawBuffs(SpriteBatch sb)
{
float y = 136;
foreach (var b in _game.Buffs)
{
string text = string.Format(L.t("buff." + b.Kind.ToString().ToLowerInvariant()), NumberFormat.Percent(b.Mult - 1), NumberFormat.Duration(b.Left));
D.Text(sb, Assets.SansBold, 17, text, new Vector2(40, y), D.Blue);
y += 24;
}
}
// ── Fenster: Rückkehr-Bericht und Ereignis ──────────────────
void DrawModal(SpriteBatch sb)
{
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.65f);
if (_game.ExpeditionResult is { } rep) DrawReport(sb, rep);
else if (_eventShown != null || _game.PendingEvent != null) DrawEvent(sb);
}
void DrawReport(SpriteBatch sb, ExpeditionReport rep)
{
var reg = RegionDef.Get(rep.Region);
var r = new RectangleF(Camera.W / 2 - 520, 70, 1040, 940);
Ui.Panel(sb, r, rep.Success ? D.Gold : D.Red, 0.97f);
DrawPicture(sb, Picture(reg.Art), new RectangleF(r.X + 30, r.Y + 30, r.Width - 60, 300));
float y = r.Y + 370;
D.Text(sb, Assets.Serif, 36, string.Format(L.t(rep.Success ? "exp.back.ok" : "exp.back.fail"), L.t(reg.Key)),
new Vector2(r.Center.X, y), rep.Success ? D.Gold : D.Red, Align.Center);
y += 44;
if (!rep.Success) { D.Text(sb, Assets.Sans, 18, L.t("exp.back.failtext"), new Vector2(r.Center.X, y), D.Sand, Align.Center); y += 34; }
foreach (int n in rep.Log)
{
D.TextWrap(sb, Assets.Serif, 19, "· " + L.t("expedition.log." + n), new RectangleF(r.X + 80, y - 10, r.Width - 160, 40), D.Sand); // i18n-ok
y += 32;
}
y += 14;
void Line(string label, string value)
{
D.Text(sb, Assets.Sans, 20, label, new Vector2(r.X + 220, y), D.Dim);
D.Text(sb, Assets.SansBold, 22, value, new Vector2(r.Right - 220, y), D.Sand, Align.Right);
y += 34;
}
Line(L.t("exp.reward.gold"), "+" + NumberFormat.Format(rep.Gold)); // i18n-ok
Line(L.t("exp.reward.fame"), "+" + NumberFormat.Format(rep.Fame)); // i18n-ok
Line(L.t("exp.reward.xp"), "+" + NumberFormat.Format(rep.Xp)); // i18n-ok
if (rep.Loot.Count > 0)
{
float size = 88, lx = r.Center.X - (rep.Loot.Count * (size + 12) - 12) / 2;
for (int i = 0; i < rep.Loot.Count; i++) ItemTile(sb, new RectangleF(lx + i * (size + 12), y + 4, size, size), rep.Loot[i], false);
}
if (_ui.Button(sb, new RectangleF(r.Center.X - 170, r.Bottom - 80, 340, 60), L.t("exp.ok"), selected: true, size: 24))
{ _game.DismissExpeditionResult(); SoundManager.PlayCoins(); }
}
void DrawEvent(SpriteBatch sb)
{
_eventShown ??= _game.PendingEvent;
var ev = Adventures.GetEvent(_eventShown!);
var r = new RectangleF(Camera.W / 2 - 700, 110, 1400, 860);
Ui.Panel(sb, r, D.Gold, 0.97f);
var pic = new RectangleF(r.X + 34, r.Y + 34, 640, 360);
DrawPicture(sb, Picture(ev.Art), pic);
D.Frame(sb, pic, D.Border, 2);
float tx = pic.Right + 34, tw = r.Right - 34 - tx;
D.TextWrap(sb, Assets.Serif, 34, L.t(ev.Title), new RectangleF(tx, r.Y + 30, tw, 100), D.Gold);
D.TextWrap(sb, Assets.Serif, 21, L.t(ev.Text), new RectangleF(tx, r.Y + 140, tw, 250), D.Sand);
float y = pic.Bottom + 34;
if (_eventOutcome != null)
{
D.TextWrap(sb, Assets.Serif, 26, L.t(_eventOutcome), new RectangleF(r.X + 80, y + 20, r.Width - 160, 200), new Color(245, 236, 214));
if (_ui.Button(sb, new RectangleF(r.Center.X - 170, r.Bottom - 90, 340, 62), L.t("event.ok"), selected: true, size: 24))
{ _eventShown = null; _eventOutcome = null; SoundManager.PlayClick(); }
return;
}
for (int i = 0; i < ev.Choices.Length; i++)
{
var c = ev.Choices[i];
double cost = _game.ChoiceCost(c);
string label = L.t(ev.ChoiceKey(c));
if (cost > 0) label += " · " + string.Format(L.t("event.cost"), NumberFormat.Format(cost)); // i18n-ok
if (c.Chance < 1) label += " · " + L.t("event.risky") + " " + NumberFormat.Percent(c.Chance); // i18n-ok
if (_ui.Button(sb, new RectangleF(r.X + 60, y, r.Width - 120, 64), label, _game.Gold >= cost, size: 21))
{
var outcome = _game.Choose(i);
if (outcome != null)
{
_eventOutcome = outcome;
if (outcome.EndsWith(".fail", StringComparison.Ordinal)) SoundManager.PlayBoo(); else SoundManager.PlayGoodEvent();
}
}
y += 76;
}
}
}
}

View File

@@ -15,7 +15,7 @@ namespace GladiatorIdle.Arena
/// </summary> /// </summary>
internal sealed partial class HubScene internal sealed partial class HubScene
{ {
enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall } enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall, Expedition }
readonly GameState _game; readonly GameState _game;
readonly Ui _ui = new(); readonly Ui _ui = new();
@@ -72,6 +72,7 @@ namespace GladiatorIdle.Arena
_ui.Begin(input, ui); _ui.Begin(input, ui);
_game.Tick(dt); // Training, Einnahmen, Erholung _game.Tick(dt); // Training, Einnahmen, Erholung
_hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion); _hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
UpdateAdventure();
_crowd.Update(dt); _crowd.Update(dt);
_fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H); _fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H);
_fx.Update(dt); _fx.Update(dt);
@@ -136,10 +137,15 @@ namespace GladiatorIdle.Arena
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui); sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
DrawTopBar(sb); DrawTopBar(sb);
if (_drawerK < 0.98f) DrawOffers(sb); DrawBuffs(sb);
DrawDrawerButtons(sb); if (Modal) DrawModal(sb); // Bericht oder Ereignis: darunter nichts anklickbar
DrawToast(sb); else
if (_drawerK > 0.01f) DrawDrawer(sb); {
if (_drawerK < 0.98f) { if (_game.Away is { } away) DrawAwayCard(sb, away); else DrawOffers(sb); }
DrawDrawerButtons(sb);
DrawToast(sb);
if (_drawerK > 0.01f) DrawDrawer(sb);
}
sb.End(); sb.End();
} }
@@ -299,6 +305,10 @@ namespace GladiatorIdle.Arena
if (_ui.Button(sb, new RectangleF(1024, y, 230, 60), string.Format(L.t("hall.button"), _game.Legends.Count), selected: _drawer == Drawer.Hall, if (_ui.Button(sb, new RectangleF(1024, y, 230, 60), string.Format(L.t("hall.button"), _game.Legends.Count), selected: _drawer == Drawer.Hall,
size: 22, accent: open > 0 || _game.GodFavor > 0 ? D.Purple : null)) size: 22, accent: open > 0 || _game.GodFavor > 0 ? D.Purple : null))
_drawer = _drawer == Drawer.Hall ? Drawer.None : Drawer.Hall; _drawer = _drawer == Drawer.Hall ? Drawer.None : Drawer.Hall;
string ex = _game.Away != null ? $"{L.t("exp.button")} · {NumberFormat.Duration(_game.Away.Left)}" : L.t("exp.button"); // i18n-ok
if (_ui.Button(sb, new RectangleF(1270, y, 300, 60), ex, selected: _drawer == Drawer.Expedition, size: 22,
accent: _game.Away != null ? D.Gold : null))
_drawer = _drawer == Drawer.Expedition ? Drawer.None : Drawer.Expedition;
} }
void DrawDrawer(SpriteBatch sb) void DrawDrawer(SpriteBatch sb)
@@ -311,6 +321,7 @@ namespace GladiatorIdle.Arena
else if (_drawer == Drawer.Forum) DrawForum(sb, r); else if (_drawer == Drawer.Forum) DrawForum(sb, r);
else if (_drawer == Drawer.Skills) DrawSkills(sb, r); else if (_drawer == Drawer.Skills) DrawSkills(sb, r);
else if (_drawer == Drawer.Hall) DrawHall(sb, r); else if (_drawer == Drawer.Hall) DrawHall(sb, r);
else if (_drawer == Drawer.Expedition) DrawExpeditions(sb, r);
} }
static float Ease(float k) => 1 - (1 - k) * (1 - k); static float Ease(float k) => 1 - (1 - k) * (1 - k);

View File

@@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GladiatorIdle.Gfx;
using GladiatorIdle.Net;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// <summary>
/// Bestenliste (aus dem Hauptmenü): Siegertreppchen für die drei Besten, darunter die Plätze 4–15.
/// Zwei Wertungen: stärkste Gladiatoren (beste Kampfkraft) und schnellste Freiheit. Der eigene
/// Eintrag leuchtet; steht er nicht unter den ersten 15, erscheint er unter der Liste.
/// </summary>
internal sealed class LeaderboardScene
{
enum Tab { Power, Fastest }
readonly Ui _ui = new();
readonly Particles _fx = new();
readonly Texture2D? _backdrop = Assets.Sprite("arena_colosseum", "jpg");
readonly string _me = Leaderboard.PlayerId;
List<LeaderEntry>? _all;
bool _loading = true, _offline, _dev;
Tab _tab;
double _t;
public bool Done { get; private set; }
public LeaderboardScene(GameState? game)
{
if (game != null) Leaderboard.Submit(game); // eigenen Stand zuerst aktualisieren
Reload();
}
void Reload()
{
_loading = true;
_ = Leaderboard.FetchAsync().ContinueWith(t =>
{
if (_dev) return;
_all = t.Result;
_offline = _all == null;
_loading = false;
});
}
/// Testläufe: Beispieleinträge statt der Datenbank (sendet und lädt nichts).
public void DevSample(GameState? game)
{
_dev = true;
var rnd = new Random(5);
string[] names = { "Spiculus", "Flamma", "Priscus", "Verus", "Carpophorus", "Tetraites", "Crixus", "Oenomaus", "Gannicus", "Varro", "Hilarus", "Celadus" };
_all = names.Select((n, i) => new LeaderEntry("dev" + i, n, ((GladiatorClass)(i % 4)).ToString(), 70 - i * 4, Math.Round(4e9 / Math.Pow(1.9, i)),
Math.Max(0, 6 - i / 2), 7200 + rnd.Next(9000), 7, "")).ToList();
if (game != null) _all.Add(Leaderboard.FromGame(game) with { Id = _me });
_loading = false; _offline = false;
}
public void Update(float dt, Input input, Matrix ui)
{
_t += dt;
_ui.Begin(input, ui);
_fx.Motes(AppSettings.ReduceMotion ? 0 : 40, Camera.W, Camera.H);
_fx.Update(dt);
if (input.Pressed(Keys.Escape)) Done = true;
}
List<LeaderEntry> Ranked() => _all == null ? new() : _tab == Tab.Power
? _all.Where(e => e.Power > 0).OrderByDescending(e => e.Power).ThenBy(e => e.Name).ToList()
: _all.Where(e => e.FastestFreedom > 0).OrderBy(e => e.FastestFreedom).ThenBy(e => e.Name).ToList();
string Value(LeaderEntry e) => _tab == Tab.Power ? NumberFormat.Format(e.Power) : NumberFormat.Duration(e.FastestFreedom);
string ClassName(LeaderEntry e) => Enum.TryParse<GladiatorClass>(e.Class, out var c) ? L.t(ClassDef.Of(c).Key) : e.Class;
// ── Zeichnen ────────────────────────────────────────────────
public void Draw(SpriteBatch sb, float scale, Vector2 offset)
{
D.UiScale = scale;
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
if (_backdrop != null)
{
float k = 1.08f * MathF.Max(Camera.W / _backdrop.Width, Camera.H / _backdrop.Height);
sb.Draw(_backdrop, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.3f, 0.27f, 0.24f), 0,
new Vector2(_backdrop.Width / 2f, _backdrop.Height / 2f), k, SpriteEffects.None, 0);
}
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
_fx.DrawAdd(sb);
D.Glow(sb, new Vector2(Camera.W / 2, 120), new Vector2(1600, 400), D.Gold * 0.1f);
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
D.Text(sb, Assets.Serif, 72, L.t("lb.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 80), D.Gold, Align.Center);
float tw = 360;
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - tw - 10, 140, tw, 56), L.t("lb.tab.power"), selected: _tab == Tab.Power, size: 22)) _tab = Tab.Power;
if (_ui.Button(sb, new RectangleF(Camera.W / 2 + 10, 140, tw, 56), L.t("lb.tab.fastest"), selected: _tab == Tab.Fastest, size: 22)) _tab = Tab.Fastest;
if (_loading) D.Text(sb, Assets.Serif, 30, L.t("lb.loading"), new Vector2(Camera.W / 2, 520), D.Sand, Align.Center);
else if (_offline)
{
D.Text(sb, Assets.Serif, 30, L.t("lb.offline"), new Vector2(Camera.W / 2, 500), D.Red, Align.Center);
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - 160, 560, 320, 56), L.t("lb.retry"), size: 22)) Reload();
}
else
{
var list = Ranked();
if (list.Count == 0) D.Text(sb, Assets.Serif, 28, L.t(_tab == Tab.Power ? "lb.empty" : "lb.empty.fastest"), new Vector2(Camera.W / 2, 520), D.Sand, Align.Center);
else DrawRanking(sb, list);
}
if (_ui.Button(sb, new RectangleF(60, Camera.H - 100, 260, 60), L.t("lb.back"), size: 22)) Done = true;
sb.End();
}
void DrawRanking(SpriteBatch sb, List<LeaderEntry> list)
{
// Siegertreppchen: 2 – 1 – 3
Color[] medal = { D.Gold, new Color(205, 212, 225), new Color(205, 140, 90) };
int[] order = { 1, 0, 2 };
float[] heights = { 175, 215, 150 };
for (int s = 0; s < 3; s++)
{
int i = order[s];
if (i >= list.Count) continue;
var e = list[i];
float w = 360, x = Camera.W / 2 - 1.5f * w - 20 + s * (w + 20), h = heights[s], baseY = 480;
var r = new RectangleF(x, baseY - h, w, h);
D.Rect(sb, r, new Color(30, 22, 15) * 0.92f);
D.Frame(sb, r, e.Id == _me ? D.Purple : medal[i], e.Id == _me ? 4 : 3);
D.Text(sb, Assets.Serif, 44, (i + 1).ToString(NumberFormat.Culture), new Vector2(r.Center.X, r.Y + 30), medal[i], Align.Center);
D.Text(sb, Assets.Serif, 28, e.Name, new Vector2(r.Center.X, r.Y + 72), Color.White, Align.Center);
if (h >= 170) D.Text(sb, Assets.Sans, 17, $"{ClassName(e)} · {string.Format(L.t("ludus.level"), e.Level)}", new Vector2(r.Center.X, r.Y + 104), D.Sand, Align.Center); // i18n-ok
D.Text(sb, Assets.SansBold, 24, Value(e), new Vector2(r.Center.X, r.Bottom - 26), medal[i], Align.Center);
}
// Plätze 4–15
float x0 = Camera.W / 2 - 560, y = 512, rowH = 36, wAll = 1120;
D.Text(sb, Assets.Sans, 15, L.t("lb.col.rank"), new Vector2(x0 + 20, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.name"), new Vector2(x0 + 90, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.class"), new Vector2(x0 + 470, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.freedoms"), new Vector2(x0 + 760, y), D.Dim, Align.Center);
D.Text(sb, Assets.Sans, 15, L.t(_tab == Tab.Power ? "lb.tab.power" : "lb.tab.fastest"), new Vector2(x0 + wAll - 20, y), D.Dim, Align.Right);
y += 26;
for (int i = 3; i < Math.Min(15, list.Count); i++) { Row(sb, list[i], i, x0, y, wAll, rowH); y += rowH; }
int mine = list.FindIndex(e => e.Id == _me);
if (mine >= 15) { y += 10; Row(sb, list[mine], mine, x0, y, wAll, rowH); }
if (mine >= 0)
D.Text(sb, Assets.Sans, 17, string.Format(L.t("lb.yourrank"), mine + 1, list.Count), new Vector2(Camera.W - 60, Camera.H - 70), D.Purple, Align.Right);
}
void Row(SpriteBatch sb, LeaderEntry e, int i, float x0, float y, float w, float h)
{
bool me = e.Id == _me;
var r = new RectangleF(x0, y, w, h - 4);
D.Rect(sb, r, (me ? new Color(60, 40, 80) : new Color(30, 22, 15)) * 0.9f);
if (me) D.Frame(sb, r, D.Purple, 2);
float cy = r.Center.Y;
D.Text(sb, Assets.SansBold, 19, (i + 1).ToString(NumberFormat.Culture), new Vector2(x0 + 20, cy), D.Sand);
D.Text(sb, Assets.SansBold, 19, me ? $"{e.Name} ({L.t("lb.you")})" : e.Name, new Vector2(x0 + 90, cy), me ? D.Purple : Color.White); // i18n-ok
D.Text(sb, Assets.Sans, 17, $"{ClassName(e)} · {string.Format(L.t("ludus.level"), e.Level)}", new Vector2(x0 + 470, cy), D.Sand); // i18n-ok
D.Text(sb, Assets.Sans, 17, e.Freedoms.ToString(NumberFormat.Culture), new Vector2(x0 + 760, cy), D.Sand, Align.Center);
D.Text(sb, Assets.SansBold, 19, Value(e), new Vector2(x0 + w - 20, cy), D.Gold, Align.Right);
}
}
}

View File

@@ -12,7 +12,7 @@ namespace GladiatorIdle.Arena
/// </summary> /// </summary>
internal sealed class MenuScene internal sealed class MenuScene
{ {
public enum Choice { None, Continue, New, Intro, Settings, Quit } public enum Choice { None, Continue, New, Intro, Leaderboard, Settings, Quit }
readonly Ui _ui = new(); readonly Ui _ui = new();
readonly Particles _fx = new(); readonly Particles _fx = new();
@@ -67,24 +67,26 @@ namespace GladiatorIdle.Arena
D.Text(sb, Assets.Serif, 120, L.t("app.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 220), D.Gold * appear, Align.Center, 1.06f - 0.06f * appear); D.Text(sb, Assets.Serif, 120, L.t("app.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 220), D.Gold * appear, Align.Center, 1.06f - 0.06f * appear);
D.Text(sb, Assets.Serif, 32, L.t("start.subtitle"), new Vector2(Camera.W / 2, 320), D.Sand * appear, Align.Center); D.Text(sb, Assets.Serif, 32, L.t("start.subtitle"), new Vector2(Camera.W / 2, 320), D.Sand * appear, Align.Center);
float w = 520, h = 74, x = (Camera.W - w) / 2, y = 430; float w = 520, h = 66, x = (Camera.W - w) / 2, y = 410;
if (_hasSave && _ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.continue"), selected: true, size: 30)) Picked = Choice.Continue; if (_hasSave && _ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.continue"), selected: true, size: 30)) Picked = Choice.Continue;
if (_hasSave) y += h + 18; if (_hasSave) y += h + 14;
string newText = _armNew > 0 ? L.t("menu.new.confirm") : L.t("menu.new"); string newText = _armNew > 0 ? L.t("menu.new.confirm") : L.t("menu.new");
if (_ui.Button(sb, new RectangleF(x, y, w, h), newText, selected: !_hasSave, size: _armNew > 0 ? 18 : 28, accent: _armNew > 0 ? D.Red : null)) if (_ui.Button(sb, new RectangleF(x, y, w, h), newText, selected: !_hasSave, size: _armNew > 0 ? 18 : 28, accent: _armNew > 0 ? D.Red : null))
{ {
if (!_hasSave || _armNew > 0) Picked = Choice.New; if (!_hasSave || _armNew > 0) Picked = Choice.New;
else _armNew = 4; // zweiter Klick innerhalb von 4 s else _armNew = 4; // zweiter Klick innerhalb von 4 s
} }
y += h + 18; y += h + 14;
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.intro"), size: 26)) Picked = Choice.Intro; if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.intro"), size: 26)) Picked = Choice.Intro;
y += h + 18; y += h + 14;
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.leaderboard"), size: 26, accent: D.Gold)) Picked = Choice.Leaderboard;
y += h + 14;
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.settings"), size: 26)) Picked = Choice.Settings; if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.settings"), size: 26)) Picked = Choice.Settings;
y += h + 18; y += h + 14;
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.quit"), size: 26)) Picked = Choice.Quit; if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.quit"), size: 26)) Picked = Choice.Quit;
if (_freedoms > 0) if (_freedoms > 0)
D.Text(sb, Assets.Serif, 22, string.Format(L.t("menu.freedoms"), _freedoms), new Vector2(Camera.W / 2, y + h + 50), D.Gold, Align.Center); D.Text(sb, Assets.Serif, 22, string.Format(L.t("menu.freedoms"), _freedoms), new Vector2(Camera.W / 2, y + h + 36), D.Gold, Align.Center);
D.Text(sb, Assets.Sans, 16, $"{Credits.COPYRIGHT} · {Credits.DISCORD}", new Vector2(Camera.W / 2, Camera.H - 30), D.Dim, Align.Center); // i18n-ok D.Text(sb, Assets.Sans, 16, $"{Credits.COPYRIGHT} · {Credits.DISCORD}", new Vector2(Camera.W / 2, Camera.H - 30), D.Dim, Align.Center); // i18n-ok
sb.End(); sb.End();
} }

View File

@@ -33,8 +33,7 @@ namespace GladiatorIdle.Arena
// --model=<name>: andere Figur ansehen (Standard: hero_murmillo_1) // --model=<name>: andere Figur ansehen (Standard: hero_murmillo_1)
string name = Array.Find(Environment.GetCommandLineArgs(), x => x.StartsWith("--model="))?[8..] ?? "hero_murmillo_1"; string name = Array.Find(Environment.GetCommandLineArgs(), x => x.StartsWith("--model="))?[8..] ?? "hero_murmillo_1";
Model = Model3D.Load(gd, name); Model = Model3D.Load(gd, name);
Model?.AddSword(); Model?.Arm(name);
Model?.AddShield();
_backdrop = Assets.Sprite("arena_colosseum", "jpg"); _backdrop = Assets.Sprite("arena_colosseum", "jpg");
_fx = new BasicEffect(gd) { VertexColorEnabled = true, LightingEnabled = true, PreferPerPixelLighting = true }; _fx = new BasicEffect(gd) { VertexColorEnabled = true, LightingEnabled = true, PreferPerPixelLighting = true };
_fx.AmbientLightColor = new Vector3(0.42f, 0.38f, 0.36f); _fx.AmbientLightColor = new Vector3(0.42f, 0.38f, 0.36f);

View File

@@ -29,10 +29,13 @@ namespace GladiatorIdle
DuelScene? _scene; DuelScene? _scene;
ModelTestScene? _model; // --model3d: 3D-Test ModelTestScene? _model; // --model3d: 3D-Test
FreedomScene? _freedom; // Freiheit: Clip, Bilanz, Götter FreedomScene? _freedom; // Freiheit: Clip, Bilanz, Götter
LeaderboardScene? _board; // Bestenliste (aus dem Menü)
bool _nextLife; // nächste Erstellung behält das Profil (Legenden, Götter) bool _nextLife; // nächste Erstellung behält das Profil (Legenden, Götter)
Legend? _legend; // laufendes Duell gegen eine Legende Legend? _legend; // laufendes Duell gegen eine Legende
static readonly bool DevFreedomRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--freedom") >= 0; static readonly bool DevFreedomRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--freedom") >= 0;
static readonly bool DevChampionRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--champion") >= 0; static readonly bool DevChampionRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--champion") >= 0;
static readonly bool DevAdventureRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--adventure") >= 0;
static readonly bool DevBoardRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--leaderboard") >= 0;
static readonly bool Model3DTest = Array.IndexOf(Environment.GetCommandLineArgs(), "--model3d") >= 0; static readonly bool Model3DTest = Array.IndexOf(Environment.GetCommandLineArgs(), "--model3d") >= 0;
SettingsOverlay _settings = null!; SettingsOverlay _settings = null!;
bool _paused; bool _paused;
@@ -126,13 +129,13 @@ namespace GladiatorIdle
void ToMenu() void ToMenu()
{ {
_hub = null; _scene = null; _creator = null; _intro = null; _freedom = null; _paused = false; _nextLife = false; _hub = null; _scene = null; _creator = null; _intro = null; _freedom = null; _board = null; _paused = false; _nextLife = false;
_menu = new MenuScene(_game != null, _game?.Freedoms ?? 0); _menu = new MenuScene(_game != null, _game?.Freedoms ?? 0);
} }
protected override void OnExiting(object sender, ExitingEventArgs args) protected override void OnExiting(object sender, ExitingEventArgs args)
{ {
if (_game != null && _creator == null) _game.Save(); // Testläufe speichern nie (GameState.Save) if (_game != null && _creator == null) { _game.Save(); Net.Leaderboard.Submit(_game); } // Testläufe speichern und senden nie
base.OnExiting(sender, args); base.OnExiting(sender, args);
} }
@@ -166,6 +169,7 @@ namespace GladiatorIdle
int favor = _game!.TakeFreedom(); int favor = _game!.TakeFreedom();
if (favor <= 0 && _game.Legends.Count == 0) return; if (favor <= 0 && _game.Legends.Count == 0) return;
_game.Save(); _game.Save();
Net.Leaderboard.Submit(_game);
_hub = null; _scene = null; _paused = false; _hub = null; _scene = null; _paused = false;
_freedom = new FreedomScene(_game, _game.Legends[^1], favor); _freedom = new FreedomScene(_game, _game.Legends[^1], favor);
_devTime = 0; _devTime = 0;
@@ -215,6 +219,7 @@ namespace GladiatorIdle
{ {
_game!.ResolveFight(_offer!, won); _game!.ResolveFight(_offer!, won);
_hub!.ShowResult(_hub.ResultLines(_before, won), won ? Gfx.Draw.Gold : Gfx.Draw.Red); _hub!.ShowResult(_hub.ResultLines(_before, won), won ? Gfx.Draw.Gold : Gfx.Draw.Red);
if (won && _offer!.Enemy.IsChampion) Net.Leaderboard.Submit(_game);
} }
SoundManager.StartAmbient("music_ludus"); SoundManager.StartAmbient("music_ludus");
_scene = null; _scene = null;
@@ -253,6 +258,12 @@ namespace GladiatorIdle
if (input.Pressed(Keys.Escape)) Exit(); if (input.Pressed(Keys.Escape)) Exit();
if (DevShot.Active) DevModel(dt); if (DevShot.Active) DevModel(dt);
} }
else if (_board != null)
{
_board.Update(dt, input, ui);
if (DevShot.Active) DevBoard(dt);
if (_board != null && _board.Done) ToMenu();
}
else if (_freedom != null) else if (_freedom != null)
{ {
_freedom.Update(dt, input, ui); _freedom.Update(dt, input, ui);
@@ -284,6 +295,10 @@ namespace GladiatorIdle
case MenuScene.Choice.Continue when _game != null: _menu = null; _hub = new HubScene(_game); break; case MenuScene.Choice.Continue when _game != null: _menu = null; _hub = new HubScene(_game); break;
case MenuScene.Choice.New: _menu = null; _creator = new CreatorScene(DevShot.Active ? DevShot.Name : L.t("gladiator.defaultname")); break; case MenuScene.Choice.New: _menu = null; _creator = new CreatorScene(DevShot.Active ? DevShot.Name : L.t("gladiator.defaultname")); break;
case MenuScene.Choice.Intro: _menu = null; _intro = new IntroScene(); break; case MenuScene.Choice.Intro: _menu = null; _intro = new IntroScene(); break;
case MenuScene.Choice.Leaderboard:
_menu = null; _board = new LeaderboardScene(_game);
if (DevShot.Active) _board.DevSample(_game);
break;
case MenuScene.Choice.Settings: _menu.Picked = MenuScene.Choice.None; _settings.Open = true; break; case MenuScene.Choice.Settings: _menu.Picked = MenuScene.Choice.None; _settings.Open = true; break;
case MenuScene.Choice.Quit: Exit(); break; case MenuScene.Choice.Quit: Exit(); break;
} }
@@ -360,6 +375,7 @@ namespace GladiatorIdle
if (_devTime > 1.9) Shot("c_settings"); if (_devTime > 1.9) Shot("c_settings");
if (_devTime > 2.3 && _capture == null && _settings.Open) _settings.Open = false; if (_devTime > 2.3 && _capture == null && _settings.Open) _settings.Open = false;
if (_devTime > 2.5 && _capture == null && DevShot.Full && !_shots.Contains("i_intro")) { _shots.Add("i_intro"); _menu = null; _intro = new IntroScene(); return; } if (_devTime > 2.5 && _capture == null && DevShot.Full && !_shots.Contains("i_intro")) { _shots.Add("i_intro"); _menu = null; _intro = new IntroScene(); return; }
if (DevBoardRun && _devTime > 1.2 && _capture == null && _menu != null) { _menu.Picked = MenuScene.Choice.Leaderboard; _devTime = 0; return; }
if (_devTime > 2.6 && _capture == null && _menu != null) { _menu.Picked = MenuScene.Choice.New; _devTime = 0; } if (_devTime > 2.6 && _capture == null && _menu != null) { _menu.Picked = MenuScene.Choice.New; _devTime = 0; }
} }
@@ -412,6 +428,21 @@ namespace GladiatorIdle
if (_devTime > 1.8 && _capture == null && _shots.Contains("h_hall")) { _hub!.DevOpen(0); _hub.ChosenLegend = _game.Legends[0]; _devTime = 0; } if (_devTime > 1.8 && _capture == null && _shots.Contains("h_hall")) { _hub!.DevOpen(0); _hub.ChosenLegend = _game.Legends[0]; _devTime = 0; }
return; return;
} }
if (DevAdventureRun)
{
// Expeditionen: Auswahl, unterwegs, Rückkehr-Bericht; dann ein Ereignis mit Entscheidung
if (_devTime > 0.8 && !_shots.Contains("x_open")) { _shots.Add("x_open"); _hub!.DevOpen(6); }
if (_devTime > 1.6) Shot("x_regions");
if (_devTime > 1.9 && !_shots.Contains("x_go")) { _shots.Add("x_go"); _hub!.DevOpen(0); _game!.StartExpedition("gallia", 1); }
if (_devTime > 2.6) Shot("x_away");
if (_devTime > 2.9 && !_shots.Contains("x_back")) { _shots.Add("x_back"); _game!.Tick(Adventures.Durations[1] + 1); }
if (_devTime > 3.6) Shot("x_report");
if (_devTime > 3.9 && !_shots.Contains("x_event")) { _shots.Add("x_event"); _game!.DismissExpeditionResult(); _game.DevEvent("nightduel"); }
if (_devTime > 4.6) Shot("x_eventcard");
if (_devTime > 4.9 && !_shots.Contains("x_choose")) { _shots.Add("x_choose"); _game!.Choose(0); }
if (_devTime > 5.3 && _capture == null && _shots.Contains("x_choose")) { DevShot.Log($"adventure: buffs={_game!.Buffs.Count} gold={_game.Gold:0}"); Exit(); }
return;
}
if (DevChampionRun && !_shots.Contains("m_end")) if (DevChampionRun && !_shots.Contains("m_end"))
{ {
if (_devTime > 0.5 && _capture == null) { _hub!.Chosen = new Offer(_game!.ChampionEnemy, 1, OfferKind.Champion); _devTime = 0; } if (_devTime > 0.5 && _capture == null) { _hub!.Chosen = new Offer(_game!.ChampionEnemy, 1, OfferKind.Champion); _devTime = 0; }
@@ -446,6 +477,18 @@ namespace GladiatorIdle
} }
} }
/// Testlauf --leaderboard: beide Wertungen aufnehmen (Beispieldaten), dann Ende.
void DevBoard(float dt)
{
_devTime += dt;
void Shot(string name) { if (_shots.Add(name)) _capture = name; }
if (_devTime > 1.0) Shot("l_power");
if (_devTime > 1.4 && _capture == null && _shots.Contains("l_power") && !_shots.Contains("l_tab"))
{ _shots.Add("l_tab"); typeof(LeaderboardScene).GetField("_tab", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!.SetValue(_board, 1); }
if (_devTime > 2.0) Shot("l_fastest");
if (_devTime > 2.4 && _capture == null && _shots.Contains("l_fastest")) Exit();
}
/// Testlauf --freedom: Clip, Bilanz und Götter aufnehmen, dann weiter zum nächsten Leben. /// Testlauf --freedom: Clip, Bilanz und Götter aufnehmen, dann weiter zum nächsten Leben.
void DevFreedom(float dt) void DevFreedom(float dt)
{ {
@@ -533,6 +576,7 @@ namespace GladiatorIdle
Gfx.Draw.UiScale = scale; Gfx.Draw.UiScale = scale;
if (_model != null) _model.Draw(gd, _sb, scale, offset); if (_model != null) _model.Draw(gd, _sb, scale, offset);
else if (_freedom != null) _freedom.Draw(gd, _sb, _fx, scale, offset); else if (_freedom != null) _freedom.Draw(gd, _sb, _fx, scale, offset);
else if (_board != null) _board.Draw(_sb, scale, offset);
else if (_intro != null) _intro.Draw(_sb, scale, offset); else if (_intro != null) _intro.Draw(_sb, scale, offset);
else if (_menu != null) _menu.Draw(_sb, scale, offset); else if (_menu != null) _menu.Draw(_sb, scale, offset);
else if (_creator != null) _creator.Draw(gd, _sb, _fx, scale, offset); else if (_creator != null) _creator.Draw(gd, _sb, _fx, scale, offset);

View File

@@ -54,7 +54,7 @@ namespace GladiatorIdle.Gfx
public readonly List<Clip> Clips = new(); public readonly List<Clip> Clips = new();
public readonly VertexPNCT[] Vertices; public readonly VertexPNCT[] Vertices;
public BoundingBox Bounds { get; } public BoundingBox Bounds { get; }
readonly Texture2D? _texture; Texture2D? _texture;
Texture2D? _painted; Texture2D? _painted;
/// Maßstab: Modell-Einheiten je Zentimeter (Mixamo-Figuren gibt es in cm und in m). /// Maßstab: Modell-Einheiten je Zentimeter (Mixamo-Figuren gibt es in cm und in m).
public readonly float Unit; public readonly float Unit;
@@ -127,6 +127,44 @@ namespace GladiatorIdle.Gfx
public Clip? Find(string name) => Clips.Find(c => c.Name == name); public Clip? Find(string name) => Clips.Find(c => c.Name == name);
/// Teamfarbe (Index in Appearance.Colors), -1 = Originalfarben. /// Teamfarbe (Index in Appearance.Colors), -1 = Originalfarben.
/// Hautton dunkler (0 = unverändert, 1 = dunkle Haut): für Aussehen-Vorlagen mit dunkler Haut, solange
/// sie das Modell einer anderen Vorlage nutzen. Haut erkannt an Farbton (Orange/Rosa), mittlerer
/// Sättigung und Helligkeit — Leder ist dunkler, Metall ungesättigt, Teamfarbe magenta.
public void SetSkin(float dark)
{
if (_texture == null || dark <= 0) return;
var data = new Color[_texture.Width * _texture.Height];
_texture.GetData(data);
for (int i = 0; i < data.Length; i++)
{
var c = data[i];
float r = c.R / 255f, g = c.G / 255f, b = c.B / 255f;
float max = MathF.Max(r, MathF.Max(g, b)), min = MathF.Min(r, MathF.Min(g, b)), d = max - min;
if (max < 0.38f || d < 0.04f) continue;
float sat = d / max;
float h = max == r ? 60 * (((g - b) / d) % 6) : max == g ? 60 * ((b - r) / d + 2) : 60 * ((r - g) / d + 4);
if (h < 0) h += 360;
float wh = Band(h, 2, 10, 34, 46), ws = Band(sat, 0.12f, 0.2f, 0.62f, 0.75f), wv = Band(max, 0.38f, 0.48f, 1.1f, 1.2f);
float w = wh * ws * wv * dark;
if (w <= 0) continue;
// dunkle, warme Haut: Helligkeit stark senken, Sättigung leicht anheben
float nv = max * (1 - 0.58f * w), ns = MathF.Min(1, sat * (1 + 0.25f * w));
float k = nv / max;
float nr = r * k, ng = g * k, nb = b * k;
float gray = (nr + ng + nb) / 3, boost = ns / MathF.Max(sat, 1e-3f);
nr = gray + (nr - gray) * boost; ng = gray + (ng - gray) * boost; nb = gray + (nb - gray) * boost;
data[i] = new Color(Math.Clamp(nr, 0, 1), Math.Clamp(ng, 0, 1), Math.Clamp(nb, 0, 1), c.A / 255f);
}
var t = new Texture2D(_texture.GraphicsDevice, _texture.Width, _texture.Height);
t.SetData(data);
_texture = t;
_color = -2; // Teamfarbe neu auf die geänderte Textur
}
/// 0 unterhalb a, 1 zwischen b und c, 0 oberhalb d, linear dazwischen.
static float Band(float x, float a, float b, float c, float d) =>
x <= a || x >= d ? 0 : x < b ? (x - a) / (b - a) : x > c ? (d - x) / (d - c) : 1;
public void SetColor(int index) public void SetColor(int index)
{ {
if (index == _color) return; if (index == _color) return;
@@ -279,7 +317,7 @@ namespace GladiatorIdle.Gfx
var world = fx.World; var world = fx.World;
foreach (var p in Props) foreach (var p in Props)
{ {
fx.World = p.Local * _global[p.Bone] * p.Correction * world; fx.World = p.World * p.Correction * world;
foreach (var pass in fx.CurrentTechnique.Passes) foreach (var pass in fx.CurrentTechnique.Passes)
{ {
pass.Apply(); pass.Apply();
@@ -297,6 +335,9 @@ namespace GladiatorIdle.Gfx
public bool Shield; public float Height, Width, Bend, Length; // Maße in cm (Schild: Höhe x, Breite y; Klinge: Länge entlang x) public bool Shield; public float Height, Width, Bend, Length; // Maße in cm (Schild: Höhe x, Breite y; Klinge: Länge entlang x)
public Matrix Correction = Matrix.Identity; // Ausweichen vor dem eigenen Körper (Modell-Raum) public Matrix Correction = Matrix.Identity; // Ausweichen vor dem eigenen Körper (Modell-Raum)
public float Push, Angle; public Vector3 Axis = Vector3.Up; public float Push, Angle; public Vector3 Axis = Vector3.Up;
public bool NoAvoid; // weicht nicht aus (Netz)
public bool Upright; // Schild aufrecht vor der Hand statt an der Handdrehung
public Matrix World = Matrix.Identity; // Lage im Modell-Raum (vor dem Ausweichen)
public VertexPNC[] V = Array.Empty<VertexPNC>(); public int[] I = Array.Empty<int>(); public Color[] Base = Array.Empty<Color>(); public VertexPNC[] V = Array.Empty<VertexPNC>(); public int[] I = Array.Empty<int>(); public Color[] Base = Array.Empty<Color>();
} }
public readonly List<Prop> Props = new(); public readonly List<Prop> Props = new();
@@ -344,8 +385,15 @@ namespace GladiatorIdle.Gfx
return frame * _offset[bone]; // Rahmen · (Knochen in Ruhe)⁻¹ return frame * _offset[bone]; // Rahmen · (Knochen in Ruhe)⁻¹
} }
/// Gladius in der Faust (Knochen-Präfix "Right"/"Left"). Klinge zeigt vom kleinen Finger zum Zeigefinger. /// Ausrüstung nach Figur: Retiarius Dreizack und Netz, sonst Gladius und Scutum.
public void AddSword(string side = "Right") public void Arm(string art)
{
if (art.Contains("retiarius")) { AddTrident(); AddNet(); }
else { AddSword(); AddShield(); }
}
/// Griff in der Faust: x vom kleinen Finger zum Zeigefinger (Waffe), y zur Handfläche, Ursprung im Griff.
Matrix Grip(string side)
{ {
var h = BindPos(side + "Hand"); var m = BindPos(side + "HandMiddle1"); var h = BindPos(side + "Hand"); var m = BindPos(side + "HandMiddle1");
var ix = BindPos(side + "HandIndex1"); var pk = BindPos(side + "HandPinky1"); var th = BindPos(side + "HandThumb1"); var ix = BindPos(side + "HandIndex1"); var pk = BindPos(side + "HandPinky1"); var th = BindPos(side + "HandThumb1");
@@ -354,6 +402,64 @@ namespace GladiatorIdle.Gfx
var palm = Vector3.Normalize(Vector3.Cross(finger, blade)); var palm = Vector3.Normalize(Vector3.Cross(finger, blade));
if (Vector3.Dot(palm, th - h) < 0) palm = -palm; if (Vector3.Dot(palm, th - h) < 0) palm = -palm;
var grip = h + (m - h) * 0.75f + palm * 2.5f * Unit; var grip = h + (m - h) * 0.75f + palm * 2.5f * Unit;
return Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), blade, palm, grip);
}
/// Dreizack des Retiarius, in der Mitte gefasst: Schaft nach hinten, drei Zinken nach vorn.
public void AddTrident(string side = "Right")
{
var b = new MeshBuilder();
var wood = new Color(110, 74, 42); var bronze = new Color(184, 140, 70); var steel = new Color(200, 204, 210);
b.Box(new Vector3(15, 0, 0), new Vector3(150, 2.6f, 2.6f), wood); // Schaft (-60 … +90)
b.Box(new Vector3(-61, 0, 0), new Vector3(3, 3.6f, 3.6f), bronze); // Endkappe
b.Box(new Vector3(91, 0, 0), new Vector3(4, 4, 4), bronze); // Tülle
b.Box(new Vector3(95, 0, 0), new Vector3(3, 2, 22), bronze); // Querstück
foreach (float z in new[] { -10f, 0f, 10f })
{
float len = z == 0 ? 32 : 26;
b.Box(new Vector3(96 + len / 2, 0, z), new Vector3(len, 1.4f, 1.6f), steel); // Zinke
b.Box(new Vector3(96 + len - 2, 0, z + (z >= 0 ? 1.4f : -1.4f)), new Vector3(4, 1.2f, 1.6f), steel); // Widerhaken
}
var p = b.Build(Bone(side + "Hand"), Grip(side));
p.Length = 128;
Props.Add(p);
}
/// Wurfnetz des Retiarius: gerafft in der Faust, hängt als Maschenwerk mit Bleigewichten herab.
public void AddNet(string side = "Left")
{
var b = new MeshBuilder();
var rope = new Color(176, 152, 104); var lead = new Color(90, 92, 98);
const int COLS = 6, ROWS = 8;
const float W = 36, H = 58, CORD = 0.9f;
Vector3 P(float u, float v)
{
// vom Griff nach unten (Richtung kleiner Finger = -x), unten breiter, leicht gewellt
float spread = 0.35f + 0.65f * v;
return new Vector3(-4 - v * H, MathF.Sin(u * 9 + v * 5) * 2.5f * v, (u - 0.5f) * W * spread);
}
for (int c = 0; c <= COLS; c++) // senkrechte Schnüre
for (int r = 0; r < ROWS; r++)
{
var a = P(c / (float)COLS, r / (float)ROWS); var e = P(c / (float)COLS, (r + 1) / (float)ROWS);
b.Box((a + e) / 2, new Vector3(MathF.Abs(e.X - a.X) + CORD, CORD, CORD + MathF.Abs(e.Z - a.Z)), rope);
}
for (int r = 1; r <= ROWS; r++) // waagerechte Schnüre
for (int c = 0; c < COLS; c++)
{
var a = P(c / (float)COLS, r / (float)ROWS); var e = P((c + 1) / (float)COLS, r / (float)ROWS);
b.Box((a + e) / 2, new Vector3(CORD, CORD, MathF.Abs(e.Z - a.Z) + CORD), rope);
}
for (int c = 0; c <= COLS; c++) b.Box(P(c / (float)COLS, 1) + new Vector3(-1.5f, 0, 0), new Vector3(3, 2.2f, 2.2f), lead); // Bleigewichte
b.Box(new Vector3(-2, 0, 0), new Vector3(6, 5, 9), rope); // geraffter Teil in der Faust
var p = b.Build(Bone(side + "Hand"), Grip(side));
p.NoAvoid = true;
Props.Add(p);
}
/// Gladius in der Faust (Knochen-Präfix "Right"/"Left"). Klinge zeigt vom kleinen Finger zum Zeigefinger.
public void AddSword(string side = "Right")
{
var b = new MeshBuilder(); var b = new MeshBuilder();
var steel = new Color(196, 200, 206); var brass = new Color(176, 136, 62); var wood = new Color(92, 58, 34); var steel = new Color(196, 200, 206); var brass = new Color(176, 136, 62); var wood = new Color(92, 58, 34);
b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass); // Knauf b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass); // Knauf
@@ -361,7 +467,7 @@ namespace GladiatorIdle.Gfx
b.Box(new Vector3(2.2f, 0, 0), new Vector3(1.6f, 4, 11), brass); // Parierstange b.Box(new Vector3(2.2f, 0, 0), new Vector3(1.6f, 4, 11), brass); // Parierstange
b.Box(new Vector3(30, 0, 0), new Vector3(54, 0.8f, 5.2f), steel); // Klinge b.Box(new Vector3(30, 0, 0), new Vector3(54, 0.8f, 5.2f), steel); // Klinge
b.Box(new Vector3(60, 0, 0), new Vector3(6, 0.7f, 2.6f), steel); // Spitze b.Box(new Vector3(60, 0, 0), new Vector3(6, 0.7f, 2.6f), steel); // Spitze
var sword = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), blade, palm, grip)); var sword = b.Build(Bone(side + "Hand"), Grip(side));
sword.Length = 63; sword.Length = 63;
Props.Add(sword); Props.Add(sword);
} }
@@ -390,6 +496,8 @@ namespace GladiatorIdle.Gfx
// y (Breite) = Knöchel × Griff, z (außen) = x × y = Knöchelrichtung // y (Breite) = Knöchel × Griff, z (außen) = x × y = Knöchelrichtung
var shield = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), across, Vector3.Cross(knuckles, across), centre)); var shield = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), across, Vector3.Cross(knuckles, across), centre));
shield.Shield = true; shield.Height = H; shield.Width = W; shield.Bend = BEND; shield.Shield = true; shield.Height = H; shield.Width = W; shield.Bend = BEND;
// Skelett ohne Finger: die Handdrehung passt nach der Übertragung der Bewegungen nicht zuverlässig
shield.Upright = Bone(side + "HandMiddle1") < 0;
Props.Add(shield); Props.Add(shield);
} }
@@ -429,11 +537,12 @@ namespace GladiatorIdle.Gfx
{ {
if (Props.Count == 0) return; if (Props.Count == 0) return;
BuildBody(out float cm); BuildBody(out float cm);
foreach (var p in Props) p.World = p.Upright ? UprightShield(p, cm) : p.Local * _global[p.Bone];
if (_body.Count == 0) return; if (_body.Count == 0) return;
Prop? shield = null; Prop? shield = null;
foreach (var p in Props) if (p.Shield) shield = p; foreach (var p in Props) if (p.Shield) shield = p;
if (shield != null) AvoidShield(shield, cm); if (shield != null) AvoidShield(shield, cm);
foreach (var p in Props) if (!p.Shield) AvoidBlade(p, shield, cm); foreach (var p in Props) if (!p.Shield && !p.NoAvoid) AvoidBlade(p, shield, cm);
} }
static Vector3 Axis(Matrix m, int row) => row switch static Vector3 Axis(Matrix m, int row) => row switch
@@ -441,10 +550,28 @@ namespace GladiatorIdle.Gfx
0 => new Vector3(m.M11, m.M12, m.M13), 1 => new Vector3(m.M21, m.M22, m.M23), _ => new Vector3(m.M31, m.M32, m.M33) 0 => new Vector3(m.M11, m.M12, m.M13), 1 => new Vector3(m.M21, m.M22, m.M23), _ => new Vector3(m.M31, m.M32, m.M33)
}; };
/// Schild aufrecht vor der Hand: Hochachse entlang des Oberkörpers, Vorderseite vom Körper zur Hand hin.
Matrix UprightShield(Prop s, float cm)
{
int hand = s.Bone, hips = Bone("Hips"), neck = Bone("Neck"), head = Bone("Head");
if (hips < 0 || neck < 0) return s.Local * _global[s.Bone];
var h = _global[hand].Translation;
var a = _global[hips].Translation; var n = _global[neck].Translation;
var up = Vector3.Normalize((head >= 0 ? _global[head].Translation : n) - a);
var outV = h - Closest(a, n, h);
outV -= up * Vector3.Dot(outV, up);
if (outV.LengthSquared() < 1e-6f) outV = Vector3.Cross(up, Vector3.UnitX);
outV.Normalize();
var y = Vector3.Cross(outV, up); // x (Höhe) = up, z (außen) = outV, z = x × y
var c = h + outV * 6 * cm;
var frame = new Matrix(up.X, up.Y, up.Z, 0, y.X, y.Y, y.Z, 0, outV.X, outV.Y, outV.Z, 0, c.X, c.Y, c.Z, 1);
return Matrix.CreateScale(cm) * frame;
}
/// Schild entlang seiner Außenseite verschieben, bis kein Körperteil von innen hineinragt. /// Schild entlang seiner Außenseite verschieben, bis kein Körperteil von innen hineinragt.
void AvoidShield(Prop s, float cm) void AvoidShield(Prop s, float cm)
{ {
var m = s.Local * _global[s.Bone]; var m = s.World;
var c = m.Translation; var c = m.Translation;
float sc = Axis(m, 0).Length(); // Modell-Einheiten je Schild-cm float sc = Axis(m, 0).Length(); // Modell-Einheiten je Schild-cm
var ax = Vector3.Normalize(Axis(m, 0)); var ay = Vector3.Normalize(Axis(m, 1)); var az = Vector3.Normalize(Axis(m, 2)); var ax = Vector3.Normalize(Axis(m, 0)); var ay = Vector3.Normalize(Axis(m, 1)); var az = Vector3.Normalize(Axis(m, 2));
@@ -469,12 +596,12 @@ namespace GladiatorIdle.Gfx
/// Klinge um den Griff wegdrehen, wenn sie Körper oder eigenen Schild schneidet. /// Klinge um den Griff wegdrehen, wenn sie Körper oder eigenen Schild schneidet.
void AvoidBlade(Prop p, Prop? shield, float cm) void AvoidBlade(Prop p, Prop? shield, float cm)
{ {
var m = p.Local * _global[p.Bone]; var m = p.World;
var grip = m.Translation; var grip = m.Translation;
float sc = Axis(m, 0).Length(); float sc = Axis(m, 0).Length();
var dir = Vector3.Normalize(Axis(m, 0)); var dir = Vector3.Normalize(Axis(m, 0));
float len = p.Length * sc, half = 2.5f * cm; float len = p.Length * sc, half = 2.5f * cm;
var sm = shield != null ? shield.Local * _global[shield.Bone] * shield.Correction : Matrix.Identity; var sm = shield != null ? shield.World * shield.Correction : Matrix.Identity;
float ss = Axis(sm, 0).Length(); float ss = Axis(sm, 0).Length();
var sx = Vector3.Normalize(Axis(sm, 0)); var sy = Vector3.Normalize(Axis(sm, 1)); var sz = Vector3.Normalize(Axis(sm, 2)); var sx = Vector3.Normalize(Axis(sm, 0)); var sy = Vector3.Normalize(Axis(sm, 1)); var sz = Vector3.Normalize(Axis(sm, 2));

106
Mono/Net/Leaderboard.cs Normal file
View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace GladiatorIdle.Net
{
/// Ein Spieler in der Bestenliste: die besten Werte aus allen seinen Leben.
internal sealed record LeaderEntry(string Id, string Name, string Class, int Level, double Power, int Freedoms,
double FastestFreedom, int Arena, string Date);
/// <summary>
/// Online-Bestenliste über die Firebase-Datenbank (wie bei Your Life is Game), Bereich
/// <c>gladiatoridle/players</c>: ein Eintrag je Spielprofil (zufällige ID in
/// %AppData%\GladiatorIdle\player.txt), der bei Fortschritt überschrieben wird. Ohne Netz oder ohne
/// Freigabe in den Datenbank-Regeln bleibt die Liste leer ("offline"). Testläufe senden nie.
/// </summary>
internal static class Leaderboard
{
const string BASE = "https://your-life-is-game-ae407-default-rtdb.europe-west1.firebasedatabase.app/gladiatoridle/players";
static readonly HttpClient Http = new() { Timeout = TimeSpan.FromSeconds(12) };
static string? _lastSent;
public static string PlayerId
{
get
{
if (DevShot.Active || DevShot.Playtest) return "dev"; // Testläufe legen nichts an
string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GladiatorIdle");
string file = Path.Combine(dir, "player.txt");
try
{
if (File.Exists(file) && File.ReadAllText(file).Trim() is { Length: >= 8 } id) return id;
Directory.CreateDirectory(dir);
string fresh = Guid.NewGuid().ToString("N");
File.WriteAllText(file, fresh);
return fresh;
}
catch { return "local"; }
}
}
/// Eintrag aus dem Spielstand: bestes aus laufendem Leben und allen Legenden.
public static LeaderEntry FromGame(GameState g)
{
double power = g.Legends.Select(l => l.Power).Append(g.Power()).Max();
int level = g.Legends.Select(l => l.Level).Append(g.CharLevel).Max();
double fastest = g.Legends.Count > 0 ? g.Legends.Min(l => l.RunSeconds) : 0;
int arena = g.Legends.Count > 0 ? ArenaDef.All.Length : g.Arena + 1;
string name = (g.Name ?? "").Trim();
if (name.Length > 24) name = name[..24];
return new LeaderEntry(PlayerId, name, g.Class.ToString(), level, Math.Round(power), g.Freedoms, Math.Round(fastest), arena,
DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"));
}
/// Eigenen Eintrag hochladen (im Hintergrund, Fehler still). Nichts bei Testläufen oder ohne Änderung.
public static void Submit(GameState g)
{
if (DevShot.Active || DevShot.Playtest || string.IsNullOrWhiteSpace(g.Name)) return;
var e = FromGame(g);
string json = JsonSerializer.Serialize(new
{
name = e.Name, @class = e.Class, level = e.Level, power = e.Power, freedoms = e.Freedoms,
fastest = e.FastestFreedom, arena = e.Arena, date = e.Date
});
string key = json[..json.LastIndexOf("\"date\"", StringComparison.Ordinal)];
if (key == _lastSent) return;
_lastSent = key;
_ = Task.Run(async () =>
{
try { await Http.PutAsync($"{BASE}/{e.Id}.json", new StringContent(json, Encoding.UTF8, "application/json")); }
catch { /* offline */ }
});
}
/// Alle Einträge laden; null bei Fehler (offline oder keine Freigabe).
public static async Task<List<LeaderEntry>?> FetchAsync()
{
try
{
using var resp = await Http.GetAsync(BASE + ".json");
if (!resp.IsSuccessStatusCode) return null;
using var doc = JsonDocument.Parse(await resp.Content.ReadAsStringAsync());
var list = new List<LeaderEntry>();
if (doc.RootElement.ValueKind != JsonValueKind.Object) return list;
foreach (var p in doc.RootElement.EnumerateObject())
{
var v = p.Value;
if (v.ValueKind != JsonValueKind.Object) continue;
string S(string k) => v.TryGetProperty(k, out var x) && x.ValueKind == JsonValueKind.String ? x.GetString() ?? "" : "";
double N(string k) => v.TryGetProperty(k, out var x) && x.ValueKind == JsonValueKind.Number ? x.GetDouble() : 0;
string name = S("name");
if (name.Length == 0) continue;
list.Add(new LeaderEntry(p.Name, name.Length > 24 ? name[..24] : name, S("class"), (int)N("level"), N("power"),
(int)N("freedoms"), N("fastest"), (int)N("arena"), S("date")));
}
return list;
}
catch { return null; }
}
}
}