public TableDealer DealerForTable(Guid tableId) { return(_dealers.GetOrAdd(tableId, (key) => { PokerDbContext dbContext = _provider.ApplicationServices.CreateScope().ServiceProvider.GetService <PokerDbContext>(); var table = dbContext.Tables .Include(t => t.Seats) .SingleOrDefault(t => t.Id == tableId); if (table == null) { return null; } return new TableDealer(dbContext, _players, table); })); }
public MainViewModel Rooms() { var retval = new MainViewModel(); using (var context = new PokerDbContext()) { var rooms = context.Rooms.ToList(); foreach (var room in rooms) { retval.Rooms.Add(new RoomListItemViewModel() { Code = room.Code, Name = room.Name }); } } return(retval); }
public RoomViewModel Rooms(string code) { var retval = new RoomViewModel(); using (var context = new PokerDbContext()) { var rooms = context.Rooms.Where(x => x.Code == code).FirstOrDefault(); retval.Participants = new List <ParticipantViewModel>(); retval.Code = rooms.Code; retval.Name = rooms.Name; foreach (var participant in rooms.Participants) { retval.Participants.Add(new ParticipantViewModel() { Nick = participant.NickName }); } } return(retval); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PokerDbContext db, Helpers.Dealers dealers, Helpers.Players players) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); if (!env.IsDevelopment()) { app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => { if (ctx.File.PhysicalPath.Contains("wwwroot")) { ctx.Context.Response.Headers.Append("Cache-Control", $"public, max-age=86400"); } else { ctx.Context.Response.Headers.Append("Cache-Control", $"no-cache"); } } }); } app.UseStaticFiles(); // Add new mappings //var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider(); //provider.Mappings[".glb"] = "application/octet-stream"; //app.UseStaticFiles(new StaticFileOptions //{ // ContentTypeProvider = provider //}); db.Database.EnsureCreated(); dealers.SetProvider(app); players.SetProvider(app); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); }
public PokerDbContext Init() { return(_dbContext ?? (_dbContext = new PokerDbContext())); }
public void SetProvider(IApplicationBuilder provider) { _provider = provider; _dbContext = _provider.ApplicationServices.CreateScope().ServiceProvider.GetService <PokerDbContext>(); }
static void Main(string[] args) { /*var firstPlayerCards = new[] * { * new Card(CardRank.Ace, CardSuit.Diamond), * new Card(CardRank.Two, CardSuit.Diamond), * }; * var secondPlayerCards = new[] * { * new Card(CardRank.Ace, CardSuit.Diamond), * new Card(CardRank.Two, CardSuit.Diamond), * }; * var boardCards = new[] * { * new Card(CardRank.Two, CardSuit.Heart), * new Card(CardRank.Two, CardSuit.Club), * new Card(CardRank.Three, CardSuit.Diamond), * new Card(CardRank.Five, CardSuit.Diamond), * new Card(CardRank.Four, CardSuit.Diamond), * }; * * var allCards = firstPlayerCards.Union(boardCards).ToArray();*/ //var IsPair = CombinationFactory.IsPair(allCards); //var IsTwoPairs = CombinationFactory.IsTwoPairs(allCards); //var IsThreeOfAKind = CombinationFactory.IsThreeOfAKind(allCards); //var IsStraight = CombinationFactory.IsStraight(allCards); //var IsFlush = CombinationFactory.IsFlush(allCards); //var IsFullHouse = CombinationFactory.IsFullHouse(allCards); //var IsFourOfAKind = CombinationFactory.IsFourOfAKind(allCards); //var IsStraightFlush = CombinationFactory.IsStraightFlush(allCards); /* var two = @"(\d)?\1"; * var three = @"(\d)\1\1"; * var four = @"(\d)\1\1\1"; * * var flush = @"\bs*(\d)\b"; * * * //string three = @"(\d)\1\1"; * var pairRegularExp = new Regex(two); * * var t1 = Regex.Matches("113444", two); * var t2 = Regex.Matches("113444", two); * var t3 = Regex.Matches("113444", two); * var t4 = Regex.Matches("113444", two); * * var t5 = Regex.Matches("1122234444", three); * var t6 = Regex.Matches("112234444", three); * var t221 = Regex.Matches("112234444", three); * var t231 = Regex.Matches("112234444", three); * * var t341 = Regex.Matches("111233345", four); * var t351 = Regex.Matches("111233345", four); * var t361 = Regex.Matches("1112333345", four); * var t371 = Regex.Matches("11112333345", four); * * var t376 = Regex.Matches(" t0 s1 s2 s3 s4 s5 s6", flush);*/ /* var allFileLines = File.ReadAllLines(@"C:\Projects\PokerStatistic\StaticticExample.txt"); * * * var gamesParser = new GamesParser( * new GameBaseParser( * new GameInfoBaseParser(), * new PlayersBaseParser( * new PlayerBaseParser( * new MoneyBaseParser())), * new RoundsBaseParser( * new RoundParser( * new PlayerActionsBaseParser( * new PlayerActionBaseParser( * new MoneyBaseParser())), * new ActionsUpdater( * new ActionUpdater()), * new CardsBaseParser( * new CardBaseParser()))), * new PlayerBlindsBaseParser( * new PlayerPositionUpdater(), * new BlindsMoneyUpdater( * new BlindMoneyUpdater())), * new PlayerPositionUpdater())); * * var filePaths = Directory * .GetFiles(@"C:\Users\ilyaugov\Documents\888poker\HandHistory\Napaum"); * * filePaths = filePaths.Where(f => * !f.Contains("Sit & Go") && * !f.Contains("Tournament") && * !f.Contains("BLAST")).ToArray(); * * var games = new List<Game>(); * * Debug.WriteLine($"Total count: {filePaths.Length}"); * int i = 0; * * foreach (var filePath in filePaths) * { * allFileLines = File.ReadAllLines(filePath); * games.AddRange(gamesParser.Parse(allFileLines)); * * Debug.WriteLine($"completed: {++i}"); * } * */ /*var gamesFileStrings = filePaths.SelectMany(File.ReadAllLines).ToArray(); * var games = gamesParser.Parse(gamesFileStrings);*/ /* * * var dbContext = new PokerDbContext(); * * dbContext.Game.AddRange(games); * dbContext.SaveChanges();*/ var dbContext = new PokerDbContext(); var napaum = dbContext.Player .Include(p => p.Games) .Include(p => p.PlayerGameSnapshots) .ThenInclude(p => p.FinishedRounds) .Include(p => p.PlayerGameSnapshots) .ThenInclude(p => p.StartedRounds) .AsSplitQuery() .FirstOrDefault(p => p.NickName == "Napaum"); var statsCalculator = new PlayerStatisticsCalculator( new TotalGamesCalculator(), new TotalEnterFlopCalculator(), new TotalEnterTurnCalculator(), new TotalEnterRiverCalculator(), new TotalEnterShowDownCalculator(), new WinnedMoneyCalculator(), new WinnedBlindsCalculator()); var stats = statsCalculator.Calculate(napaum); }