2018-04-13 02:32:30 -04:00
|
|
|
|
using System;
|
2018-04-23 01:43:48 -04:00
|
|
|
|
using System.Collections.Generic;
|
2018-04-15 00:26:27 -04:00
|
|
|
|
using System.IO;
|
2018-04-13 02:32:30 -04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
|
|
|
|
|
namespace Application.EventParsers
|
|
|
|
|
{
|
|
|
|
|
class T6MEventParser : IEventParser
|
|
|
|
|
{
|
|
|
|
|
public GameEvent GetEvent(Server server, string logLine)
|
|
|
|
|
{
|
2018-04-23 01:43:48 -04:00
|
|
|
|
string cleanedEventLine = Regex.Replace(logLine, @"^ *[0-9]+:[0-9]+ *", "").Trim();
|
|
|
|
|
string[] lineSplit = cleanedEventLine.Split(';');
|
2018-04-13 02:32:30 -04:00
|
|
|
|
|
2018-04-15 21:27:43 -04:00
|
|
|
|
if (lineSplit[0][0] == 'K')
|
2018-04-13 02:32:30 -04:00
|
|
|
|
{
|
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.Script,
|
2018-04-23 01:43:48 -04:00
|
|
|
|
Data = cleanedEventLine,
|
2018-04-13 02:32:30 -04:00
|
|
|
|
Origin = server.GetPlayersAsList().First(c => c.ClientNumber == Utilities.ClientIdFromString(lineSplit, 6)),
|
|
|
|
|
Target = server.GetPlayersAsList().First(c => c.ClientNumber == Utilities.ClientIdFromString(lineSplit, 2)),
|
|
|
|
|
Owner = server
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-15 21:27:43 -04:00
|
|
|
|
if (lineSplit[0][0] == 'D')
|
|
|
|
|
{
|
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.Damage,
|
2018-04-23 01:43:48 -04:00
|
|
|
|
Data = cleanedEventLine,
|
2018-04-15 21:27:43 -04:00
|
|
|
|
Origin = server.GetPlayersAsList().First(c => c.ClientNumber == Utilities.ClientIdFromString(lineSplit, 6)),
|
|
|
|
|
Target = server.GetPlayersAsList().First(c => c.ClientNumber == Utilities.ClientIdFromString(lineSplit, 2)),
|
|
|
|
|
Owner = server
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 18:52:48 -04:00
|
|
|
|
if (lineSplit[0] == "say" || lineSplit[0] == "sayteam")
|
2018-04-13 02:32:30 -04:00
|
|
|
|
{
|
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.Say,
|
|
|
|
|
Data = lineSplit[4],
|
|
|
|
|
Origin = server.GetPlayersAsList().First(c => c.ClientNumber == Utilities.ClientIdFromString(lineSplit, 2)),
|
|
|
|
|
Owner = server,
|
|
|
|
|
Message = lineSplit[4]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 16:46:53 -04:00
|
|
|
|
if (lineSplit[0].Contains("ExitLevel"))
|
2018-04-13 02:32:30 -04:00
|
|
|
|
{
|
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.MapEnd,
|
|
|
|
|
Data = lineSplit[0],
|
|
|
|
|
Origin = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
|
|
|
|
Target = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
|
|
|
|
Owner = server
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-15 21:27:43 -04:00
|
|
|
|
if (lineSplit[0].Contains("InitGame"))
|
2018-04-13 02:32:30 -04:00
|
|
|
|
{
|
2018-04-23 01:43:48 -04:00
|
|
|
|
string dump = cleanedEventLine.Replace("InitGame: ", "");
|
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.MapChange,
|
|
|
|
|
Data = lineSplit[0],
|
|
|
|
|
Origin = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
|
|
|
|
Target = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
2018-04-23 01:43:48 -04:00
|
|
|
|
Owner = server,
|
2018-04-24 18:01:27 -04:00
|
|
|
|
Extra = dump.DictionaryFromKeyValue()
|
2018-04-13 02:32:30 -04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new GameEvent()
|
|
|
|
|
{
|
|
|
|
|
Type = GameEvent.EventType.Unknown,
|
|
|
|
|
Origin = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
|
|
|
|
Target = new Player()
|
|
|
|
|
{
|
|
|
|
|
ClientId = 1
|
|
|
|
|
},
|
|
|
|
|
Owner = server
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-15 00:26:27 -04:00
|
|
|
|
|
|
|
|
|
public string GetGameDir() => $"t6r{Path.DirectorySeparatorChar}data";
|
2018-04-13 02:32:30 -04:00
|
|
|
|
}
|
|
|
|
|
}
|