public void LoadReplayXML(string zipFilePath) { App.logger.LogMessage("Parsing Replay File: " + zipFilePath); XmlSerializer serializer = new XmlSerializer(typeof(Replay)); string filename = @"F:\bloodbowl\BB2Replays\Coach-90995-a69d4914f53cb5244bf08ecdaf0872f6_2015-12-31_15_34_04\Replay.xml"; //string filename = Environment.SpecialFolder.MyDocuments + @"\BloodBowl2\Profiles\3EAD1B73DBA10132713B8B56C1675837\Replays\ReplayIndex.xml"; status = "About to read XML replay file"; var za = ZipFile.OpenRead(zipFilePath + ".bbrz"); foreach (var entry in za.Entries) { using (var r = new StreamReader(entry.Open())) { // using (Stream reader = new FileStream(r, FileMode.Open)) // { // status = "About to deserialize XML replay"; // Call the Deserialize method to restore the object's state. replay = (Replay)serializer.Deserialize(r); //} matchResultXML = replay.ReplayStep[replay.ReplayStep.Length - 1].RulesEventGameFinished[0]; ReplayReplayStepBoardStateListTeamsTeamState[] matchStartTeamStatesXML = replay.ReplayStep[0].BoardState[0].ListTeams; matchResult = new MatchResult(matchResultXML, matchStartTeamStatesXML); //MatchStats matchStats = new MatchStats(replay, matchResult); } } }
public MatchResult(ReplayReplayStepRulesEventGameFinishedMatchResult matchResultXML, ReplayReplayStepBoardStateListTeamsTeamState[] matchStartTeamStatesXML) { awayMetresRunning = GetStat(matchResultXML.Row[0].AwayInflictedMetersRunning); awayMetresPassing = GetStat(matchResultXML.Row[0].AwayInflictedMetersPassing); awayPasses = GetStat(matchResultXML.Row[0].AwayInflictedPasses); awayCatches = GetStat(matchResultXML.Row[0].AwayInflictedCatches); awayStunsInflicted = GetStat(matchResultXML.Row[0].AwayInflictedStuns); awayKOsInflicted = GetStat(matchResultXML.Row[0].AwayInflictedKO); awayInjuriesInflicted = GetStat(matchResultXML.Row[0].AwayInflictedInjuries); awayCasInflicted = GetStat(matchResultXML.Row[0].AwayInflictedCasualties); awayDeathsInflicted = GetStat(matchResultXML.Row[0].AwayInflictedDead); homeMetresRunning = GetStat(matchResultXML.Row[0].HomeInflictedMetersRunning); homeMetresPassing = GetStat(matchResultXML.Row[0].HomeInflictedMetersPassing); homePasses = GetStat(matchResultXML.Row[0].HomeInflictedPasses); homeCatches = GetStat(matchResultXML.Row[0].HomeInflictedCatches); homeStunsInflicted = GetStat(matchResultXML.Row[0].HomeInflictedStuns); homeKOsInflicted = GetStat(matchResultXML.Row[0].HomeInflictedKO); homeInjuriesInflicted = GetStat(matchResultXML.Row[0].HomeInflictedInjuries); homeCasInflicted = GetStat(matchResultXML.Row[0].HomeInflictedCasualties); homeDeathsInflicted = GetStat(matchResultXML.Row[0].HomeInflictedDead); awaySupporters = GetStat(matchResultXML.Row[0].AwayNbSupporters); homeSupporters = GetStat(matchResultXML.Row[0].HomeNbSupporters); //GetStat(matchResultXML.Row[0].); homeTeam = matchResultXML.Row[0].TeamHomeName; awayTeam = matchResultXML.Row[0].TeamAwayName; homeRace = GetRace(matchResultXML.Row[0].IdRacesHome); awayRace = GetRace(matchResultXML.Row[0].IdRacesAway); displayMatchHeader = homeTeam + " V " + awayTeam; homeCoach = matchResultXML.Row[0].CoachHomeName; awayCoach = matchResultXML.Row[0].CoachAwayName; homeCoachedBy = homeRace + " coached by " + homeCoach; awayCoachedBy = awayRace + " coached by " + awayCoach; if (matchResultXML.Row[0].HomeScore != null) { homeScore = int.Parse(matchResultXML.Row[0].HomeScore); } else { homeScore = 0; } if (matchResultXML.Row[0].AwayScore != null) { awayScore = int.Parse(matchResultXML.Row[0].AwayScore); } else { awayScore = 0; } homeCheerleaders = GetStat(matchResultXML.CoachResults[0].TeamResult[0].TeamData[0].Cheerleaders); awayCheerleaders = GetStat(matchResultXML.CoachResults[1].TeamResult[0].TeamData[0].Cheerleaders); homeAssistantCoaches = GetStat(matchResultXML.CoachResults[0].TeamResult[0].TeamData[0].CoachSlot); awayAssistantCoaches = GetStat(matchResultXML.CoachResults[1].TeamResult[0].TeamData[0].CoachSlot); homeApothecary = GetStat(matchResultXML.CoachResults[0].TeamResult[0].TeamData[0].Apothecary); awayApothecary = GetStat(matchResultXML.CoachResults[1].TeamResult[0].TeamData[0].Apothecary); homeRerolls = GetStat(matchResultXML.CoachResults[0].TeamResult[0].TeamData[0].Reroll); awayRerolls = GetStat(matchResultXML.CoachResults[1].TeamResult[0].TeamData[0].Reroll); homeTeamValue = GetStat(matchResultXML.CoachResults[0].TeamResult[0].TeamData[0].Value); awayTeamValue = GetStat(matchResultXML.CoachResults[1].TeamResult[0].TeamData[0].Value); displayMatchResult = homeScore + " " + awayScore; homePlayersStart = new Dictionary <string, Player>(); for (int i = 0; i < matchStartTeamStatesXML[0].ListPitchPlayers.Length; i++) { Player p = new Player(); p.LoadPlayerData(matchStartTeamStatesXML[0].ListPitchPlayers[i]); if (p.uniqueID != null) //null values for currently MNG injured players?? { homePlayersStart.Add(p.uniqueID, p); } } awayPlayersStart = new Dictionary <string, Player>(); for (int i = 0; i < matchStartTeamStatesXML[1].ListPitchPlayers.Length; i++) { Player p = new Player(); p.LoadPlayerData(matchStartTeamStatesXML[1].ListPitchPlayers[i]); if (p.uniqueID != null) { awayPlayersStart.Add(p.uniqueID, p); } } homePlayers = new List <Player>(); for (int i = 0; i < matchResultXML.CoachResults[0].TeamResult[0].PlayerResults.Length; i++) { Player p = new Player(); p.LoadPlayerData(matchResultXML.CoachResults[0].TeamResult[0].PlayerResults[i], homePlayersStart); homePlayers.Add(p); } awayPlayers = new List <Player>(); for (int i = 0; i < matchResultXML.CoachResults[1].TeamResult[0].PlayerResults.Length; i++) { Player p = new Player(); p.LoadPlayerData(matchResultXML.CoachResults[1].TeamResult[0].PlayerResults[i], awayPlayersStart); awayPlayers.Add(p); } int homeTVofPlayers = homePlayers.Sum(p => p.TV); int awayTVofPlayers = awayPlayers.Sum(p => p.TV); }