using System.Collections.Generic;
namespace Luneraria.Core
{
///
/// Combat definition of a unit type: troop, monster, send, hero, champion, boss or building.
/// One type for all, as in the reference, where definitions were dictionaries; the defaults
/// are the fallbacks the rules used for missing keys (e.g. SiegeFactor 1, HpFactor 1).
///
public sealed class UnitDef
{
public string Id = "";
public string DisplayName = "";
public int Cost;
public string UpgradeId = "";
public double MaxHp = 1.0;
public double Damage;
/// 0 Klinge, 1 Durchschlag, 2 Impuls.
public int AttackType;
/// 0 Leicht, 1 Schwer, 2 Ätherisch.
public int ArmorType;
public double AttackRange = 1.0;
public double Speed = 2.0;
public string Ability = "";
public int LeakValue;
public int Bounty;
public string AbilityDescription = "";
public bool IsBoss;
public int IncomeGain;
// Set by the match for army units and heroes.
public string Role = "";
public string HeroId = "";
public int Level = 1;
public double ViewScale = 1.0;
public double Regen;
public double ItemSplash;
public List Talents = new List();
public double DamageBonus;
public double ReductionBonus;
public double AttackSpeedBonus;
/// Heroes with an ultimate (H1): the trigger rule chosen in planning, "" = none.
public string UltimateRule = "";
/// H1: cosmetic skin of a hero ("" = standard); the view swaps materials, the rules never read it.
public string Skin = "";
// Attack champions.
public string ChampionId = "";
public string Priority = "";
public double SiegeFactor = 1.0;
// Monsters: wave strength factor (heals of e06 scale with it).
public double HpFactor = 1.0;
// Buildings: outer, inner, base or core.
public string Tier = "";
public UnitDef Clone()
{
var copy = (UnitDef)MemberwiseClone();
copy.Talents = new List(Talents);
return copy;
}
}
public sealed class HeroSpec
{
public string Id = "";
public string Name = "";
public string Title = "";
public string Model = "";
public int Cost;
public string RoleText = "";
public bool Provisional;
public string Summary = "";
/// H1 heroes describe their own kit; reference heroes show the ability of their troop model.
public string PassiveText = "";
public string AbilityText = "";
public string UltimateName = "";
public string UltimateText = "";
/// Level-1 values without items and talents.
public UnitDef Base = new UnitDef();
}
public sealed class TalentOption
{
public readonly string Id;
public readonly string Name;
public readonly string Text;
public TalentOption(string id, string name, string text)
{
Id = id;
Name = name;
Text = text;
}
}
public sealed class ItemSpec
{
public string Id = "";
public string Name = "";
public int Cost;
public string Text = "";
public double HpFlat;
public double Damage;
public double Reduction;
public double AttackSpeed;
public double Regen;
public double Splash;
public int MinLevel = 1;
}
public sealed class ChampionSpec
{
public string Id = "";
public string Name = "";
public string RoleText = "";
public string Model = "";
public int Cost;
/// Send type whose base values the champion scales (s02, s03, s04).
public string Base = "";
public string Text = "";
public string Priority = "";
public double SiegeFactor = 1.0;
public double ViewScale = 1.0;
}
public sealed class BotProfile
{
public string Name = "";
public double Front;
public double Melee;
public double Ranged;
public double Splash;
public double Support;
public int UpgradeFrom;
public double SupportLane;
public string Hero = "";
public int HeroRound;
public string[] Items = new string[0];
public int[] TalentChoices = new int[0];
public string Champion = "";
/// Boss hunters only; 0 = never goes to the grotto.
public int BossFrom;
public int BossTroops;
public bool HuntsBoss { get { return BossFrom > 0; } }
public double Share(string role)
{
switch (role)
{
case "front": return Front;
case "melee": return Melee;
case "ranged": return Ranged;
case "splash": return Splash;
default: return Support;
}
}
}
public static partial class ContentData
{
static OrderedMap Map(params UnitDef[] entries)
{
var map = new OrderedMap();
foreach (UnitDef entry in entries)
map[entry.Id] = entry;
return map;
}
static OrderedMap Ordered(params HeroSpec[] entries)
{
var map = new OrderedMap();
foreach (HeroSpec entry in entries)
map[entry.Id] = entry;
return map;
}
static OrderedMap Ordered(params ItemSpec[] entries)
{
var map = new OrderedMap();
foreach (ItemSpec entry in entries)
map[entry.Id] = entry;
return map;
}
static OrderedMap Ordered(params ChampionSpec[] entries)
{
var map = new OrderedMap();
foreach (ChampionSpec entry in entries)
map[entry.Id] = entry;
return map;
}
static OrderedMap Ordered(params BotProfile[] entries)
{
var map = new OrderedMap();
foreach (BotProfile entry in entries)
map[entry.Name] = entry;
return map;
}
static OrderedMap Pairs(params string[] keysAndValues)
{
var map = new OrderedMap();
for (int i = 0; i + 1 < keysAndValues.Length; i += 2)
map[keysAndValues[i]] = keysAndValues[i + 1];
return map;
}
}
}