protected override void AppendEvent(GameLogEvent gameLogEvent, GameSnapshot gameSnapshot) { base.AppendEvent(gameLogEvent, gameSnapshot); using var context = new DosDbContext(); context.ReplayMove.Add(new ReplayMove { TargetPlayer = gameLogEvent.TargetPlayer, SourcePlayer = gameLogEvent.SourcePlayer, Cards = gameLogEvent.Cards, EventType = gameLogEvent.EventType, ReplayId = replayId }); context.ReplaySnapshot.Add(new ReplaySnapshot { CenterRow = gameSnapshot.CenterRow, PlayerHands = gameSnapshot.PlayerHands, ReplayId = replayId, CurrentPlayerId = gameSnapshot.CurrentPlayerId, }); context.SaveChanges(); }
private void Init(DiscordDosGame discordGame) { var replay = new Replay { GameStartDate = DateTime.UtcNow, Players = discordGame.Players.Select(p => new ReplayPlayer { OrderId = p.OrderId, PlayerName = p.Name }) .ToList(), IsOngoing = true, ChannelTitle = discordGame.Info.Channel.Name, GuildTitle = discordGame.Info.ServerName, IsPublic = discordGame.Config.PublishReplays }; using var context = new DosDbContext(); context.Replay.Add(replay); context.SaveChanges(); replayId = replay.ReplayId; }