public static DSReplay GetDetails(dynamic details) { DSReplay replay = new DSReplay() { DSPlayer = new HashSet <DSPlayer>() }; byte failsafe_pos = 0; foreach (var player in details["m_playerList"]) { if ((int)player["m_observe"] > 0) { continue; } failsafe_pos++; string name = DecodeService.GetString(player, "m_name"); Match m2 = rx_subname.Match(name); if (m2.Success) { name = m2.Groups[1].Value; } replay.DSPlayer.Add(new DSPlayer() { NAME = name, RACE = DecodeService.GetString(player, "m_race"), RESULT = (byte)(int)player["m_result"], TEAM = (byte)(int)player["m_teamId"], POS = failsafe_pos, WORKINGSETSLOT = player["m_workingSetSlotId"] != null ? (byte)(int)player["m_workingSetSlotId"] : (byte)0, Stats = new List <DbStats>(), Spawns = new List <DbSpawn>(), Refineries = new List <DbRefinery>(), Upgrades = new List <DbUpgrade>() }); } replay.PLAYERCOUNT = (byte)replay.DSPlayer.Count; long timeutc = (long)details["m_timeUTC"]; long georgian = timeutc; replay.GAMETIME = DateTime.FromFileTime(georgian); replay.GAMETIME = new DateTime(replay.GAMETIME.Year, replay.GAMETIME.Month, replay.GAMETIME.Day, replay.GAMETIME.Hour, replay.GAMETIME.Minute, replay.GAMETIME.Second, 0, replay.GAMETIME.Kind); return(replay); }
static void Main(string[] args) { var logger = ApplicationLogging.CreateLogger <Program>(); logger.LogInformation("Running ..."); DecodeService decodeService = new DecodeService(); // NameService.Init(); List <string> replays = new List <string>() { @"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3870).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3871).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3872).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3873).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3874).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3875).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3876).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3877).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3878).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3860).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3861).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3862).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3863).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3864).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3865).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3866).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3867).SC2Replay", //@"C:\Users\pax77\Documents\StarCraft II\Accounts\107095918\2-S2-1-226401\Replays\Multiplayer\Direct Strike (3868).SC2Replay", }; CancellationTokenSource source = new CancellationTokenSource(); decodeService.DecodeReplays("", replays, 1, source.Token); Console.ReadLine(); }
public static void GetTrackerEvents(DSReplay replay, dynamic trackerevents_dec) { bool isBrawl_set = false; //bool noStagingAreaNextSpawn = true; bool noStagingAreaNextSpawn = false; if (replay.GAMETIME < new DateTime(2019, 03, 24, 21, 46, 15)) // 20190324214615 { noStagingAreaNextSpawn = true; } HashSet <string> Mutation = new HashSet <string>(); replay.Middle = new List <DbMiddle>() { new DbMiddle() { Gameloop = 0, Team = 0 } }; List <StagingAreaNextSpawn> stagingAreaNextSpawns = new List <StagingAreaNextSpawn>(); Vector2 ObjectivePlanetaryFortress = Vector2.Zero; Vector2 ObjectiveNexus = Vector2.Zero; Vector2 ObjectiveBunker = Vector2.Zero; Vector2 ObjectivePhotonCannon = Vector2.Zero; Vector2 Center = Vector2.Zero; KeyValuePair <Vector2, Vector2> LineT1 = new KeyValuePair <Vector2, Vector2>(Vector2.Zero, Vector2.Zero); KeyValuePair <Vector2, Vector2> LineT2 = new KeyValuePair <Vector2, Vector2>(Vector2.Zero, Vector2.Zero); KeyValuePair <int, int> PhotonCannon = new KeyValuePair <int, int>(); KeyValuePair <int, int> Bunker = new KeyValuePair <int, int>(); int LastSpawn = 480; foreach (PythonDictionary pydic in trackerevents_dec) { if (pydic.ContainsKey("m_unitTypeName")) //11998 { if (pydic.ContainsKey("m_controlPlayerId")) { int playerid = (int)pydic["m_controlPlayerId"]; int gameloop = (int)pydic["_gameloop"]; // Game end if (DecodeService.GetString(pydic, "m_unitTypeName").StartsWith("DeathBurst")) { replay.DURATION = (int)(gameloop / 22.4); if (playerid == 13) { replay.WINNER = 1; } else if (playerid == 14) { replay.WINNER = 0; } break; } // Objectives init if (gameloop == 0 && pydic.ContainsKey("m_creatorAbilityName") && (pydic["m_creatorAbilityName"] == null || DecodeService.GetString(pydic, "m_creatorAbilityName") == "")) { if (DecodeService.GetString(pydic, "m_unitTypeName") == "ObjectivePlanetaryFortress") { ObjectivePlanetaryFortress = new Vector2((int)pydic["m_x"], (int)pydic["m_y"]); } else if (DecodeService.GetString(pydic, "m_unitTypeName") == "ObjectiveNexus") { ObjectiveNexus = new Vector2((int)pydic["m_x"], (int)pydic["m_y"]); } else if (DecodeService.GetString(pydic, "m_unitTypeName") == "ObjectiveBunker") { ObjectiveBunker = new Vector2((int)pydic["m_x"], (int)pydic["m_y"]); Bunker = new KeyValuePair <int, int>((int)pydic["m_unitTagIndex"], (int)pydic["m_unitTagRecycle"]); } else if (DecodeService.GetString(pydic, "m_unitTypeName") == "ObjectivePhotonCannon") { ObjectivePhotonCannon = new Vector2((int)pydic["m_x"], (int)pydic["m_y"]); PhotonCannon = new KeyValuePair <int, int>((int)pydic["m_unitTagIndex"], (int)pydic["m_unitTagRecycle"]); } if (ObjectiveBunker != Vector2.Zero && ObjectivePhotonCannon != Vector2.Zero && ObjectivePlanetaryFortress != Vector2.Zero && ObjectiveNexus != Vector2.Zero) { float x1t1 = ObjectivePlanetaryFortress.X + MathF.Cos(135 * MathF.PI / 180) * 100; float y1t1 = ObjectivePlanetaryFortress.Y + MathF.Sin(135 * MathF.PI / 180) * 100; float x2t1 = ObjectivePlanetaryFortress.X + MathF.Cos(315 * MathF.PI / 180) * 100; float y2t1 = ObjectivePlanetaryFortress.Y + MathF.Sin(315 * MathF.PI / 180) * 100; LineT1 = new KeyValuePair <Vector2, Vector2>(new Vector2(x1t1, y1t1), new Vector2(x2t1, y2t1)); float x1t2 = ObjectiveNexus.X + MathF.Cos(135 * MathF.PI / 180) * 100; float y1t2 = ObjectiveNexus.Y + MathF.Sin(135 * MathF.PI / 180) * 100; float x2t2 = ObjectiveNexus.X + MathF.Cos(315 * MathF.PI / 180) * 100; float y2t2 = ObjectiveNexus.Y + MathF.Sin(315 * MathF.PI / 180) * 100; LineT2 = new KeyValuePair <Vector2, Vector2>(new Vector2(x1t2, y1t2), new Vector2(x2t2, y2t2)); Center = new Vector2((ObjectiveNexus.X + ObjectivePlanetaryFortress.X) / 2, (ObjectiveNexus.Y + ObjectivePlanetaryFortress.Y) / 2); replay.OBJECTIVE = (Center.X, Center.Y) switch { (128.0f, 120.0f) => 1, (120.0f, 120.0f) => 2, (128.0f, 122.0f) => 3, _ => 0 }; } } if (playerid == 0 || playerid > 12) { continue; } // Player DSPlayer pl = replay.DSPlayer.SingleOrDefault(s => s.POS == playerid); if (pl == null) { pl = replay.DSPlayer.SingleOrDefault(s => s.WORKINGSETSLOT == playerid - 1); if (pl == null) { continue; } else { pl.POS = (byte)playerid; } } ; // Race if (gameloop < 1440) { Match m = rx_race2.Match(DecodeService.GetString(pydic, "m_unitTypeName")); if (m.Success && m.Groups[1].Value.Length > 0) { pl.RACE = m.Groups[1].Value; } } if (pydic.ContainsKey("m_creatorAbilityName")) { if (pydic["m_creatorAbilityName"] == null || DecodeService.GetString(pydic, "m_creatorAbilityName") == "") { if (gameloop == 0) { if (DecodeService.GetString(pydic, "_event") == "NNet.Replay.Tracker.SUnitBornEvent") { // Refineries init if (DecodeService.GetString(pydic, "m_unitTypeName").StartsWith("MineralField")) { int index = (int)pydic["m_unitTagIndex"]; int recycle = (int)pydic["m_unitTagRecycle"]; pl.Refineries.Add(new DbRefinery(gameloop, index, recycle, pl)); continue; } } } if (gameloop < 480) { continue; } if (noStagingAreaNextSpawn == false) { if (gameloop - LastSpawn >= 9) { continue; } } if (DecodeService.GetString(pydic, "_event") == "NNet.Replay.Tracker.SUnitBornEvent") { string born_unit = DecodeService.GetString(pydic, "m_unitTypeName"); bool isSpawnUnit = (born_unit switch { "TrophyRiftPremium" => true, "MineralIncome" => true, "ParasiticBombRelayDummy" => true, "Biomass" => true, "PurifierAdeptShade" => true, "PurifierTalisShade" => true, "HornerReaperLD9ClusterCharges" => true, "Broodling" => true, "Raptorling" => true, "InfestedLiberatorViralSwarm" => true, "SplitterlingSpawn" => true, "GuardianShell" => true, "BroodlingStetmann" => true, _ => false });