void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list, List <String> rated_packs) { MySQLDataTable 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 transnum" /*by mod(start_card,50),start_card/50"*/ ); foreach (DataRow row in table.Rows) { if (rated_packs != null) { bool found = false; string packname = row["pack_type_name"].ToString(); foreach (String rated_packname in rated_packs) { if (String.Compare(packname, rated_packname, true) == 0) { found = true; break; } } // ignore loading this pack. it's not allowed. if (!found) { continue; } } int transnum = Convert.ToInt32(row["transnum"]); PlayerTransaction transaction = null; BingoPlayer player = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction); int packnum = Convert.ToInt32(row["pack_type"]); if (packnum < 100) { PlayerPack pack = new PlayerPack(); pack.electronic = true; 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.paper = false; //pack.game_list = _games; pack.player = player; pack.unit_number = Convert.ToInt32(row["unit_num"]); #if each_pack_has_counts foreach (BingoGame game in _games) { int x; // pack doesn't play in this game. if (pack.pack_info.ID >= game.pack_card_counts.Count) { pack.game_card_count[game.game_ID] = 0; continue; } x = pack.game_card_count[game.game_ID] = game.pack_card_counts[pack.pack_info.ID - 1]; if (x > pack.most_game_card_count) { if (pack.least_game_card_count == 0) { pack.least_game_card_count = x; } pack.most_game_card_count = x; } if (x > 0 && x < pack.least_game_card_count) { pack.least_game_card_count = x; } } #endif //pack.pack_info.ID = player.played_packs.Count; player.played_packs.Add(pack); } } }
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?"); } } } }
void LoadElectronics(BingoSessionEvent session, BingoPacks pack_list) { MySQLDataTable table = new MySQLDataTable(StaticDsnConnection.dsn , "select access_db_sale.transnum,pack_type,start_card,pack_type_name,unit_num,access_db_sale.bingoday 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.session_number + " order by mod(start_card,50),start_card/50" ); foreach (DataRow row in table.Rows) { int start_card = Convert.ToInt32(row["start_card"]); if (start_card == 0) { // these are special case macro label place holders... no real cards. continue; } int transnum = Convert.ToInt32(row["transnum"]); PlayerTransaction transaction = null; BingoPlayer player = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction); if (player != null) { int packnum = Convert.ToInt32(row["pack_type"]); if (packnum < 100) { PlayerPack pack = new PlayerPack(); pack.electronic = true; pack.start_card = start_card; pack.transaction = transaction; try { pack.pack_info = pack_list.GetPack(row["pack_type_name"].ToString()); pack.dealer = pack.pack_info.GetRangeDealer(start_card); } catch (Exception e) { //System.Windows.Forms.MessageBox.Show( e.Message ); throw new Exception("Fail loading packs."); continue; } if (pack.pack_info == null) { continue; // fail loading this. } pack.paper = false; //pack.game_list = _games; pack.player = player; pack.unit_number = Convert.ToInt32(row["unit_num"]); #if each_pack_has_counts foreach (BingoGame game in _games) { int x; // pack doesn't play in this game. if (pack.pack_info.ID >= game.pack_card_counts.Count) { pack.game_card_count[game.game_ID] = 0; continue; } x = pack.game_card_count[game.game_ID] = game.pack_card_counts[pack.pack_info.ID - 1]; if (x > pack.most_game_card_count) { if (pack.least_game_card_count == 0) { pack.least_game_card_count = x; } pack.most_game_card_count = x; } if (x > 0 && x < pack.least_game_card_count) { pack.least_game_card_count = x; } } #endif if (bDoLogCards) { Log.log("electronic pack starting card " + pack.start_card); } //pack.pack_info.ID = player.played_packs.Count; transaction.Add(pack); player.played_packs.Add(pack); } else { // ignore macros } } } table.Dispose(); }
void LoadPaper(BingoSessionEvent session, BingoPacks pack_list, List <String> rated_packs) { MySQLDataTable paper_table = new MySQLDataTable(StaticDsnConnection.dsn , "select * from pos_paper_barcode_master" + " join pos_paper_barcode_item on pos_paper_barcode_master.pos_paper_barcode_master_id=pos_paper_barcode_item.pos_paper_barcode_master_id" + " join item_descriptions on item_descriptions.item_description_id=pos_paper_barcode_item.item_description_id" + " join floor_paper_names on floor_paper_names.floor_paper_name_id=pos_paper_barcode_item.floor_paper_name_id" + " where pos_paper_barcode_master.bingoday=cast( " + DsnSQLUtil.MakeDate(StaticDsnConnection.dsn, session.bingoday) + " as date) and pos_paper_barcode_master.session=" + session.session.session + " order by transnum" //start_card" ); foreach (DataRow row in paper_table.Rows) { string packname = row["name"].ToString(); if (rated_packs != null) { bool found = false; foreach (String rated_packname in rated_packs) { if (String.Compare(packname, rated_packname, true) == 0) { found = true; break; } } // ignore loading this pack. it's not allowed. if (!found) { continue; } } int transnum = Convert.ToInt32(row["transnum"]); if (transnum == 0) { // these are special case packs (paper usage tracking only) continue; } PlayerTransaction transaction = null; BingoPlayer player = GetPlayer(Convert.ToDateTime(row["bingoday"]), transnum, ref transaction); if (player != null) { PlayerPack pack = new PlayerPack(); pack.electronic = false; pack.transaction = transaction; pack.start_card = Convert.ToInt32(row["start_card"]); pack.pack_info = pack_list.GetPack(packname); if (pack.pack_info != null) { //pack.pack_info.game_list = _games; pack.player = player; pack.unit_number = Convert.ToInt32(row["packnum"]); pack.dealer = pack_list.GetDealer(pack.pack_info, pack.start_card); pack.paper = true; pack.pack_info.ID = player.played_packs.Count; { // fix the starting card.... // need to figure this out ( sam's town ) if (bDoLogCards) { Log.log("paper pack starting card " + pack.start_card); } pack.unit_number = Convert.ToInt32(row["packnum"]); player.played_packs.Add(pack); } transaction.Add(pack); } } } paper_table.Dispose(); }
BingoPlayer GetPlayer(DateTime bingoday, int transnum, ref PlayerTransaction transaction) { BingoPlayer player = this.Find(delegate(BingoPlayer p) { foreach (PlayerTransaction t in p.transactions) { if (t.transnum == transnum) { return(true); } } return(false); }); if (!players_loaded && player == null) { DbDataReader r = StaticDsnConnection.KindExecuteReader("select card,id from player_track where transnum=" + transnum.ToString() + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, bingoday)); if (r != null && r.HasRows) { r.Read(); String player_card = r.GetString(0); int ID = r.GetInt32(1); if (max_player_id < ID) { max_player_id = ID; } StaticDsnConnection.EndReader(r); player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); }); if (player != null) { player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); } if (player == null) { player = new BingoPlayer(); player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); player.card = player_card; player.ID = Guid.NewGuid(); // this.Count; Add(player); } } else { if (allow_any_player) { String player_card = transnum.ToString(); player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); }); if (player != null) { player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); } if (player == null) { player = new BingoPlayer(); player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); player.card = player_card; player.ID = Guid.NewGuid(); //this.Count; Add(player); } } } } else { foreach (PlayerTransaction t in player.transactions) { if (t.transnum == transnum) { transaction = t; } } } return(player); }
public List <PlayerTransaction> LoadPlayers() { List <PlayerTransaction> new_players = null; if (this.Count == 0) { PlayerTransaction transaction; DbDataReader r = StaticDsnConnection.KindExecuteReader("select card,transnum,ID from player_track where session=" + session_event.session_number + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, session_event.bingoday)); max_player_id = 0; if (r != null && r.HasRows) { String player_card = r.GetString(0); int transnum = r.GetInt32(1); int player_id = r.GetInt32(2); if (player_id > max_player_id) { max_player_id = player_id; } BingoPlayer player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); }); if (player != null) { transaction = player.transactions.Find(delegate(PlayerTransaction p) { return(p.transnum == transnum); }); if (transaction == null) { player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); } // new transaction on player.... if (new_players == null) { new_players = new List <PlayerTransaction>(); } new_players.Add(transaction); } else { player = new BingoPlayer(); player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); player.card = player_card; player.ID = Guid.NewGuid(); Add(player); if (new_players == null) { new_players = new List <PlayerTransaction>(); } new_players.Add(transaction); } } } else { PlayerTransaction transaction; DbDataReader r = StaticDsnConnection.KindExecuteReader("select card,transnum,ID from player_track where session=" + session_event.session_number + " and bingoday=" + DsnSQLUtil.MakeDateOnly(StaticDsnConnection.dsn, session_event.bingoday) + " and ID>" + max_player_id); if (r != null && r.HasRows) { String player_card = r.GetString(0); int transnum = r.GetInt32(1); int player_id = r.GetInt32(2); if (player_id > max_player_id) { max_player_id = player_id; } BingoPlayer player = this.Find(delegate(BingoPlayer p) { return(String.Compare(p.card, player_card) == 0); }); if (player != null) { transaction = player.transactions.Find(delegate(PlayerTransaction p) { return(p.transnum == transnum); }); if (transaction == null) { player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); } // new transaction on player.... if (new_players == null) { new_players = new List <PlayerTransaction>(); } new_players.Add(transaction); } else { player = new BingoPlayer(); player.transactions.Add(transaction = new PlayerTransaction(player, transnum)); player.card = player_card; player.ID = Guid.NewGuid(); Add(player); if (new_players == null) { new_players = new List <PlayerTransaction>(); } new_players.Add(transaction); } } } return(new_players); }
/// <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; } }