public void ReloadSessionGames(DataRow session) { if (schedule == null) { return; } // clear all my games. this.Clear(); // hmm... { DataRow[] SessionGames = session.GetChildRows("session_has_game"); if (SessionGames != null) { foreach (DataRow session_game in SessionGames) { int game_number = Convert.ToInt32(session_game[SessionGame.NumberColumn]); if (session_game.RowState == DataRowState.Deleted) { continue; } foreach (BingoGame test_game in this) { if (test_game.game_number == game_number) { test_game.Extend(this, session_game); game_number = 0; break; } } if (game_number > 0) { BingoGame game = new BingoGame(this, session_game); //new BingoGame( patterns.ToArray() ); Add(game); game.game_list = this; game.game_ID = IndexOf(game); DataRow[] games_game_groups = session_game.GetChildRows("session_game_has_session_pack_group"); foreach (DataRow game_game_group in games_game_groups) { DataRow session_pack_group = game_game_group.GetParentRow("session_pack_group_in_session_game"); DataRow pack_group_info = session_pack_group.GetParentRow("pack_group_in_session"); //DataRow pack_group = session_pack_group.GetParentRow( "pack_group_in_session" ); BingoGameGroup bgg = this.game_group_list.GetGameGroup(pack_group_info); bgg.Add(game); } game.session_game_id = session_game[SessionGame.PrimaryKey]; } } } } if (pack_list == null) { pack_list = new BingoPacks(this, schedule, session); } UpdateCardCounts(); }
/// <summary> /// Create a new BingoPack from a PackTable datarow /// </summary> /// <param name="dataRow">A row from PackTable</param> public BingoPack(BingoGameGroup game_group, DataRow dataRow) { if (dataRow != null) { this.schedule_row = dataRow; ScheduleDataSet schedule = dataRow.Table.DataSet as ScheduleDataSet; if (game_group != null) { this.game_groups.Add(game_group); this.cols = Convert.ToInt32(dataRow["width"]); this.rows = Convert.ToInt32(dataRow["height"]); this.count = cols * rows; this.name = dataRow[PackTable.NameColumn].ToString(); } if (schedule != null) { DataRow[] possible_game_group_prize = dataRow.GetChildRows("pack_has_prize_level"); List <DataRow> game_group_prize = new List <DataRow>(); foreach (DataRow prize in possible_game_group_prize) { this.prize_levels.Add(game_group.GetPrize(prize[PrizeLevelNames.PrimaryKey])); } } this.ID = dataRow[PackTable.PrimaryKey]; if (count == 0) { Log.log("Pack " + dataRow[PackTable.NameColumn] + " has 0 faces defined by length and strips(rows,cols:height,width)."); } object tmp = dataRow["_3_number"]; if (tmp == DBNull.Value) { flags.big3 = false; } else { flags.big3 = Convert.ToBoolean(tmp); } tmp = dataRow["double_action"]; if (tmp == DBNull.Value) { flags.double_action = false; } else { flags.double_action = Convert.ToBoolean(tmp); } } }
/// <summary> /// Search for a pack already created by said name, if it doesn't exist, create a BingoPack as defined by PackTable Row. /// </summary> /// <param name="dataRow">a DataRow from PackTable</param> /// <returns></returns> public BingoPack MakePack(BingoGameGroup game_group, DataRow dataRow) { foreach (BingoPack pack in pack_skel) { if (String.Compare(pack.name, dataRow[PackTable.NameColumn].ToString(), true) == 0 && pack.game_groups.Contains(game_group)) { return(pack); } } foreach (BingoPack pack in pack_skel) { // found the pack, but it's not in this game group, so it's not really a pack. if (String.Compare(pack.name, dataRow[PackTable.NameColumn].ToString(), true) == 0) { return(pack); } } BingoPack newpack = new BingoPack(game_group, dataRow); if (dataRow != null) { DataRow[] ranges = dataRow.GetChildRows("pack_has_cardset_range"); if (ranges.Length == 0) { MessageBox.Show("Pack " + dataRow[PackTable.NameColumn] + " does not have any cardset ranges..."); OpenSkieScheduler3.Controls.Forms.PackEditor pe = new OpenSkieScheduler3.Controls.Forms.PackEditor(dataRow); pe.ShowDialog(); pe.Dispose(); ranges = dataRow.GetChildRows("pack_has_cardset_range"); } if (ranges != null && ranges.Length > 0) { foreach (DataRow cardset_range in ranges) { DataRow range = cardset_range.GetParentRow("cardset_range_in_pack"); newpack.dealers.Add(BingoDealers.GetDealer(range)); } } this.pack_skel.Add(newpack); newpack.pack_type = this.pack_skel.IndexOf(newpack); game_group.packs.Add(newpack); } return(newpack); }
public BingoPacks(BingoGameList game_list, ScheduleDataSet schedule, DataRow session_info) { this.schedule = schedule; this.game_list = game_list; //Session if (session_info != null) { DataRow[] pack_groups = session_info.GetChildRows("session_has_pack_group"); foreach (DataRow pack_group in pack_groups) { DataRow pack_group_info = pack_group.GetParentRow("pack_group_in_session"); BingoGameGroup group = game_list.game_group_list.GetGameGroup(pack_group_info); DataRow[] packs = pack_group_info.GetChildRows("pack_group_has_pack"); foreach (DataRow pack in packs) { DataRow pack_info = pack.GetParentRow("pack_in_pack_group"); BingoPack made_pack = this.MakePack(group, pack_info); this.Add(made_pack); } } } }
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); }
/// <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(BingoPlayer _Player, List <object> game_pack_set_ids, BingoGameState s) { int pack_number = 0; BingoGameGroup game_group = s.game.game_group; 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? if (player_card_list.Count > 0) { return; } //player_card_list.Clear(); //foreach( PlayerTransaction trans in _Player.transactions ) { foreach (PlayerPack _pack in _Player.played_packs) { 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 <= s.game.game_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[s.game.game_ID]; if (game_cards.Count < card_count) { if (_pack.dealer == null) { 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. if (base_real_card == 512301) { int a = 3; } 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 { if (_pack.pack_info.name == "Double Double" || _pack.pack_info.name == "Dual Daub") { int a = 3; } 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); cs.player = _Player; cs.pack = _pack; //cs.prize_level_id = _pack.pack_info._dealer.prize_level_id; cs.unit_card_number = unit_card; cs.cardset_card_number = real_card; cs.game = s.game_event; 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[s.game.game_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); } } } } } }
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; }