Ejemplo n.º 1
0
        public SkatTable(string player1, string player2, string player3, string player4 = null)
        {
            if (player4 != null)
            {
                Players.Add(new Player(player1, PlayerPosition.Forehand));
                Players.Add(new Player(player2, PlayerPosition.Middlehand));
                Players.Add(new Player(player3, PlayerPosition.Rearhand));
                InactivePlayer = new Player(player4, PlayerPosition.Inactive);
                TablePlayers.Add(InactivePlayer);
                TablePlayers.AddRange(Players);
            }
            else
            {
                Players.Add(new Player(player1, PlayerPosition.Rearhand));
                Players.Add(new Player(player2, PlayerPosition.Forehand));
                Players.Add(new Player(player3, PlayerPosition.Middlehand));
                TablePlayers.AddRange(Players);
            }
            SkatResult     = new SkatResult();
            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);
            var s = new HashSet <int>();

            // farbe
            for (int m = 2; m < 18; m++) // mit 10 spielt 11 hand 12 schneider 13 angesagt 14 schwarz 15 angesagt 16 ouvert 17
            {
                s.Add(m * 9);
                s.Add(m * 10);
                s.Add(m * 11);
                s.Add(m * 12);
            }
            // grand
            for (int m = 2; m < 12; m++) // mit 4 spielt 5 hand 6 schneider 7 angesagt 8 schwarz 9 angesagt 10 overt 11
            {
                s.Add(m * 24);
            }
            // null
            s.Add(23);
            // null hand
            s.Add(35);
            // null ouvert
            s.Add(46);
            // null ouvert hand
            s.Add(59);
            BidValues = s.ToList <int>();
            BidValues.Sort();
        }
Ejemplo n.º 2
0
        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;
        }