示例#1
0
        public static void ComputePrizes(BingoGameEvent game_event, BingoGame game, List <wininfo> winners)
        {
            foreach (wininfo winner in winners)
            {
                foreach (BingoPrize prize in winner.prize_levels)
                {
                    int total = 0;
                    foreach (wininfo winner_with_prize in winners)
                    {
                        if (winner == winner_with_prize)
                        {
                            continue;
                        }
                        foreach (BingoPrize winner2_prize in winner.prize_levels)
                        {
                            if (winner2_prize.level.Equals(prize.level))
                            {
                                total++;
                                break;
                            }
                        }
                    }
                    long change;
                    long value = prize.amount / total;

                    if ((change = value % 100) > 0)
                    {
                        value += 100;
                        value -= change;
                    }
                    winner.amount += value;
                }
            }
        }
示例#2
0
 public BingoCardState(byte[, ,] CardData, BingoPlayer _Player, PlayerPack pack, int unit_card, int real_card, BingoGameEvent game)
 {
     this.card                = CardData;
     this.player              = _Player;
     this.pack                = pack;
     this.unit_card_number    = unit_card;
     this.cardset_card_number = real_card;
     this.game                = game;
 }
示例#3
0
 public static BingoGameEvent Continue(BingoGameEvent prior_event, BingoGame new_game)
 {
     if (prior_event != null)
     {
         //this.game_event_row = game_event_data_table_row;
         prior_event.games.Add(new_game);
     }
     return(prior_event);
 }
示例#4
0
        // double action determines whether card[X,,] goes from 0-0 or 0-1 (triple action? 0-2?)
        // check one card, get the best mask, and the best count_away
        // return the number of balls in ball array it won on.
        public static bool check_single_card(
            BingoCardState card
            , BingoGameEvent game_event
            , int game_index
            , int[] playing_balls
            , int faces
            , int columns
            , int pattern_index
            )
        {
            int mark_count = 0;

            if (card.pack.pack_info.flags.big3)
            {
                card.CheckBig3(card.marks[0]);
            }
            else
            {
                //foreach( BingoGame game in game_event.games )
                BingoGame game = game_event.games[game_index];
                {
                    foreach (Pattern pattern in game.patterns)
                    {
                        BingoCardState.BingoCardPatternMarkInfo marks = card.GetCurrentMark(pattern_index);
                        switch (pattern.algorithm)
                        {
                        case PatternDescriptionTable.match_types.ExternalJavaEngine:
                            break;

                        default:
                            if (card.MarkNew(marks, faces, columns, playing_balls))
                            {
                                mark_count++;
                            }
                            break;
                        }
                    }
                }
                if (mark_count == 0)
                {
                    return(false);
                }

                {
                    // get last marked cardmask
                    //foreach( BingoGame game in game_event.games )
                    {
                        if (game.patterns[0].algorithm == PatternDescriptionTable.match_types.CrazyMark)
                        {
                            return(card.CheckCrazy(card.marks[0], game.patterns[0].repeat_count));
                        }
                        else if (game.patterns[0].algorithm == PatternDescriptionTable.match_types.ExternalJavaEngine)
                        {
                            //return
                        }
                        else
                        {
                            List <int> patterns = game.pattern_list.pattern_bitmask_list;
                            //foreach ( int check_mask in patterns )
                            {
                                if (card.CheckPattern(card.marks[0], patterns))
                                {
                                    card.WinningGame      = game;
                                    card.WinningGameEvent = game_event;
                                    return(true);
                                }
                            } // end of foreach( pattern )
                        }
                    }
                }
            }
            return(false);
        }
示例#5
0
        // all cards in the session? the game lists should maintain this good enough?
        //public card_list playing_cards;



        /// <summary>
        /// This completes final initialization fo a bingo game state, including loading the cards for each player
        /// </summary>
        /// <param name="game_index">if game== null, index will be used to get the GameList entry at the index.</param>
        /// <param name="result">this is the partial state we're going to use...</param>
        /// <returns>result or NULL if fails</returns>
        public BingoGameState StepToUsing(int game_index, BingoGameState result, BallDataInterface bdi = null)
        {
            // setup a play state for an absolute game number...
            // get one game of all the ones defined in the bingo core state...

            lock (this.step_lock)
            {
                BingoGame game = null;
                result.game_needs_balls = false;

                // no games in state.
                if (session.GameList == null || session.GameList.Count == 0)
                {
                    // return an early result (no process)
                    return(result);
                }

                result.session_event = this;
                {
                    {
                        // if game is already set, no reason to use game_index
                        if (result.game == null)
                        {
                            if (game_index >= session.GameList.Count)
                            {
                                Log.log("StepTo passed a game number beyond the current list.");
                                return(result);
                                // need to do a step of session.
                                // setup some hotballs ....
                            }

                            // new session, played all players and all their cards
                            game = session.GameList[game_index];
                        }
                        else
                        {
                            game = result.game;
                        }
                        // should wait before running the NEXT game...
                        // for that game to finish...
                        while (game.playing)
                        {
                            Thread.SpinWait(1);
                        }

                        if (result.game == null)
                        {
                            // though at this point I should have result.session_event... and we should have
                            // been progressing through that...


                            // with events, I need to know the prior event ....
                            // but the threaded nature of this makes this impossible... since we are
                            // not really within a session container... it's really an observation of
                            // game by game...

                            if (prior_game_event != null && game.prior_game != null && game.into)
                            {
                                result.game_event       = BingoGameEvent.Continue(prior_game_event, game);
                                result.game_event_index = result.game_event.games.Count - 1;
                            }
                            else
                            {
                                result.game_event = new BingoGameEvent(game, bdi);
                                prior_game_event  = result.game_event;
                            }

                            string[] str = game.Name.Split('\t');
                            if (my_store_to_database)
                            {
                                game.ID = Local.bingo_tracking.OpenGame(game_index + 1, game.ballset_number, str[1]);                                   //game.Name );
                            }
                            if (game.number_colored > 0)
                            {
                                int[] newballs = new int[game.number_colored];
                                int   n;
                                for (n = 0; n < game.number_colored; n++)
                                {
                                    newballs[n] = -1 - n;
                                }
                                result.game_event.balls.AddExtraBalls(newballs);
                            }
                            if (game.cashballs == 5)
                            {
                                byte[] card = result.game_event.card_factory.Create5Card();
                                result.game_event.playing_hotballs = new int[card.Length];
                                for (int n = 0; n < card.Length; n++)
                                {
                                    result.game_event.playing_hotballs[n] = card[n];
                                }
                            }
                            else
                            {
                                result.game_event.playing_hotballs = result.game_event.balls.CallBalls(game.cashballs);
                            }
                        }
                    }
                }

                result.bestwin = session.max_balls;                // game.bestwin; // start at more than any level...

                // this is indexed with -1... soo [card, ball-1] == count away.
                result.winning_cards = new List <wininfo>();
                // this resultset is the whole sess's cards?
                result.playing_cards = new List <BingoCardState>();                 // playing_cards;
                result.playing_packs = new List <PlayerPack>();

                result.valid = true;

                result.session_event = this;

                List <object> game_pack_set_ids = new List <object>();
                if (opened)
                {
                    if (my_store_to_database)
                    //foreach( BingoGameGroup group in result.game.game_groups )
                    {
                        game_pack_set_ids.Add(result.game.game_group.group_pack_set_id = Local.bingo_tracking.AddPackSetToGame(result.game.game_group.pack_set_id));
                    }
                }
                else
                {
                    game_pack_set_ids.Add(Guid.Empty);
                }

                /*
                 * if( _PlayerList != null )
                 * {
                 *      foreach( BingoPlayer player in _PlayerList )
                 *      {
                 *              LoadPlayerCards( player, game_pack_set_ids, result );
                 *      }
                 * }
                 */
                // return this state so we can unlock it.
                // with these balls and cards referenced
                // we should not have a problem with multi-threading this.
                return(result);
            }
        }