2021-10-20 22:22:19 +02:00

43 lines
1.2 KiB
C#

using System.Collections.Generic;
namespace AnotherReplayReader.ReplayFile
{
internal sealed class Player
{
public static readonly IReadOnlyDictionary<string, string> ComputerNames = new Dictionary<string, string>
{
{ "E", "简单" },
{ "M", "中等" },
{ "H", "困难" },
{ "B", "凶残" },
};
public bool IsComputer { get; }
public string PlayerName { get; }
public uint PlayerIp { get; }
public int FactionId { get; }
public int Team { get; }
public Player(string[] playerEntry)
{
IsComputer = playerEntry[0][0] == 'C';
PlayerName = playerEntry[0].Substring(1);
if (IsComputer)
{
PlayerName = ComputerNames[PlayerName];
PlayerIp = 0;
FactionId = int.Parse(playerEntry[2]);
Team = int.Parse(playerEntry[4]);
}
else
{
PlayerIp = uint.Parse(playerEntry[1], System.Globalization.NumberStyles.HexNumber);
FactionId = int.Parse(playerEntry[5]);
Team = int.Parse(playerEntry[7]);
}
}
}
}