Example #1
0
        void DoPlay()
        {
            BingoGameState s;

            while (true)
            {
                s = this.Step();
                BingoGameEvents.Add(s);
                if (s.valid)
                {
                    session.UpdateStatus("Checking game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                    if (StateWriter.CheckState(ref s))
                    {
                        session.UpdateStatus("Playing game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                        //status.Refresh();
                        BingoMatchEngine.Play(s);
                    }
                    else
                    {
                        //MessageBox.Show( "Game:" + s.game.game_number + " in Session:" + ( GameList.session ) + " on " + GameList.bingoday + " has already been rated...\nIgnoring" );
                    }
                }
                else
                {
                    break;
                }
            }
            if (s.game != null)
            {
                session.UpdateStatus("Game completed " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
            }
            //status.Refresh();
        }
Example #2
0
 //static int play_lock;
 /// <summary>
 /// Plays a single bingo event.
 /// </summary>
 /// <param name="State">the state to play - should have used a 'Step' function to get this</param>
 public void PlayGame(BingoGameState State)
 {
     BingoMatchEngine.Play(State);
     if (opened)
     {
         BingoPrize.ComputePrizes(State.game_event, State.game, State.winning_cards);
         foreach (wininfo win in State.winning_cards)
         {
             Local.bingo_tracking.AddWinner(win.playing_card.ID, win.mask, win.amount);
         }
     }
 }
Example #3
0
        public void DoPlayState(object param)
        {
            BingoGameState s = param as BingoGameState;

            if (s.valid)
            {
                session.UpdateStatus("Playing game " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
                BingoMatchEngine.Play(s);
                session.UpdateStatus("Game completed " + s.game.game_number + "(" + s.game.game_ID + ")" + " in session " + session_number + " on " + bingoday.Date + "...");
            }
            else
            {
                session.UpdateStatus("Invalid state. Ignoring.");
            }
        }
Example #4
0
        /// <summary>
        /// This literally loads the packs each player is playing into the bingo game state
        /// </summary>
        /// <param name="_Player"></param>
        /// <param name="s"></param>
        void LoadPlayerCards(PlayerTransaction transaction, List <object> game_pack_set_ids, BingoGameState s)
        {
            bool           pack_pattern      = BingoMatchEngine.IsPackPattern(s);
            int            pack_pattern_size = BingoMatchEngine.GetPackCardGroupSize(s);
            int            pack_number       = 0;
            BingoGameGroup game_group        = s.game.game_group;
            BingoPlayer    _Player           = transaction.player;

            while (_Player._played_cards.Count <= game_group.game_group_ID)
            {
                _Player._played_cards.Add(new List <BingoCardState>());
            }

            List <BingoCardState> player_card_list = _Player._played_cards[game_group.game_group_ID];

            // already loaded these cards?
            while (game_group.game_group_ID >= transaction.loaded.Count)
            {
                transaction.loaded.Add(false);
            }
            if (transaction.loaded[game_group.game_group_ID])
            {
                foreach (BingoCardState card in _Player._played_cards[game_group.game_group_ID])
                {
                    s.playing_cards.Add(card.Clone());
                }
                return;
            }
            //player_card_list.Clear();


            //foreach( PlayerTransaction trans in _Player.transactions )
            {
                foreach (PlayerPack _pack in transaction)
                {
                    bool skip_pack = true;
                    if (_pack.pack_info.game_groups.Count > 0)
                    {
                        foreach (BingoGameGroup group in _pack.pack_info.game_groups)
                        {
                            if (group.Contains(s.game))
                            {
                                // this pack is in this game, load cards for it.
                                game_group = group;
                                skip_pack  = false;
                                break;
                            }
                        }
                        if (skip_pack)
                        {
                            continue;
                        }
                    }
                    while (_pack.Cards.Count <= game_group.game_group_ID)
                    {
                        _pack.Cards.Add(new List <BingoCardState>());
                    }

                    pack_number++;

                    _pack.played = true;

                    int card_count = _pack.pack_info.count;                    // s.game.GetCardCount( _pack.pack_info );
                    if (_pack.pack_info.count == 0)
                    {
                        // pack does not play this game, skip it.
                        continue;
                    }

                    s.playing_packs.Add(_pack);

                    List <BingoCardState> game_cards = _pack.Cards[game_group.game_group_ID];

                    if (game_cards.Count < card_count)
                    {
                        if (_pack.dealer == null)
                        {
                            if (_pack.pack_info.dealers.Count == 1)
                            {
                                _pack.dealer = _pack.pack_info.dealers[0];
                            }
                            else
                            {
                                Log.log("Fatality, dealer not assigned on pack.");
                                continue;
                            }
                        }

                        int base_real_card = _pack.dealer.Add((_pack.start_card),
                                                              !_pack.paper
                                                                ? s.game.ballset_number
                                                                : s.game.page_skip);

                        //if( base_real_card > 320000 )
                        {
                            //	MessageBox.Show( "Card is out of range!" );
                        }


                        int col = 0;
                        int row = 0;
                        for (int card = 0; card < card_count; card++)
                        {
                            byte[, ,] card_faces;
                            row++;
                            if (row >= _pack.pack_info.rows)
                            {
                                col++;
                                row = 0;
                            }
                            //if( col == _pack.pack_info.
                            // dealer does a subtract 1, this is a 0 based physical card index.
                            int unit_card = _pack.dealer.GetNext(base_real_card, row, col, card);
                            int real_card = _pack.dealer.GetPhysicalNext(base_real_card, row, col, card);

                            if (_pack.dealer.card_data == null)
                            {
                                card_faces = new byte[1, 5, 5] {
                                    { { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 } }
                                };
                            }
                            else
                            {
                                card_faces = _pack.dealer.card_data.Create(
                                    real_card
                                    , _pack.pack_info.flags.double_action ? 2 : 1
                                    , _pack.pack_info.flags.starburst
                                    );
                            }


                            BingoCardState cs = new BingoCardState(card_faces
                                                                   , _Player, _pack, unit_card, real_card
                                                                   , s.game_event);
                            //cs.player = _Player;
                            //cs.pack = _pack;
                            //cs.unit_card_number = unit_card;
                            //cs.cardset_card_number = real_card;
                            //cs.game = s.game_event;

                            // this is actually PlayerPack.Cards.Add()...
                            game_cards.Add(cs);
                            cs.pack_card_index = game_cards.IndexOf(cs);

                            player_card_list.Add(cs);
                            s.playing_cards.Add(cs);

                            if (s.session_event.opened)
                            {
                                cs.ID = Local.bingo_tracking.AddCard(game_group.group_pack_set_id, _pack.ID, s.game.ballset_number, cs.unit_card_number, cs.CardData);
                            }
                        }
                    }
                    else
                    {
                        for (int card = 0; card < card_count; card++)
                        {
                            BingoCardState cs = _pack.Cards[game_group.game_group_ID][card];
                            s.playing_cards.Add(cs);
                            player_card_list.Add(cs);
                            if (s.session_event.opened)
                            {
                                cs.ID = Local.bingo_tracking.AddCard(null, _pack.ID, s.game.ballset_number, cs.unit_card_number, cs.CardData);
                            }
                        }
                    }
                }
                transaction.loaded[game_group.game_group_ID] = true;
            }
        }