示例#1
0
        public BingoPlayers(BingoSessionEvent session, PackDNA rated_packs)
        {
            session_event = session;
            LoadPlayers();

            Log.log("Begin loading players...");

            string misc_item = Options.File("raterank.ini")[Options.ProgramName]["Misc Item To Select Sale", "none"].Value;
            string misc_dept = Options.File("raterank.ini")[Options.ProgramName]["Misc Dept To Select Sale", "none"].Value;

            //MySQLDataTable table;
            if (misc_dept != "none")
            {
                LoadMisc(session, misc_dept, misc_item);
                // lock more players from getting loaded.
                players_loaded = true;
            }
            allow_any_player = true;

            //LoadElectronics( bingoday, session, games.pack_list, rated_packs );

            LoadElectronics(session, session_event.session.GameList.pack_list);
            LoadPaper(session, session_event.session.GameList.pack_list, null);
            Log.log("Done loading players...");
        }
示例#2
0
        void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list, PackDNA rated_packs)
        {
            string         misc_item = Options.Default["Rate Rank"]["Misc Item To Select Sale", "none"].Value;
            string         misc_dept = Options.Default["Rate Rank"]["Misc Dept To Select Sale", "none"].Value;
            MySQLDataTable table;

            if (misc_dept != "none")
            {
                MySQLDataTable specials = new MySQLDataTable(StaticDsnConnection.dsn
                                                             , "select transnum,sum(quantity) as count from misc_trans join misc_item using(item_id) join misc_dept using(dept_id)"
                                                             + " where misc_item.name='" + misc_item + "' and misc_dept.name='" + misc_dept + "'"
                                                             + " and misc_trans.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date)"
                                                             + " and misc_trans.session=" + session
                                                             + " and misc_trans.void=0"
                                                             + " group by transnum"
                                                             );
                table = new MySQLDataTable(StaticDsnConnection.dsn
                                           , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num from access_db_sale"
                                           + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                           + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session
                                           + " and matched=0"
                                           + " order by transnum,access_db_packs.id"
                                           );

                foreach (DataRow row in specials.Rows)
                {
                    int transnum = Convert.ToInt32(row["transnum"]);
                    PlayerTransaction transaction = null;
                    BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);
                    int count = Convert.ToInt32(row["count"]) + player.pack_sets.Count;
                    for (int n = player.pack_sets.Count; n < count; n++)
                    {
                        PackSet tmp;
                        player.pack_sets.Add(tmp = new PackSet());
                        tmp.set_id = n + 1;
                    }
                }
            }
            else
            {
                table = new MySQLDataTable(StaticDsnConnection.dsn
                                           , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num,pos_num from access_db_sale"
                                           + " join access_db_packs on access_db_sale.electronic_id=access_db_packs.electronic_id"
                                           + " where void=0 and access_db_sale.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and access_db_packs.session=" + session
                                           + " and matched=0"
                                           + " order by transnum,access_db_packs.id"
                                           );
            }

            foreach (DataRow row in table.Rows)
            {
                int transnum = Convert.ToInt32(row["transnum"]);

                PlayerTransaction transaction = null;
                BingoPlayer       player      = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction);

                //Log.log( "Player : " + player.card );
                int packnum = Convert.ToInt32(row["pack_type"]);

                // ignore the macro pack labels.
                if (packnum < 100)
                {
                    PlayerPack pack = new PlayerPack();

                    transaction.Add(pack);
                    pack.start_card = Convert.ToInt32(row["start_card"]);
                    pack.pack_info  = pack_list.GetPack(row["pack_type_name"].ToString(), "Pos " + row["pos_num"].ToString());
                    if (pack.pack_info == null)
                    {
                        continue;                          // fail loading this.
                    }
                    //pack.game_list = _games;
                    pack.player      = player;
                    pack.unit_number = Convert.ToInt32(row["unit_num"]);

                    if (rated_packs != null)
                    {
                        bool   found    = false;
                        string packname = row["pack_type_name"].ToString();
                        //Log.log( "Looking for pack to stack: " + packname );
                        foreach (PackSet check_pack_set in player.pack_sets)
                        {
                            if (check_pack_set.Count == rated_packs.pack_sequence.Count)
                            {
                                bool empty_slot = false;
                                int  tmp_pos    = 0;
                                foreach (BingoPack seq_pack in rated_packs.pack_sequence)
                                {
                                    if (check_pack_set.Count > tmp_pos && check_pack_set[tmp_pos] == null)
                                    {
                                        empty_slot = true;
                                        break;
                                    }
                                    tmp_pos++;
                                }
                                if (!empty_slot)
                                {
                                    // this pack set is already full.
                                    //Log.log( "(all manager packs already loaded)stack is full... skipping..." );
                                    continue;
                                }
                            }
                            int pos = 0;
                            foreach (BingoPack seq_pack in rated_packs.pack_sequence)
                            {
                                if (check_pack_set.Count > pos && check_pack_set[pos] != null)
                                {
                                    //Log.log( "slot is full... skipping..." );
                                    pos++;
                                    continue;
                                }
                                //Log.log( "Comparing " + seq_pack.name +" vs " + packname );
                                if (((check_pack_set.Count <= pos) ||
                                     (check_pack_set.Count > pos && check_pack_set[pos] == null)) &&
                                    String.Compare(packname, seq_pack.name, true) == 0)
                                {
                                    //Log.log( "Steppig match_pos... setting id " + check_pack_set.set_id );
                                    check_pack_set.match_pos++;
                                    pack.pack_set = check_pack_set.set_id;
                                    check_pack_set.Set(pos, pack.pack_info);
                                    found = true;
                                    break;
                                }
                                pos++;
                            }
                            if (found)
                            {
                                //Log.log( "located..." );
                                break;
                            }
                        }
                        if (!found)
                        {
                            //if( player.card == "000000015200000761" )
                            //	Log.log( "something bad." );
                        }
                    }
                    Log.log("electronic pack starting card " + pack.start_card);

                    player.played_packs.Add(pack);
                }
            }
            //if( match_pos > 0 )
            foreach (BingoPlayer player in this)
            {
                foreach (PackSet check_pack_set in player.pack_sets)
                {
                    if (check_pack_set.Count == rated_packs.pack_sequence.Count)
                    {
                    }
                    else
                    {
                        Log.log("Incomplete pack sequence?");
                    }
                }
            }
        }