public void CollectStitch(Player player) { LastStitch.Clear(); LastStitch.AddRange(Stitch); Stitch.Clear(); if (CurrentPlayer == player && GamePlayer == player && player.Game.Type == GameType.Null && player.Stitches.Any()) { foreach (var p in Players) { p.Cards.Clear(); } } if (player.Cards.Count == 0) { var game = GamePlayer.Game; GameValue = game.GetGameValue(MatadorsJackStraight, GamePlayer.Stitches, Skat, CurrentBidValue, false); GamePlayer.Score += GameValue.Score; CurrentHistory.GamePlayerScore = GetScore(GamePlayer); CurrentHistory.GameValue = GameValue.Score; SkatResult.History.Add(CurrentHistory); SkatResult.EndedUtc = DateTime.UtcNow; } }
public void StartNewRound() { GameCounter += 1; foreach (var p in Players) { p.Stitches.Clear(); p.Cards.Clear(); p.Game = new Game(GameType.Grand); switch (p.Position) { case PlayerPosition.Middlehand: p.Position = PlayerPosition.Forehand; p.BidStatus = BidStatus.Accept; break; case PlayerPosition.Rearhand: p.Position = PlayerPosition.Middlehand; p.BidStatus = BidStatus.Bid; break; case PlayerPosition.Forehand: p.Position = PlayerPosition.Rearhand; p.BidStatus = BidStatus.Wait; break; default: break; } } MatadorsJackStraight = null; GameStarted = false; GamePlayer = null; GameValue = null; SkatTaken = false; CurrentPlayer = null; Stitch.Clear(); Skat.Clear(); LastStitch.Clear(); using (var rng = new RNGCryptoServiceProvider()) { var deck = Card.GenerateDeck(); foreach (var player in Players) { player.Cards.AddRange(Card.Draw(rng, deck, 10)); } Skat.AddRange(Card.Draw(rng, deck, 2)); } BidSaid = false; BidValueIndex = -1; BidExceeded = false; }
public void CollectStitch(Player player) { LastStitch.Clear(); LastStitch.AddRange(Stitch); Stitch.Clear(); if (CurrentPlayer == player && GamePlayer == player && player.Game.Type == GameType.Null && player.Stitches.Any()) { foreach (var p in Players) { p.Cards.Clear(); } } if (player.Cards.Count == 0) { var game = GamePlayer.Game; GameValue = game.GetGameValue(MatadorsJackStraight, GamePlayer.Stitches, Skat, CurrentBidValue, false); GamePlayer.Score += GameValue.Score; } }
public void StartNewRound() { GameCounter += 1; if (InactivePlayer == null) { foreach (var p in Players) { p.Stitches.Clear(); p.Cards.Clear(); p.Game = new Game(GameType.Grand); switch (p.Position) { case PlayerPosition.Middlehand: p.Position = PlayerPosition.Forehand; p.BidStatus = BidStatus.Accept; break; case PlayerPosition.Rearhand: p.Position = PlayerPosition.Middlehand; p.BidStatus = BidStatus.Bid; break; case PlayerPosition.Forehand: p.Position = PlayerPosition.Rearhand; p.BidStatus = BidStatus.Wait; break; default: break; } } } else { var nextPlayers = new Player[3]; var newPlayer = InactivePlayer; newPlayer.Position = PlayerPosition.Rearhand; newPlayer.BidStatus = BidStatus.Wait; newPlayer.Stitches.Clear(); newPlayer.Cards.Clear(); newPlayer.Game = new Game(GameType.Grand); nextPlayers[2] = newPlayer; foreach (var p in Players) { p.Stitches.Clear(); p.Cards.Clear(); p.Game = new Game(GameType.Grand); if (p.Position == PlayerPosition.Forehand) { InactivePlayer = p; p.Position = PlayerPosition.Inactive; p.BidStatus = BidStatus.Wait; } else if (p.Position == PlayerPosition.Middlehand) { p.Position = PlayerPosition.Forehand; p.BidStatus = BidStatus.Accept; nextPlayers[0] = p; } else if (p.Position == PlayerPosition.Rearhand) { p.Position = PlayerPosition.Middlehand; p.BidStatus = BidStatus.Bid; nextPlayers[1] = p; } } Players.Clear(); Players.AddRange(nextPlayers); } MatadorsJackStraight = null; GameStarted = false; GamePlayer = null; GameValue = null; IsSpeedUp = false; SkatTaken = false; CurrentPlayer = null; Stitch.Clear(); Skat.Clear(); LastStitch.Clear(); CurrentHistory = new GameHistory(); var deck = Card.GenerateDeck(); foreach (var player in Players) { player.Cards.AddRange(Card.Draw(deck, 10)); player.SortCards(); CurrentHistory.PlayerCards.Add((player.Name, new List <Card>(player.Cards))); } Skat.AddRange(Card.Draw(deck, 2)); CurrentHistory.Skat.AddRange(Skat); BidSaid = false; BidValueIndex = -1; }