Add project files.
This commit is contained in:
258
ModData.cs
Normal file
258
ModData.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AnotherReplayReader
|
||||
{
|
||||
enum FactionKind
|
||||
{
|
||||
Player,
|
||||
Observer,
|
||||
Unknown
|
||||
}
|
||||
|
||||
internal sealed class Mod : IComparable
|
||||
{
|
||||
public readonly string ModName;
|
||||
public readonly string ModVersion;
|
||||
public bool IsRA3 => ModName.Equals("RA3");
|
||||
|
||||
public Mod(string modInfo)
|
||||
{
|
||||
var splitted = modInfo.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
ModName = splitted[0];
|
||||
ModVersion = string.Empty;
|
||||
if (IsRA3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ModVersion = splitted[1];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (IsRA3)
|
||||
{
|
||||
return "原版";
|
||||
}
|
||||
return ModName + ' ' + ModVersion;
|
||||
}
|
||||
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if(!(other is Mod))
|
||||
{
|
||||
return GetType().FullName.CompareTo(other.GetType().FullName);
|
||||
}
|
||||
|
||||
var otherMod = (Mod)other;
|
||||
if(IsRA3 != otherMod.IsRA3)
|
||||
{
|
||||
if (IsRA3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
var modCompare = ModName.CompareTo(otherMod.ModName);
|
||||
if (modCompare != 0)
|
||||
{
|
||||
return modCompare;
|
||||
}
|
||||
|
||||
return ModVersion.CompareTo(otherMod.ModVersion);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class Faction
|
||||
{
|
||||
public readonly FactionKind Kind;
|
||||
public readonly string Name;
|
||||
|
||||
public Faction(FactionKind kind, string name)
|
||||
{
|
||||
Kind = kind;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class ModData
|
||||
{
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3Factions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3ARFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3CoronaFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3DawnFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3INSFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3FSFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3EisenreichFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3TNWFactions;
|
||||
private static readonly IReadOnlyDictionary<int, Faction> _ra3WOPFactions;
|
||||
private static readonly Faction _unknown;
|
||||
|
||||
static ModData()
|
||||
{
|
||||
_ra3Factions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3ARFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 1, new Faction(FactionKind.Player, "阳炎") },
|
||||
{ 2, new Faction(FactionKind.Player, "天琼") },
|
||||
{ 3, new Faction(FactionKind.Player, "OB") },
|
||||
{ 4, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 5, new Faction(FactionKind.Player, "鹰眼") },
|
||||
{ 6, new Faction(FactionKind.Player, "解说员") },
|
||||
{ 7, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 8, new Faction(FactionKind.Player, "克格勃") },
|
||||
{ 11, new Faction(FactionKind.Player, "血月") },
|
||||
{ 12, new Faction(FactionKind.Player, "随机") },
|
||||
{ 13, new Faction(FactionKind.Player, "苏联") },
|
||||
{ 14, new Faction(FactionKind.Player, "涅墨西斯") },
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
};
|
||||
_ra3CoronaFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
{ 9, new Faction(FactionKind.Player, "神州") },
|
||||
};
|
||||
_ra3DawnFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "禁卫军") },
|
||||
{ 5, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 9, new Faction(FactionKind.Player, "革命军") },
|
||||
{ 10, new Faction(FactionKind.Player, "德法同盟") },
|
||||
{ 11, new Faction(FactionKind.Player, "随机") },
|
||||
{ 12, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3INSFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3FSFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3EisenreichFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "德国") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3TNWFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "帝国") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3WOPFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
{ 2, new Faction(FactionKind.Player, "日本") },
|
||||
{ 3, new Faction(FactionKind.Observer, "解说员") },
|
||||
{ 4, new Faction(FactionKind.Player, "美国") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_unknown = new Faction(FactionKind.Unknown, "未知阵营");
|
||||
}
|
||||
|
||||
public static Faction GetFaction(Mod mod, int factionID)
|
||||
{
|
||||
new Faction(FactionKind.Player, mod.ModName + "-" + factionID);
|
||||
|
||||
if
|
||||
(mod.ModName.Equals("RA3"))
|
||||
{
|
||||
return _ra3Factions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("Armor Rush"))
|
||||
{
|
||||
return _ra3ARFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("ART"))
|
||||
{
|
||||
return _ra3ARFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("corona"))
|
||||
{
|
||||
return _ra3CoronaFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("Dawn"))
|
||||
{
|
||||
return _ra3DawnFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("Insurrection"))
|
||||
{
|
||||
return _ra3INSFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("1.12+FS"))
|
||||
{
|
||||
return _ra3FSFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("Eisenreich"))
|
||||
{
|
||||
return _ra3EisenreichFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("The New World"))
|
||||
{
|
||||
return _ra3TNWFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
if (mod.ModName.Equals("War Of Powers"))
|
||||
{
|
||||
return _ra3WOPFactions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return _unknown;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user