public BTA(string name, string division) { Name = name; Division = division; Buyin = 200; Prize = 1000; IsOver = false; using (var context = new TourneyContext()) { Players = context.Players.Where(p => p.Division == division).Include(p => p.Histories).Include(p => p.Accomplishments).ToList(); } Players.Shuffle(); foreach (var player in Players) { player.Bankroll -= Buyin; } Brackets = new Bracket[8]; Brackets[0] = new Bracket($"Div {Division} - {Name} Round 1A", Players[0], Players[1], 4, 0); Brackets[1] = new Bracket($"Div {Division} - {Name} Round 1B", Players[2], Players[3], 4, 1); Brackets[2] = new Bracket($"Div {Division} - {Name} Round 1C", Players[4], Players[5], 5, 0); Brackets[3] = new Bracket($"Div {Division} - {Name} Round 1D", Players[6], Players[7], 5, 1); Brackets[4] = new Bracket($"Div {Division} - {Name} Semi-Final A", Brackets[0].Winner, Brackets[1].Winner, 6, 0); Brackets[5] = new Bracket($"Div {Division} - {Name} Semi-Final B", Brackets[2].Winner, Brackets[3].Winner, 6, 1); Brackets[6] = new Bracket($"Div {Division} - {Name} Final", Brackets[4].Winner, Brackets[5].Winner, 7, 0); Brackets[7] = new Bracket($"Div {Division} - {Name} Champion", Brackets[6].Winner, null, 0, 0); }
public PlayerScreen() { Console.Clear(); Console.WriteLine("Loading ..."); using (var context = new TourneyContext()) { Players = context.Players.ToList(); } }
public void Step() { if (_currentBracket >= 8) { return; } if (_currentBracket == 7) { // We done Brackets[_currentBracket].PlayerA.Accomplishments.Add(new Accomplishment { Name = Name + "Champ" }); Console.WriteLine("Saving Data..."); using (var context = new TourneyContext()) { foreach (var player in Players) { var p = context.Players.Find(player.Id); p = player; context.SaveChanges(); } } _currentBracket++; IsOver = true; return; } var curBrack = Brackets[_currentBracket]; if (_rng.Next(0, 100) % 2 == 0) // player A wins { curBrack.PlayerA.Wins++; curBrack.PlayerA.Histories.Add(new History(0, curBrack.Name, curBrack.PlayerB.Id, $"{curBrack.PlayerA.Name} def {curBrack.PlayerB.Name}")); curBrack.PlayerB.Loses++; curBrack.PlayerB.Histories.Add(new History(0, curBrack.Name, curBrack.PlayerA.Id, $"{curBrack.PlayerA.Name} def {curBrack.PlayerB.Name}")); curBrack.SetNextBracket(curBrack.PlayerA, Brackets[curBrack.NextBracket], curBrack.Spot); } else { curBrack.PlayerB.Wins++; curBrack.PlayerB.Histories.Add(new History(0, curBrack.Name, curBrack.PlayerA.Id, $"{curBrack.PlayerB.Name} def {curBrack.PlayerA.Name}")); curBrack.PlayerA.Loses++; curBrack.PlayerA.Histories.Add(new History(0, curBrack.Name, curBrack.PlayerB.Id, $"{curBrack.PlayerB.Name} def {curBrack.PlayerA.Name}")); curBrack.SetNextBracket(curBrack.PlayerB, Brackets[curBrack.NextBracket], curBrack.Spot); } _currentBracket++; }
public EventScreen() { Console.Clear(); Console.WriteLine("Loading ..."); using (var context = new TourneyContext()) { var nextEvent = context.Events.FirstOrDefault(e => e.Finished == false); if (nextEvent == null) { return; } switch (nextEvent.EventType) { case 0: Event = new BTA(nextEvent.Name, nextEvent.Division); break; } } }