Files
GladiatorIdle/Game/Adventures.cs
Michi a7134b2753 Gladiator Idle (MonoGame) – Spiel mit 3D-Gladiatoren
Nur was zum Bauen und Starten nötig ist: Mono/ (Spiel), Game/, Core/,
Languages/, Assets/ (Bilder, Clips, 3D-Figuren, Ton), build-release.bat.
Bauen: build-release.bat → Spiel\GladiatorIdle.exe

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:57:20 +01:00

156 lines
7.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
namespace GladiatorIdle
{
public enum BuffKind { Damage, Health, Gold, Xp }
/// Zeitweiser Segen (aus Ereignissen): Faktor auf einen Wert für eine Zeit.
internal sealed class ActiveBuff
{
public BuffKind Kind { get; set; }
public double Mult { get; set; }
public double Left { get; set; }
}
// ── Expeditionen ─────────────────────────────────────────────────
/// Region für Expeditionen: frei ab Arena <see cref="Unlock"/>, Gegnerstärke wie <see cref="Tier"/>.
internal sealed record RegionDef(string Id, int Unlock, int Tier)
{
public string Key => "region." + Id;
public string Art => "region_" + Id;
public static readonly RegionDef[] All =
{
new("gallia", 0, 6), new("germania", 1, 16), new("britannia", 2, 26),
new("hispania", 3, 36), new("dacia", 4, 46), new("aegyptus", 5, 56),
};
public static RegionDef Get(string id) => All.First(r => r.Id == id);
}
/// Eine laufende Expedition.
internal sealed class Expedition
{
public string Region { get; set; } = "gallia";
public int Duration { get; set; } // Index in Adventures.Durations
public double Left { get; set; }
public double Chance { get; set; } // Erfolgschance beim Aufbruch
}
/// Ergebnis bei der Rückkehr (wird angezeigt, bis der Spieler es bestätigt).
internal sealed class ExpeditionReport
{
public string Region { get; set; } = "";
public bool Success { get; set; }
public double Gold { get; set; }
public double Fame { get; set; }
public double Xp { get; set; }
public List<Item> Loot { get; set; } = new();
public List<int> Log { get; set; } = new(); // Nummern der Reise-Ereignisse (expedition.log.N)
}
// ── Ereignisse ───────────────────────────────────────────────────
public enum EffectKind { Gold, Fame, Crowd, Xp, Item, Buff, Recovery }
/// Folge einer Entscheidung. Gold/Ruhm/XP in "Siegen" der aktuellen Gegnerstufe (wächst mit).
internal sealed record EventEffect(EffectKind Kind, double Amount, BuffKind Buff = BuffKind.Damage, double Seconds = 0,
Rarity Rarity = Rarity.Rare, ItemSlot? Slot = null);
/// Wahlmöglichkeit: Kosten (in Siegen Gold), Chance auf Erfolg, Folgen bei Erfolg/Misserfolg.
internal sealed record EventChoice(string Id, double Cost, double Chance, EventEffect[] Ok, EventEffect[]? Fail = null);
internal sealed record EventDef(string Id, EventChoice[] Choices)
{
public string Art => "event_" + Id;
public string Title => $"event.{Id}.title";
public string Text => $"event.{Id}.text";
public string ChoiceKey(EventChoice c) => $"event.{Id}.{c.Id}";
public string OutcomeKey(EventChoice c, bool ok) => $"event.{Id}.{c.Id}.{(ok ? "ok" : "fail")}";
}
internal static class Adventures
{
public static readonly double[] Durations = { 300, 1800, 7200 };
public const int LOG_LINES = 12; // expedition.log.1 … 12
public const double EVENT_MIN = 480, EVENT_MAX = 840; // 8–14 min aktive Spielzeit
static EventEffect Gold(double w) => new(EffectKind.Gold, w);
static EventEffect Fame(double w) => new(EffectKind.Fame, w);
static EventEffect Crowd(double v) => new(EffectKind.Crowd, v);
static EventEffect Xp(double w) => new(EffectKind.Xp, w);
static EventEffect Loot(Rarity r, ItemSlot? s = null) => new(EffectKind.Item, 1, Rarity: r, Slot: s);
static EventEffect Bless(BuffKind k, double mult, double seconds) => new(EffectKind.Buff, mult, k, seconds);
static EventEffect Rest(double seconds) => new(EffectKind.Recovery, seconds);
public static readonly EventDef[] Events =
{
new("bribe", new[]
{
new EventChoice("accept", 0, 1, new[] { Gold(15), Crowd(-30), Fame(-3) }),
new EventChoice("refuse", 0, 1, new[] { Crowd(20) }),
new EventChoice("report", 0, 1, new[] { Fame(6), Bless(BuffKind.Gold, 1.2, 600) }),
}),
new("nightduel", new[]
{
new EventChoice("fight", 0, 0.6, new[] { Loot(Rarity.Rare), Crowd(15) }, new[] { Rest(60), Crowd(-10) }),
new EventChoice("ignore", 0, 1, new[] { Xp(2) }),
}),
new("extratraining", new[]
{
new EventChoice("pay", 8, 1, new[] { Bless(BuffKind.Xp, 1.5, 600) }),
new EventChoice("decline", 0, 1, Array.Empty<EventEffect>()),
}),
new("sickfriend", new[]
{
new EventChoice("help", 3, 1, new[] { Fame(2), Bless(BuffKind.Health, 1.15, 900) }),
new EventChoice("ignore", 0, 1, new[] { Crowd(-5) }),
}),
new("feast", new[]
{
new EventChoice("go", 0, 1, new[] { Fame(5), Crowd(10), Rest(30) }),
new EventChoice("decline", 0, 1, new[] { Xp(5) }),
}),
new("mysteryweapon", new[]
{
new EventChoice("buy", 20, 1, new[] { Loot(Rarity.Epic, ItemSlot.Weapon) }),
new EventChoice("haggle", 10, 0.5, new[] { Loot(Rarity.Epic, ItemSlot.Weapon) }, new[] { Gold(10) }),
new EventChoice("leave", 0, 1, Array.Empty<EventEffect>()),
}),
new("escape", new[]
{
new EventChoice("join", 0, 0.4, new[] { Gold(25) }, new[] { Rest(120), Crowd(-40) }),
new EventChoice("betray", 0, 1, new[] { Fame(8), Gold(5), Crowd(-10) }),
new EventChoice("silent", 0, 1, Array.Empty<EventEffect>()),
}),
new("mars", new[]
{
new EventChoice("offer", 5, 1, new[] { Bless(BuffKind.Damage, 1.25, 900) }),
new EventChoice("decline", 0, 1, Array.Empty<EventEffect>()),
}),
new("showtime", new[]
{
new EventChoice("perform", 0, 1, new[] { Crowd(100), Fame(3) }),
new EventChoice("refuse", 0, 1, new[] { Crowd(-20), Xp(3) }),
}),
new("gamble", new[]
{
new EventChoice("play", 0, 0.5, new[] { Gold(10) }, new[] { Gold(-10) }),
new EventChoice("decline", 0, 1, Array.Empty<EventEffect>()),
}),
};
public static EventDef GetEvent(string id) => Events.First(e => e.Id == id);
/// Stärke einer Region zum Vergleich mit der Kampfkraft (wie ein Gegner ihrer Stufe, ein paar Mal).
public static double RegionPower(RegionDef r) => 2.5 * Math.Sqrt(Balance.EnemyHp(r.Tier) * Balance.EnemyDamage(r.Tier));
/// Erfolgschance aus Kampfkraft im Verhältnis zur Region (gleich stark = 50 %, doppelt = 95 %).
public static double Chance(double power, RegionDef r) =>
Math.Clamp(0.5 + 0.65 * Math.Log2(power / RegionPower(r)), 0.05, 0.95);
}
}