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; }
public wininfo(int card_id, int card_number, int mask, BingoPlayer player, PlayerPack pack, byte[, ,] playing_card, int ball_count) { this.ball_win_count = ball_count; //this.playing_card = playing_card; this.card_number = card_number; this.card_index = card_id; this.mask = mask; this.player = player; this.pack = pack; }
public wininfo(int card_id, BingoCardState card) { this.ball_win_count = card.BallCount; this.playing_card = card; this.card_number = card.unit_card_number; this.card_index = card_id; this.mask = card.BestMask(); this.player = card.player; this.pack = card.pack; }
public void PlayPack(PlayerTransaction transaction, BingoPack pack) { throw new Exception("Packs have multiple dealers; have to figure a way to use just one"); PlayerPack played_pack = new PlayerPack(); played_pack.pack_info = pack; played_pack.player = this; //if( pack._dealer == null ) // pack._dealer = BingoDealers.nodealer; //played_pack.start_card = pack._dealer.Deal( pack.rows, pack.cols, pack.count ); played_packs.Add(played_pack); transaction.Add(played_pack); }
public PlayerPack[] GetPlayerPacks(string packnam, String range) { List <PlayerPack> packs = new List <PlayerPack>(); //retry: foreach (BingoPack pack in pack_skel) { if (String.Compare(pack.name, packnam, true) == 0) { BingoPack real_pack = pack.GetRangePack(range); PlayerPack newpack = new PlayerPack(); newpack.pack_info = real_pack; if (packs.Count == 0) { newpack.start_card = newpack.pack_info.AutoDeal(); } else { newpack.start_card = packs[0].start_card; } packs.Add(newpack); } } if (packs.Count == 0) { if (MessageBox.Show("Pack " + packnam + " does not exist - add to schedule?", "Configure Pack?", MessageBoxButtons.YesNo) == DialogResult.Yes) { DataRow row = schedule.packs.NewPack(packnam); //OpenSkieScheduler.Controls.ControlList.schedule = schedule; OpenSkieScheduler3.Controls.Forms.PackEditor pe = new OpenSkieScheduler3.Controls.Forms.PackEditor(row); pe.ShowDialog(); //MakePack( game_group, row ); //goto retry; return(null); // MakePack( game_group, row ); } } return(packs.ToArray()); }
bool BuildRunInfo(bool one_session) { if (ori == null) { ori = new OddsRunInfo( ); } #if this_loaded_player_tracking_for_phsycial_players BingoPlayers players = new BingoPlayers(); DbDataReader reader = StaticDsnConnection.KindExecuteReader("select card,sum(value) from player_track where bingoday=" + MySQLDataTable.MakeDateOnly(result.bingoday.AddYears(2006).AddDays(7).AddMonths(5)) + " and session=" + (_sessions + 1) + " and card<>'000000000000000000'" + " group by card"); if (reader.HasRows) { while (reader.Read()) { BingoPlayer player; players.Add(player = new BingoPlayer(reader.GetString(0))); int spend = reader.GetInt32(1); for (int p = 0; p < (spend / 2000); p++) { BingoPack pack = GameList.pack_list.GetPack(true, Cards, "Fictional Pack"); PlayerPack played; pack.pack_set = p; player.played_packs.Add(played = new PlayerPack()); played.pack_info = pack; played.player = player; played.game_list = GameList; } } } #endif if (ori.trigger_stats.enabled = checkBoxTriggerBalls.Checked) { ori.trigger_stats.max_triggered = Convert.ToInt32(textBoxMaxTriggered.Text); ori.trigger_stats.triggered = new int[ori.trigger_stats.max_triggered + 1]; ori.trigger_stats.trigger_wins = new int[ori.trigger_stats.max_triggered + 1]; } if (one_session) { ori.Years = 1; ori.Days = 1; ori.Sessions = 1; ori.Halls = 1; ori.Players = Convert.ToInt32(textBoxPlayers.Text); ori.Cards = Convert.ToInt32(textBoxCards.Text); // this will be overridden later, if external game grid is used. ori.Games = Convert.ToInt32(textBoxGames.Text); } else { ori.Years = Convert.ToInt32(textBoxYears.Text); ori.Days = Convert.ToInt32(textBoxDays.Text); //move all days into the day counter // the DateTime thing will take just adding days. ori.Days = ori.Years * ori.Days; ori.Years = 1; ori.Sessions = Convert.ToInt32(textBoxSessions.Text); ori.Halls = Convert.ToInt32(textBoxHalls.Text); ori.Players = Convert.ToInt32(textBoxPlayers.Text); ori.Cards = Convert.ToInt32(textBoxCards.Text); // this will be overridden later, if external game grid is used. ori.Games = Convert.ToInt32(textBoxGames.Text); } ori.colored_balls = textBoxColorBallCount.Text.Length > 0 ? Convert.ToInt32(textBoxColorBallCount.Text) : 0; ori.flags.use_blower = radioBallBlower.Checked; ori.flags.database_run = checkBoxDatabase.Checked; ori.flags.save_winning_cards = checkBoxSaveWinningCards.Checked; ori.flags.Count_BINGO_Calls = checkBoxCountBINGOCalls.Checked; ori.flags.countColorBINGO = checkBoxCountColorBINGO.Checked; ori.flags.quickshot = checkBoxQuickshot.Checked; ori.flags.starburst = checkBoxStarburst.Checked; ori.flags.simulate = checkBoxSimulate.Checked; ori.flags.only_simulate = true; // this will be overridden later, if external game grid is used. ori.flags.hotball = checkBoxHotball.Checked; // this will be overridden later, if external game grid is used. ori.flags._5cashball = checkBox5Hotball.Checked; ori.PackSize = Convert.ToInt32(textBoxPackSize.Text); if ((ori.Cards / ori.PackSize) * ori.PackSize != ori.Cards) { ori = null; MessageBox.Show("Cards does not divide by Pack Size evenly..."); return(false); } if (comboBox1.SelectedItem != null) { String name = (comboBox1.SelectedItem as DataRowView).Row["name"].ToString(); if (name != null && name.Length > 0) { try { DataRow row = (comboBox1.SelectedItem as DataRowView).Row; DataRow original = row["original_row"] as DataRow; if (original != null) { ori.dealer = BingoDealers.GetDealer(original); } //ori.cardreader = new CardReader( row["original_row"] as DataRow ); //if( ori.cardreader.Length != 0 ) // ori.flags.cardfile = true; } catch { } } else { ori.dealer = BingoDealers.nodealer; } } else { ori.dealer = BingoDealers.nodealer; } if (!LoadGameInfoFromGrid()) { return(false); } return(true); }
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, 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) { 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(); }
public static bool check_pack(PlayerPack pack, int game, Pattern pattern) { int num_patterns; int num_cards; int pattern_index; int card_index; if (pattern.sub_patterns.Count < 1) { return(false); } CombinationIterator ci = ((pattern.mode_mod & Pattern.mode_modifications.OrderMatters) != 0) ? null : new CombinationIterator(pattern.sub_patterns.Count); bool iterator_done; List <BingoCardState> cards = pack.Cards[game]; int cardsets = cards.Count; /* * this check should be done somewhere; maybe when cards are dealt for packs to games? * * if( cardsets % pattern.sub_patterns.Count != 0 ) * { * throw new Exception( "Pack is incompatible with pattern. Mismatch integral card count" ); * } */ num_patterns = pattern.sub_patterns.Count; cardsets = cardsets / (num_patterns); if (cardsets > 1) { Log.log("Pattern-packsize mismatch"); } int[] best_combination = null; //int[,] bests = new int[ cardsets, ci.GetCombinations() ]; int combination = 0; if (pattern.pattern_masks == null) { pattern.pattern_masks = new List <Pattern.PatternMasks>(); foreach (Pattern sub_pattern in pattern.sub_patterns) { List <Pattern> tmplist = new List <Pattern>(); tmplist.Add(sub_pattern); Pattern.PatternMasks masks = new Pattern.PatternMasks(); Pattern.ExpandGamePatterns(tmplist, masks); pattern.pattern_masks.Add(masks); } } foreach (Pattern sub_pattern in pattern.sub_patterns) { int sub_pattern_index = pattern.sub_patterns.IndexOf(sub_pattern); foreach (BingoCardState card in cards) { // get last marked cardmask { if (sub_pattern.algorithm == PatternDescriptionTable.match_types.CrazyMark) { return(card.CheckCrazy(card.marks[0], sub_pattern.repeat_count)); } else if (sub_pattern.algorithm == PatternDescriptionTable.match_types.ExternalJavaEngine) { //return } else { List <int> patterns = pattern.pattern_masks[sub_pattern_index].pattern_bitmask_list; { if (card.CheckPattern(card.marks[sub_pattern_index], patterns)) { //card.WinningGame = game; //card.WinningGameEvent = game_event; //return true; } } // end of foreach( pattern ) } } } } int cardset; int best_away = 75; int worst_card_away = 75; int best_cardset; for (cardset = 0; cardset < cardsets; cardset++) { iterator_done = false; while (!iterator_done) { int[] this_order; if (ci == null) { iterator_done = true; this_order = new int[pattern.sub_patterns.Count]; for (int n = 0; n < pattern.sub_patterns.Count; n++) { this_order[n] = n; } } else { iterator_done = ci.IterateCombination(out this_order); } int total_away = 0; int card_offset = 0; foreach (int index in this_order) { int card_away = cards[cardset * num_patterns + card_offset].BestAway(index); if (card_away < 24 && card_away < worst_card_away) { worst_card_away = card_away; } total_away += card_away; card_offset++; } if (total_away < best_away) { best_away = total_away; best_combination = (int[])this_order.Clone(); best_cardset = cardset; } //bests[cardset, combination] = total_away; } combination++; } if (best_away > 0 && worst_card_away == 0) { worst_card_away = 1; } pack.state = pack.state ?? new List <BingoPackState>(); if (pack.state.Count <= game) { pack.state.Add(new BingoPackState()); } pack.state[game].best_away = best_away; pack.state[game].best_card_away = worst_card_away; pack.state[game].combination = best_combination; pack.state[game].group_size = pattern.sub_patterns.Count; if (pack.state[game].best_away == 0) { return(true); } return(false); }