Exemplo n.º 1
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        internal PlayingManager(Announcement current, BelotGame game, CardsCollection _allCards)
        {
            _game                = game;
            _playedHands         = new List <Hand>();
            _cardToPlayerMap     = new Dictionary <Card, Player>();
            _currentAnnouncement = current;
            _currentHand         = new Hand();
            _isHandClosed        = false;
            _cardComparer        = new CardComparer(current.Type);

            _playedCards    = new CardsCollection();
            _remainingCards = new CardsCollection();

            foreach (Card card in _allCards)
            {
                _remainingCards.Add(card);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        internal PlayingManager( Announcement current, BelotGame game, CardsCollection _allCards )
        {
            _game = game;
            _playedHands = new List< Hand >();
            _cardToPlayerMap = new Dictionary<Card, Player>();
            _currentAnnouncement = current;
            _currentHand = new Hand();
            _isHandClosed = false;
            _cardComparer = new CardComparer( current.Type );

            _playedCards = new CardsCollection();
            _remainingCards = new CardsCollection();

            foreach( Card card in _allCards )
            {
                _remainingCards.Add( card );
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor for the class. Creates a new deal during the current game.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="firstPlayer"></param>
        internal Deal(BelotGame game, Player firstPlayer)
        {
            this._game        = game;
            this._firstPlayer = firstPlayer;

            _mapEqualCombinationToPlayer      = new ListDictionary();
            _mapSequentialCombinationToPlayer = new ListDictionary();
            _mapBelotCombinationToPlayer      = new ListDictionary();

            _allCards = InitCards();
            _cards    = new CardsCollection();

            foreach (Card card in _allCards)
            {
                _cards.Add(card);
            }

            _currentAnnouncement = new Announcement(AnnouncementTypeEnum.Pass, false, false);

            _game.RaiseDealStarted();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for the class. Creates a new deal during the current game.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="firstPlayer"></param>
        internal Deal( BelotGame game, Player firstPlayer )
        {
            this._game = game;
            this._firstPlayer = firstPlayer;

            _mapEqualCombinationToPlayer = new ListDictionary();
            _mapSequentialCombinationToPlayer = new ListDictionary();
            _mapBelotCombinationToPlayer = new ListDictionary();

            _allCards = InitCards();
            _cards = new CardsCollection();

            foreach( Card card in _allCards )
            {
                _cards.Add( card );
            }

            _currentAnnouncement = new Announcement( AnnouncementTypeEnum.Pass, false, false );

            _game.RaiseDealStarted();
        }
Exemplo n.º 5
0
        private void MenuNew_Click( object sender, EventArgs e )
        {
            this.Text = "";

            HumanPlayer pl1 = new HumanPlayer( Properties.Settings.Default.SouthName );
            ComputerPlayer pl2 = CreatePlayer( Properties.Settings.Default.NorthDll, Properties.Settings.Default.NorthName );
            ComputerPlayer pl3 = CreatePlayer( Properties.Settings.Default.EastDll, Properties.Settings.Default.EastName );
            ComputerPlayer pl4 = CreatePlayer( Properties.Settings.Default.WestDll, Properties.Settings.Default.WestName );

            if ( pl2 == null || pl3 == null || pl4 == null )
            {
                MessageBox.Show( "Player not properly configured. See 'Settings->Players' for details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            pl1.AnnounceMaking += new HumanPlayer.AnnounceMakingHandler( HumanPlayerIsBidding );
            pl2.AnnounceMade += new ComputerPlayer.AnnounceMadeHandler( CompPlayerBidded );
            pl3.AnnounceMade += new ComputerPlayer.AnnounceMadeHandler( CompPlayerBidded );
            pl4.AnnounceMade += new ComputerPlayer.AnnounceMadeHandler( CompPlayerBidded );

            pl1.CardPlaying += new Player.CardPlayingHandler( HumanPlayerIsPlaying );
            pl2.CardPlayed += new Player.CardPlayedHandler( ComputerPlayerPlayed );
            pl3.CardPlayed += new Player.CardPlayedHandler( ComputerPlayerPlayed );
            pl4.CardPlayed += new Player.CardPlayedHandler( ComputerPlayerPlayed );

            pl1.CardsChanged += new Player.PlayerCardsChangedHandler( DrawCards );
            pl2.CardsChanged += new Player.PlayerCardsChangedHandler( DrawCards );
            pl3.CardsChanged += new Player.PlayerCardsChangedHandler( DrawCards );
            pl4.CardsChanged += new Player.PlayerCardsChangedHandler( DrawCards );

            pl1.CardCombinationAnnouncing += new HumanPlayer.CardCombinationAnnouncingHandler( HumanCardCombinationAnnouncing );
            pl2.CardCombinationAnnounced += new ComputerPlayer.CardCombinationAnnouncedHandler( CombinationAnnounced );
            pl3.CardCombinationAnnounced += new ComputerPlayer.CardCombinationAnnouncedHandler( CombinationAnnounced );
            pl4.CardCombinationAnnounced += new ComputerPlayer.CardCombinationAnnouncedHandler( CombinationAnnounced );

            this._game = new BelotGame( pl1, pl3, pl2, pl4 );
            this._game.BiddingCompleted += new BelotGame.BiddingCompletedHandler( BiddingCompleted );
            this._game.DealStarted += new BelotGame.DealEventHandler( DealStarted );
            this._game.DealCompleted += new BelotGame.DealEventHandler( DealCompleted );
            this._game.HandClosed += new BelotGame.HandClosedHandler( HandClosed );
            this._game.GameCompleted += new BelotGame.GameCompletedHandler( GameOver );

            this._game.CapotRemovesDouble = Properties.Settings.Default.CapotRemovesDouble;
            this._game.ExtraPointsAreDoubled = Properties.Settings.Default.ExtraPointsAreDoubled;

            this._game.StartGame();
        }