public Pattern(Pattern p) { this.row = p.row.Table.NewRow(); this._repeat_count = p._repeat_count; this.algorithm = p.algorithm; // clone the original data row. DataRow row = p.row; for (int n = 1; n < p.row.ItemArray.Length; n++) { // don't copy the primary key. if (p.row.Table.Columns[n].AutoIncrement) { continue; } this.row[n] = p.row[n]; } // clone all the loaded masks. this.masks = new List <System.Collections.Specialized.BitVector32>(); foreach (System.Collections.Specialized.BitVector32 bits in p.masks) { this.masks.Add(new System.Collections.Specialized.BitVector32(bits)); } this.sub_patterns = new List <Pattern>(); foreach (Pattern pattern in p.sub_patterns) { sub_patterns.Add(pattern); } // create a new name based on the old name. this.row[XDataTable.Name(row.Table)] = this.Name = "Copy of " + p.Name; this._mode_mod = p._mode_mod; this.pattern_list = p.pattern_list; this.changed = true; retry_name: try { p.row.Table.Rows.Add(this.row); } catch (ConstraintException ce) { if (ce.Message.IndexOf("pattern_name") >= 0) { this.row[XDataTable.Name(row.Table)] = this.Name = "Copy of " + this.Name; goto retry_name; } } UpdateRow(); }
public Form1() { DataRow[] drarray; BingoSQLTracking.BingoTracking.disable = true; schedule = new ScheduleDataSet(StaticDsnConnection.dsn); schedule.Create(); schedule.Fill(); schedule.patterns.DefaultView.Sort = "pattern_name ASC"; schedule.sessions.DefaultView.Sort = "session_name ASC"; patterns = new Patterns(schedule); ori = new OddsRunInfo( ); InitializeComponent(); Cardsets = new DataTable(); Cardsets.TableName = "Cardset"; Cardsets.Columns.Add("Name", typeof(String)); Cardsets.Columns.Add("filename", typeof(string)); Cardsets.Columns.Add("original_row", typeof(DataRow)); DataRow drx = Cardsets.NewRow(); drx[0] = "<No Dealers Found>"; drx[1] = null; Cardsets.Rows.Add(drx); foreach (DataRow row in schedule.cardset_ranges.Rows) { DataRow dr = Cardsets.NewRow(); dr[0] = row[OpenSkieScheduler3.BingoGameDefs.CardsetRange.NameColumn]; // skip the ',' string object o = row.GetParentRow(CardsetRange.CardsetInfoRelationName)["name"]; if (o == null) { dr[1] = DBNull.Value; } else { dr[1] = o; } dr[2] = row; Cardsets.Rows.Add(dr); } Cardsets.AcceptChanges(); PoplateGameTable(); }
public Pattern(ScheduleDataSet schedule, Patterns pattern_data) { ID = Guid.Empty; row = schedule.patterns.NewRow(); Name = QueryNewName.Show("Enter new pattern name"); if (Name == null || Name == "") { throw new NullReferenceException("Name cannot be blank."); } _repeat_count = 1; algorithm = 0; _mode_mod = mode_modifications.NoExpansion; masks = new List <System.Collections.Specialized.BitVector32>(25); sub_patterns = new List <Pattern>(); //row["pattern_name"] = Name; changed = true; this.pattern_list = pattern_data; //pattern_data = schedule.pattern_data; schedule.patterns.Rows.Add(row); UpdateRow(); }
bool LoadGameInfoFromGrid() { if (!Loaded) { int game_number = 1; //int maxid = 0; OddsRunInfo.GameInfo prior_game = null; GameList = new BingoGameList(); foreach (DataRow row in GamePatternTable.Rows) { bool rate; if (!(rate = row["Rate Game"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Rate Game"]))) { continue; } OddsRunInfo.GameInfo game = new OddsRunInfo.GameInfo(); game.patterns = new List <Pattern>(); int pattern_col = GamePatternTable.Columns.IndexOf("Pattern 1"); ori.flags.lastBall = row["Last Ball"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Last Ball"]); game.starburst = row["Starburst"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Starburst"]); if (game.starburst) { ori.flags.starburst = true; } game.rate = rate; //game.rate = row["Rate Game"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Rate Game"] ); game.ignore_b_balls = row["Ignore Bs"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Bs"]); game.ignore_i_balls = row["Ignore Is"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Is"]); game.ignore_n_balls = row["Ignore Ns"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Ns"]); game.ignore_g_balls = row["Ignore Gs"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Gs"]); game.ignore_o_balls = row["Ignore Os"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Ignore Os"]); //if( !game.rate ) // continue; //game.hotball = row["Hotball"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Hotball"] ); game.cashballs = row["# Cash Ball"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["# Cash Ball"]); game.progressive = row["Progressive"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Progressive"]); //game.double_action = row["Double Action"].Equals( DBNull.Value ) ? false : Convert.ToBoolean( row["Double Action"] ); game.overlapped = row["Overlapped"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Overlapped"]); game.extension = row["Extension"].Equals(DBNull.Value) ? false : Convert.ToBoolean(row["Extension"]); game.upick_size = row["Upick Count"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["Upick Count"]); game.number_colored = row["Colored Ball Count"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(row["Colored Ball Count"]); // extended games have a prior_game. if (game.extension) { if (prior_game == null) { game.extension = false; } game.prior_game = prior_game; } // if there is a prior game, then check that game to see if it was progressive or overlapped... if it is, then this has a prior. else if (prior_game != null && (prior_game.progressive || prior_game.overlapped)) { game.prior_game = prior_game; game.into = true; // set that we are the inot part of a progressive... } else { game.prior_game = null; } prior_game = game; // game group is 5... // okay pattern is found by name and added offset... good. if (game.cashballs == 1) { ori.flags.hotball = true; } if (game.cashballs == 5) { ori.flags._5cashball = true; } Patterns tmp = new Patterns(schedule); for (int i = 0; i < 1; i++) { object pattern_id = row[pattern_col + i]; if (pattern_id != DBNull.Value) { DataRow[] rows = schedule.patterns.Select("pattern_id='" + pattern_id + "'"); if (rows.Length > 0) { tmp.Add(new Pattern(rows[0], patterns)); } } } if (tmp.Count == 0) { // otherwise we don't need (or want) patterns if (game.upick_size == 0) { // no pattern, and not upick, drop the issue continue; // next game. } game.Name = "Upickem " + game.upick_size; } else { game.Name = tmp[0].Name; if (game.upick_size > 0) { // this is a conflict. } game.SetPatterns(tmp.ToArray()); } game.game_number = game_number; bool found_match = false; // this shouldn't have to be initialized to zero here. // there won't be any in the list // so it will end up being assigned before the // location that the compiler throws a stupid warning game.game_ID = 0; int game_pattern_count = game.patterns.Count; // gamelist as null is okay, and just bails the loop. foreach (OddsRunInfo.GameInfo checkgame in GameList) { int i = 0; if (checkgame.patterns.Count == game_pattern_count) { for ( ; i < game_pattern_count; i++) { if (!checkgame.patterns[i].ID.Equals(game.patterns[i].ID)) { break; } } } if (i == game_pattern_count) { found_match = true; game.game_ID = checkgame.game_ID; game.pattern_list = checkgame.pattern_list; game.stats = checkgame.stats; lock (game.stats) { game.stats.games++; } break; } } if (!found_match) // if it's still zero, didn't find one, so set one. { OddsRunInfo.GameTypeInfo stats = new OddsRunInfo.GameTypeInfo(); ///if( !ori.GameTypeList ) if (ori.GameTypeList == null) { ori.GameTypeList = new List <OddsRunInfo.GameTypeInfo>(); } stats.best_wins = new int[ori.bestwins.Length]; stats.aways = new int[5]; stats.games = 1; // one same game. stats.name = game.Name; stats.lastBalls = new int[90]; if (ori.colored_balls > 0) { stats.colored_ball_hit = new int[ori.colored_balls]; } ori.GameTypeList.Add(stats); game.stats = stats; game.game_ID = ori.GameTypeList.IndexOf(stats); } game.quickshot = ori.flags.quickshot; if ((game.patterns.Count > 0) || (game.upick_size > 0)) { GameList.Add(game); } else { game = null; // just make sure we auto destruct this... } game_number++; } //------------------------------------------------------------- // Check if user has selected a game/pattern //------------------------------------------------------------- if (GameList.Count <= 0) { MessageBox.Show("Please select a Pattern and Game to Rate from the Game Grid before pressing 'Go'", "Missing Pattern"); return(false); } ori.Games = GameList.Count; BingoGameGroup bgg = null; // new BingoGameGroup( Guid.NewGuid() ); BingoDealer dealer; if (ori.dealer != null) { dealer = ori.dealer; } else { dealer = BingoDealers.CreateSimpleDealer(); } foreach (BingoGame game in GameList) { if (bgg == null || !game.into) { bgg = new BingoGameGroup(Guid.NewGuid()); GameList.game_group_list.AddGameGroup(bgg); // add some packs to the game_group if (game.upick_size > 0) { BingoDealer upick_dealer = BingoDealers.CreateUpickDealer(game.upick_size); BingoPack upick_pack = GameList.CreatePack(upick_dealer, "Fictional UPick " + game.upick_size, ori.Cards); upick_pack.face_size = game.upick_size; upick_pack.flags.upickem = true; if (!upick_pack.game_groups.Contains(bgg)) { upick_pack.game_groups.Add(bgg); } bgg.packs.Add(upick_pack); } else { BingoPack pack = GameList.CreatePack(dealer, "Fictional Pack", ori.PackSize); pack.game_groups.Add(bgg); bgg.packs.Add(pack); } } bgg.Add(game); game.game_group = bgg; if (game.pack_card_counts.Count < 1) { game.pack_card_counts.Add(ori.Cards); } } ori.bingo_session = new BingoSession(GameList); ori.bingo_session.session_name = "Odds Run Info"; } return(true); }
public Pattern(DataRow row, Patterns pattern_list) { CommonInit(row, pattern_list); }
void CommonInit(DataRow row, Patterns pattern_list) { this.row = row; //this.pattern_data = pattern_data; //this.pattern_sub_pattern = pattern_sub_pattern; this.pattern_list = pattern_list; int col_count = row.Table.Columns.IndexOf("count"); int col_match = row.Table.Columns.IndexOf("match"); //ID = Convert.ToInt32( row[XDataTable.ID( row.Table )] ); ID = row[XDataTable.ID(row.Table)]; Name = (String)row[XDataTable.Name(row.Table)]; if (col_count >= 0) { if (row[col_count].GetType() == typeof(DBNull)) { _repeat_count = 1; } else { _repeat_count = Convert.ToInt32(row[col_count]); } if (_repeat_count == 0 && col_match >= 0) { // this causes the row that selected this to change. row[col_count] = row[col_match]; if (row[col_match].GetType() == typeof(DBNull)) { _repeat_count = 1; } else { _repeat_count = Convert.ToInt32(row[col_match]); } } } else { _repeat_count = (int)row["match"]; } _crazy_hardway = (bool)row["crazy_hardway"]; if (row.Table.Columns.IndexOf("mode") >= 0) { algorithm = (row["mode"].Equals(DBNull.Value) ? PatternDescriptionTable.match_types.Normal : (PatternDescriptionTable.match_types)row["mode"]); } else { algorithm = (row["real_mode"].Equals(DBNull.Value) ? PatternDescriptionTable.match_types.Normal : (PatternDescriptionTable.match_types)row["real_mode"]); } _mode_mod = (mode_modifications)row["mode_mod"]; object o = row["pattern_board_size"]; board_size = (o == DBNull.Value)?0:Convert.ToInt32(o); if ((_mode_mod & mode_modifications.eCube) != 0) { _mode_mod -= mode_modifications.eCube; eCube = true; } if ((_mode_mod & mode_modifications.max_mod) != 0) { _mode_mod -= mode_modifications.max_mod; _repeat_no_overlap = true; } if (_mode_mod == mode_modifications.NoOverlap) { _repeat_no_overlap = true; } sub_patterns = new List <Pattern>(); { DataRow[] sub_pattern_rows = row.GetChildRows("pattern_has_sub_pattern"); foreach (DataRow pattern in sub_pattern_rows) { Pattern sub = null; foreach (Pattern p in pattern_list) { if (p.ID.Equals(pattern[PatternDescriptionTable.PrimaryKey])) { sub = p; break; } } if (sub == null) { bool created2; sub = pattern_list.GetPattern(pattern.GetParentRow("sub_pattern_is_pattern"), out created2); } this.sub_patterns.Add(sub); } } masks = new List <System.Collections.Specialized.BitVector32>(); // these aren't really changes. changed = false; }
public BingoGame(BingoGameList game_list, DataRow group_game) { BingoGame _game = ((game_list.Count > 0) ? game_list[game_list.Count - 1] : null); ScheduleDataSet schedule = game_list.schedule; Init(); Name = group_game.ToString(); game_number = Convert.ToInt32(group_game[SessionGame.NumberColumn]); //game_list. //dataRow_game_group_game = group_game; { DataRow[] tmp = group_game.GetChildRows("session_game_has_session_game_group"); int n = 0; foreach (DataRow row in tmp) { BingoGameGroup bgg; this.game_group = bgg = game_list.game_group_list.GetGameGroup(row.GetParentRow("session_game_group_in_session_game")); bgg.Add(this); { DataRow session_game_group = row.GetParentRow("session_game_group_in_session_game"); DataRow[] game_prizes = session_game_group.GetChildRows("game_group_has_pack"); //DataRow[] game_prizes = group_packs. //DataRow[] game_group_prizes = game_group_row.GetChildRows( "game_group_has_prize_level" ); foreach (DataRow game_prize in game_prizes) { DataRow _prize = game_prize.GetParentRow("prize_level_in_game_group"); if (_prize[PrizeLevelNames.PrimaryKey] == null) { int a = 3; } prizes.Add(new BingoPrize(_prize[PrizeLevelNames.PrimaryKey], 50)); } // should further check against overrides to get corrected prizes. } } } { Patterns new_patterns = new Patterns(schedule); DataRow[] GamePatterns = schedule.game_patterns.GetPatterns(group_game); //Log.log( "Selected " + GamePatterns.Length + " game pattes for " + group["game_info_id"] ); foreach (DataRow pattern in GamePatterns) { object pattern_id = pattern[schedule.patterns.PrimaryKeyName]; Log.log("Looking up pattern " + pattern_id); Pattern GamePattern = new Pattern(pattern, new_patterns); new_patterns.Add(GamePattern); } SetPatterns(new_patterns.ToArray()); } if (Convert.ToBoolean(group_game["single_hotball"])) { cashballs = 1; } //double_action = Convert.ToBoolean( group_game["double_action"] ); // Load all of the packs defined in this session. // these are used to validate sales loaded into players.... // they are also used to collect raw informatino to match by name // the pack sales to pack definitions such ad dealer parameters. DataRow[] game_group_packs; { game_group_packs = schedule.session_games.GetGameGroupPacks(group_game); BingoPack pack = null; if (game_group_packs != null) { foreach (DataRow info in game_group_packs) { BingoGameGroup use_group = null; bool found = false; //foreach( BingoGameGroup game_group in game_groups ) { DataRow real_game_group = info.GetParentRow("game_group_prize_level_has_pack"); if (game_group.ID.Equals(real_game_group[PackGroupTable.PrimaryKey])) { use_group = game_group; found = true; break; } } if (!found) { game_group = use_group = new BingoGameGroup(info[PackGroupTable.PrimaryKey]); } game_group_packs = schedule.session_games.GetPacks(group_game); foreach (DataRow ggp in game_group_packs) { pack = game_list.pack_list.MakePack(use_group, ggp); while (pack_card_counts.Count <= pack.pack_type) { pack_card_counts.Add(0); } } if (pack == null) { } if (pack != null) { pack_card_counts[pack.pack_type] = pack.count; } } } prior_group_game = null; foreach (BingoGame g in game_list) { if (g == this) { continue; } //foreach( BingoGameGroup gamegroup in g.game_groups ) { //foreach( BingoGameGroup this_group in this.game_groups ) if (g.game_group != null && this.game_group != null) // this isn't set during loading... { if (g.game_group.ID.Equals(this.game_group.ID)) { prior_group_game = g; break; } } } } if (prior_group_game == null) { page_skip = 0; // this isn't really an into, prior game might be 'normal' progressive, but // that's really into the next part, not this one. into = false; } else if (into) { page_skip = prior_group_game.page_skip; } else { page_skip = prior_group_game.page_skip + 1; } //game_group_id = group_id; } // setup progressive game, and game skips (by page, and by absolute ball-set) { progressive = (Convert.ToInt32(group_game["progressive"]) != 0); if (_game != null) { if (_game.progressive) { ballset_number = _game.ballset_number; into = true; } else { ballset_number = _game.ballset_number + 1; } } else { ballset_number = 0; } } // setup page_skip. { if (prior_group_game == null) { page_skip = 0; // this isn't really an into, prior game might be 'normal' progressive, but // that's really into the next part, not this one. into = false; } else if (into) { page_skip = prior_group_game.page_skip; } else { page_skip = prior_group_game.page_skip + 1; } } //game_number = game_number; prior_game = _game; //_game = game; }