/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo(object obj) { if (obj is MTGCard) { MTGCard otherRowInformation = (MTGCard)obj; switch (_sortby) { case 0: return(Convert.ToInt32(this._id).CompareTo(Convert.ToInt32(otherRowInformation._id))); case 1: return(this._name.CompareTo(otherRowInformation._name)); case 2: return(this._cost.CompareTo(otherRowInformation._cost)); case 3: return(this._type.CompareTo(otherRowInformation._type)); case 4: return(this._power.CompareTo(otherRowInformation._power)); case 5: return(this._power.CompareTo(otherRowInformation._toughness)); case 11: return(Convert.ToInt32(this._quantity).CompareTo(Convert.ToInt32(otherRowInformation._quantity))); case 12: return(Convert.ToInt32(this._number).CompareTo(Convert.ToInt32(otherRowInformation._number))); default: // if not found or defined, then sort by name return(this._name.CompareTo(otherRowInformation._name)); } } else { throw new ArgumentException("Object is not a RowInformation"); } }
/// <summary> /// /// </summary> /// <param name="Row"></param> public void Add(MTGCard Row) { CardSet.Add(Row); LastFetched = DateTime.Now; }
/// <summary> /// /// </summary> /// <param name="Row"></param> public void Add(MTGCard Row) { CardSet.Add(Row); LastFetched = DateTime.Now; }
/// <summary> /// /// </summary> /// <param name="NewCards"></param> private void AddToCollection(MTGCollection NewCards) { try { ArrayList Display = new ArrayList(); // update the collection data grid Collection.Add(NewCards); foreach (Int32 cardnumber in Collection.Cards) { MTGCard card = new MTGCard(); foreach (MTGCard cardInfo in ((MTGCardSet)CardSets[0]).CardSet) { if (cardInfo.ID == cardnumber) { card = cardInfo; if (Display.Contains(card)) { // increment the quantity Int32 index = Display.IndexOf(card); ((MTGCard)Display[index]).Quantity += 1; } else { Display.Add(card); } break; } } } UpdateCollection(Display); Display = new ArrayList(); UpdateCombo("Create New"); // now update the combobox foreach (String DeckName in Collection.Decks.Keys) { UpdateCombo(DeckName); UpdateCombo2(DeckName); } } catch (Exception ex) { LogError("AddToCollection: Unable to add cards to collection. [" + ex.Message + "]"); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonGameSolitare_Click(object sender, EventArgs e) { // enable the game tab Gaming = true; EnableTabPages(false); EnableTabPages(true); // move tab focus to the game tab tabControl1.SelectTab(4); // start the game! String DeckName = comboBoxDecks2.SelectedItem.ToString(); ArrayList Cards = new ArrayList(); MTGDeck Deck = new MTGDeck(); Deck.Name = DeckName; foreach (Int32 cardnumber in Collection.Decks[DeckName]) { MTGCard card = new MTGCard(); foreach (MTGCard cardInfo in ((MTGCardSet)CardSets[0]).CardSet) { if (cardInfo.ID == cardnumber) { card = cardInfo; if (Cards.Contains(card)) { // increment the quantity Int32 index = Cards.IndexOf(card); ((MTGCard)Cards[index]).Quantity += 1; } else { Cards.Add(card); } break; } } } Deck.Cards = Cards; CurrentGame = new Game(this); CurrentGame.AddPlayerDeck(Deck); CurrentGame.StartSolitareGame(); Update(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxDecks_SelectedIndexChanged(object sender, EventArgs e) { ArrayList Display = new ArrayList(); String DeckName = comboBoxDecks.SelectedItem.ToString(); try { if (Collection.Decks.ContainsKey(DeckName)) { // update the decks data grid ArrayList Deck = Collection.Decks[DeckName]; foreach (Int32 cardnumber in Deck) { MTGCard card = new MTGCard(); foreach (MTGCard cardInfo in ((MTGCardSet)CardSets[0]).CardSet) { if (cardInfo.ID == cardnumber) { card = cardInfo; if (Display.Contains(card)) { // increment the quantity Int32 index = Display.IndexOf(card); ((MTGCard)Display[index]).Quantity += 1; } else { Display.Add(card); } } } } } UpdateDecks(Display); } catch (Exception ex) { LogError("comboBoxDecks_SelectedIndexChanged: Problem with combobox switch. [" + ex.Message + "]"); } }