改了一亿个东西,修了一亿个 BUG
This commit is contained in:
108
ModData.cs
108
ModData.cs
@@ -1,8 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AnotherReplayReader
|
||||
{
|
||||
@@ -42,13 +39,13 @@ namespace AnotherReplayReader
|
||||
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if(!(other is Mod))
|
||||
if (!(other is Mod))
|
||||
{
|
||||
return GetType().FullName.CompareTo(other.GetType().FullName);
|
||||
}
|
||||
|
||||
var otherMod = (Mod)other;
|
||||
if(IsRA3 != otherMod.IsRA3)
|
||||
if (IsRA3 != otherMod.IsRA3)
|
||||
{
|
||||
if (IsRA3)
|
||||
{
|
||||
@@ -84,20 +81,13 @@ namespace AnotherReplayReader
|
||||
|
||||
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;
|
||||
private static readonly Faction _unknown = new(FactionKind.Unknown, "未知阵营");
|
||||
private static readonly IReadOnlyDictionary<string, IReadOnlyDictionary<int, Faction>> _factions;
|
||||
|
||||
|
||||
static ModData()
|
||||
{
|
||||
_ra3Factions = new Dictionary<int, Faction>
|
||||
var ra3Factions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -106,8 +96,8 @@ namespace AnotherReplayReader
|
||||
{ 4, new Faction(FactionKind.Player, "盟军") },
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3ARFactions = new Dictionary<int, Faction>
|
||||
};
|
||||
var arFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 1, new Faction(FactionKind.Player, "阳炎") },
|
||||
{ 2, new Faction(FactionKind.Player, "天琼") },
|
||||
@@ -123,7 +113,7 @@ namespace AnotherReplayReader
|
||||
{ 14, new Faction(FactionKind.Player, "涅墨西斯") },
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
};
|
||||
_ra3CoronaFactions = new Dictionary<int, Faction>
|
||||
var coronaFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -134,7 +124,7 @@ namespace AnotherReplayReader
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
{ 9, new Faction(FactionKind.Player, "神州") },
|
||||
};
|
||||
_ra3DawnFactions = new Dictionary<int, Faction>
|
||||
var dawnFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -147,7 +137,7 @@ namespace AnotherReplayReader
|
||||
{ 11, new Faction(FactionKind.Player, "随机") },
|
||||
{ 12, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3INSFactions = new Dictionary<int, Faction>
|
||||
var insFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -157,7 +147,7 @@ namespace AnotherReplayReader
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3FSFactions = new Dictionary<int, Faction>
|
||||
var fsFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -167,7 +157,7 @@ namespace AnotherReplayReader
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3EisenreichFactions = new Dictionary<int, Faction>
|
||||
var eisenreichFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -177,7 +167,7 @@ namespace AnotherReplayReader
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3TNWFactions = new Dictionary<int, Faction>
|
||||
var tnwFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -187,7 +177,7 @@ namespace AnotherReplayReader
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_ra3WOPFactions = new Dictionary<int, Faction>
|
||||
var wopFactions = new Dictionary<int, Faction>
|
||||
{
|
||||
{ 0, new Faction(FactionKind.Player, "AI") },
|
||||
{ 1, new Faction(FactionKind.Observer, "观察员") },
|
||||
@@ -197,61 +187,31 @@ namespace AnotherReplayReader
|
||||
{ 7, new Faction(FactionKind.Player, "随机") },
|
||||
{ 8, new Faction(FactionKind.Player, "苏联") },
|
||||
};
|
||||
_unknown = new Faction(FactionKind.Unknown, "未知阵营");
|
||||
_factions = new Dictionary<string, IReadOnlyDictionary<int, Faction>>(StringComparer.CurrentCultureIgnoreCase)
|
||||
{
|
||||
["RA3"] = ra3Factions,
|
||||
["Armor Rush"] = arFactions,
|
||||
["ART"] = arFactions,
|
||||
["corona"] = coronaFactions,
|
||||
["Dawn"] = dawnFactions,
|
||||
["Insurrection"] = insFactions,
|
||||
["1.12+FS"] = fsFactions,
|
||||
["Eisenreich"] = eisenreichFactions,
|
||||
["The New World"] = tnwFactions,
|
||||
["War Of Powers"] = wopFactions
|
||||
};
|
||||
}
|
||||
|
||||
public static Faction GetFaction(Mod mod, int factionID)
|
||||
public static Faction GetFaction(Mod mod, int factionId)
|
||||
{
|
||||
new Faction(FactionKind.Player, mod.ModName + "-" + factionID);
|
||||
|
||||
if
|
||||
(mod.ModName.Equals("RA3"))
|
||||
if (_factions.TryGetValue(mod.ModName, out var table))
|
||||
{
|
||||
return _ra3Factions.TryGetValue(factionID, out var faction) ? faction : _unknown;
|
||||
if (table.TryGetValue(factionId, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
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