Files
GladiatorIdle/Game/Defs.cs

167 lines
8.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
namespace GladiatorIdle
{
public enum Stat { Strength, Endurance, Agility, Showmanship }
public enum GladiatorClass { Murmillo, Retiarius, Thraex, Secutor }
public enum God { Mars, Fortuna, Minerva, Apollo, Bacchus, Jupiter }
/// Spezialschlag je Klasse.
public enum Special { ShieldBash, Net, Sica, Endure }
/// <summary>Gladiatorenklasse: Startwerte, Wachstum je Wert, Spezialschlag.</summary>
internal sealed record ClassDef(GladiatorClass Id, int[] StartLevels, double[] XpMult, double CritBonus, Special Special)
{
public string Key => "class." + Id.ToString().ToLowerInvariant();
public static readonly ClassDef[] All =
{
// Str End Agi Show Str End Agi Show
new(GladiatorClass.Murmillo, new[] { 3, 3, 1, 1 }, new[] { 1.25, 1.25, 0.80, 1.00 }, 0.00, Special.ShieldBash),
new(GladiatorClass.Retiarius, new[] { 1, 1, 4, 2 }, new[] { 0.85, 0.90, 1.40, 1.15 }, 0.03, Special.Net),
new(GladiatorClass.Thraex, new[] { 3, 1, 3, 1 }, new[] { 1.15, 0.85, 1.20, 1.00 }, 0.10, Special.Sica),
new(GladiatorClass.Secutor, new[] { 2, 4, 1, 1 }, new[] { 1.10, 1.40, 0.80, 1.00 }, 0.00, Special.Endure),
};
public static ClassDef Of(GladiatorClass c) => All[(int)c];
}
public enum UpgradeKind { Trainer, Building }
/// <summary>
/// Kaufbare Stufen (Forum): Ausbilder je Wert, Ausrüstung, Ludus-Gebäude.
/// Kosten = BaseCost × Growth^Stufe.
/// </summary>
internal sealed record UpgradeDef(string Id, UpgradeKind Kind, double BaseCost, double Growth, Stat? Stat = null)
{
public string Key => "upgrade." + Id;
public double Cost(int level) => BaseCost * Math.Pow(Growth, level);
public static readonly UpgradeDef[] All =
{
new("trainer.strength", UpgradeKind.Trainer, 15, 1.42, GladiatorIdle.Stat.Strength),
new("trainer.endurance", UpgradeKind.Trainer, 15, 1.42, GladiatorIdle.Stat.Endurance),
new("trainer.agility", UpgradeKind.Trainer, 15, 1.42, GladiatorIdle.Stat.Agility),
new("trainer.showmanship", UpgradeKind.Trainer, 25, 1.45, GladiatorIdle.Stat.Showmanship),
new("building.baths", UpgradeKind.Building, 60, 1.90), // schnellere Erholung
new("building.kitchen", UpgradeKind.Building, 80, 1.70), // mehr XP
new("building.medicus", UpgradeKind.Building, 100, 1.75), // mehr Leben
};
static readonly Dictionary<string, UpgradeDef> _byId = All.ToDictionary(u => u.Id);
public static UpgradeDef Get(string id) => _byId[id];
public static UpgradeDef TrainerFor(Stat s) => All.First(u => u.Kind == UpgradeKind.Trainer && u.Stat == s);
}
/// <summary>Götter (Prestige): Stufe kostet Stufe+1 Gunst der Götter.</summary>
internal static class Gods
{
public static string Key(God g) => "god." + g.ToString().ToLowerInvariant();
public static int Cost(int level) => level + 1;
public static double DamageMult(int mars) => 1 + 0.10 * mars;
public static double GoldMult(int fortuna) => 1 + 0.15 * fortuna;
public static double CritBonus(int fortuna) => 0.01 * fortuna;
public static double XpMult(int minerva) => 1 + 0.15 * minerva;
public static double HpMult(int apollo) => 1 + 0.08 * apollo;
public static double RecoveryMult(int apollo) => Math.Pow(0.92, apollo);
public static double CrowdGainMult(int bacchus) => 1 + 0.15 * bacchus;
public static double CrowdDecayMult(int bacchus) => Math.Pow(0.92, bacchus);
public static double OfflineHours(int jupiter) => Balance.OFFLINE_HOURS + jupiter;
public static double AllMult(int jupiter) => 1 + 0.05 * jupiter;
}
/// <summary>Arena: Name-Key, Champion-Key, Gegnertypen (Namen der normalen Gegner).</summary>
internal sealed record ArenaDef(int Index, string Id, string Champion, string[] Foes)
{
public string Key => "arena." + Id;
public string ChampionKey => "champion." + Champion;
public static readonly ArenaDef[] All =
{
new(0, "ludus", "doctore", new[] { "recruit", "slave", "brawler" }),
new(1, "province", "veteran", new[] { "brawler", "hoplomachus", "provocator" }),
new(2, "capua", "rival", new[] { "hoplomachus", "dimachaerus", "provocator" }),
new(3, "pompeii", "beastmaster", new[] { "dimachaerus", "essedarius", "laquearius" }),
new(4, "circus", "romechampion", new[] { "essedarius", "eques", "sagittarius" }),
new(5, "colosseum", "flamma", new[] { "eques", "sagittarius", "crupellarius" }),
new(6, "emperor", "imperial", new[] { "crupellarius", "praetorian", "legend" }),
};
}
/// <summary>Gegner eines Kampfes (Werte aus der Stufe berechnet).</summary>
internal sealed record Enemy(string NameKey, int Tier, bool IsChampion, double Hp, double Damage, double Agility)
{
/// Fester Anzeigename statt Sprach-Key (Legenden: der Name des Spielers).
public string? Display { get; init; }
/// Bild statt aus dem Key abgeleitet (Legenden: Klassen-Figur).
public string? Art { get; init; }
public string Name => Display ?? L.t(NameKey);
public static Enemy Create(int arena, int rank, bool champion)
{
var a = ArenaDef.All[arena];
int tier = arena * Balance.RANKS_PER_ARENA + Math.Min(rank, Balance.RANKS_PER_ARENA - 1);
if (champion)
return new Enemy(a.ChampionKey, tier, true,
Balance.EnemyHp(tier) * Balance.CHAMPION_HP,
Balance.EnemyDamage(tier) * Balance.CHAMPION_DMG,
Balance.EnemyAgi(tier) * Balance.CHAMPION_AGI);
string foe = "foe." + a.Foes[rank % a.Foes.Length];
return new Enemy(foe, tier, false, Balance.EnemyHp(tier), Balance.EnemyDamage(tier), Balance.EnemyAgi(tier));
}
}
}
namespace GladiatorIdle
{
/// <summary>Sprach-Keys, die aus Enums/Listen gebaut werden (stehen nicht wörtlich im Code).</summary>
internal static class TextKeys
{
public static string Of(Stat s) => "stat." + s.ToString().ToLowerInvariant();
public static string Of(Special s) => "special." + s.ToString().ToLowerInvariant();
/// Alle gebauten Keys — der Playtest prüft, dass jeder in en.json steht.
public static IEnumerable<string> All()
{
foreach (var c in ClassDef.All) { yield return c.Key; yield return Of(c.Special); }
foreach (Stat s in Enum.GetValues<Stat>()) yield return Of(s);
foreach (God g in Enum.GetValues<God>()) { yield return Gods.Key(g); yield return Gods.Key(g) + ".desc"; }
foreach (var u in UpgradeDef.All)
{
yield return u.Key;
if (u.Kind != UpgradeKind.Trainer) yield return u.Key + ".desc";
}
foreach (var b in ItemBase.All) yield return b.Key;
foreach (var r in RegionDef.All) yield return r.Key;
foreach (var c in Appearance.Colors) yield return c.Key;
foreach (OfferKind k in Enum.GetValues<OfferKind>()) yield return "offer." + k.ToString().ToLowerInvariant();
foreach (var e in Appearance.Emblems) yield return "emblem." + e;
foreach (var s in SkillDef.All) { yield return s.Key; yield return s.Desc; }
foreach (SkillBranch b in Enum.GetValues<SkillBranch>()) yield return "branch." + b.ToString().ToLowerInvariant();
for (int i = 1; i <= Adventures.LOG_LINES; i++) yield return "expedition.log." + i;
foreach (BuffKind k in Enum.GetValues<BuffKind>()) yield return "buff." + k.ToString().ToLowerInvariant();
foreach (var e in Adventures.Events)
{
yield return e.Title; yield return e.Text;
foreach (var c in e.Choices)
{
yield return e.ChoiceKey(c);
yield return e.OutcomeKey(c, true);
if (c.Chance < 1) yield return e.OutcomeKey(c, false);
}
}
foreach (ItemSlot s in Enum.GetValues<ItemSlot>()) yield return "slot." + s.ToString().ToLowerInvariant();
foreach (Rarity r in Enum.GetValues<Rarity>()) yield return "rarity." + r.ToString().ToLowerInvariant();
foreach (Affix a in Enum.GetValues<Affix>()) yield return "affix." + a.ToString().ToLowerInvariant();
foreach (var a in ArenaDef.All)
{
yield return a.Key; yield return a.ChampionKey;
foreach (var f in a.Foes) yield return "foe." + f;
}
}
}
}