public void Log(MatchSummary summary)
        {
            var result = JsonConvert.SerializeObject(
                summary,
                Formatting.Indented,
                new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                }
            );

            using (
                var writer =
                    new StreamWriter(ReplayDirectory + Path.DirectorySeparatorChar +
                                     Settings.Default.MatchResultFilename))
            {
                writer.WriteLine(result);
            }
        }
 public void Log(MatchSummary summary)
 {
 }
 public void Log(MatchSummary summary)
 {
     var message = String.Format("Match result: Player {0} wins{1}Win reason: {2}", summary.Winner, Environment.NewLine, summary.WinReason);
     Debug.WriteLine(message);
     Console.WriteLine(message);
 }
 private void LogAll(MatchSummary summary)
 {
     foreach (ILogger logger in _loggers) {
         logger.Log(summary);
     }
 }
 public void Log(MatchSummary result)
 {
     Log(String.Format("Match result: Player {0} wins", result.Winner));
     Log(String.Format("Win reason: {0}", result.WinReason));
 }
        public MatchSummary RenderSummary(IMatch renderMatch)
        {
            var match = (Match)renderMatch;

            var result = new MatchSummary
            {
                Rounds = match.GetRoundNumber()
            };

            result.Players.Add(RenderPlayer(match, 1));
            result.Players.Add(RenderPlayer(match, 2));

            RenderWinDetails(result, match);

            return result;
        }
        protected static void RenderWinDetails(MatchSummary result, Match match)
        {
            if (match.GetResult() == MatchResult.Tie)
            {
                result.Winner = 1;
                result.WinReason = "Match was a tie, so player 1 wins by default.";
                return;
            }

            var winner = match.GetResult() == MatchResult.PlayerOneWins ? match.GetPlayer(1) : match.GetPlayer(2);
            var opponent = match.GetResult() == MatchResult.PlayerOneWins ? match.GetPlayer(2) : match.GetPlayer(1);

            result.Winner = winner.PlayerNumber;

            if (((opponent.Lives <= 0) && (opponent.Ship == null)) &&
                ((winner.Lives > 0) || (winner.Ship != null)))
            {
                result.WinReason = String.Format("Player {0} ran out of lives.", opponent.PlayerNumber);
            }
            else
            {
                result.WinReason = String.Format("Player {0} had more kills than player {1}.", winner.PlayerNumber,
                    opponent.PlayerNumber);
            }
        }