コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public MTGCollection GetPlayerCollection(String Player)
        {
            MTGCollection collection = new MTGCollection();


            // mmb - todo

            return(collection);
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        public MTGClientForm()
        {
            InitializeComponent();

            // init the collection data
            Collection = new MTGCollection();

            // setup the collection data grid view
            SetupDataGridView();            

            // Welcome the player
            UpdateStatusStrip("Welcome to Magic the Gathering Online!");

            // Disable all the extra tabs until someone is logged in
            EnableTabPages(false);

            // Load the picture data set            
            CardSets = new ArrayList();
            try
            {                
                // Attempt to load the last cardset saved
                Stream stream = File.Open("10E.dat", FileMode.Open);
                BinaryFormatter bformatter = new BinaryFormatter();

                MTGCardSet cards = new MTGCardSet();
                cards = (MTGCardSet)bformatter.Deserialize(stream);
                stream.Close();

                CardSets.Add(cards);
            }
            catch (Exception ex)
            {
                if (!ex.Message.StartsWith("Could not find file"))
                {
                    LogError(String.Format("Init: ", ex.Message));
                }
                else
                {
                    LogError("Cannot find the cards data pack.");
                }
            }
            
            WaitingData = new byte[PacketSize];
        }
コード例 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="NewCollection"></param>
        public void Add(MTGCollection NewCollection)
        {
            // add this collection to our current collection
            foreach (Int32 cardnumber in NewCollection.Cards)
            {
                Cards.Add(cardnumber);
            }

            // Now add in the decks
            foreach (String DeckName in NewCollection.Decks.Keys)
            {
                ArrayList Deck = new ArrayList();

                foreach (Int32 cardnumber in NewCollection.Decks[DeckName])
                {
                    Deck.Add(cardnumber);
                }

                Decks.Add(DeckName, Deck);
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="NewCollection"></param>
        public void Add(MTGCollection NewCollection)
        {
            // add this collection to our current collection
            foreach (Int32 cardnumber in NewCollection.Cards)
            {
                Cards.Add(cardnumber);
            }

            // Now add in the decks
            foreach (String DeckName in NewCollection.Decks.Keys)
            {
                ArrayList Deck = new ArrayList();

                foreach (Int32 cardnumber in NewCollection.Decks[DeckName])
                {
                    Deck.Add(cardnumber);
                }

                Decks.Add(DeckName, Deck);
            }
        }
コード例 #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Purchase"></param>
        /// <returns></returns>
        private MTGCollection DeterminePurchases(String Purchase)
        {
            MTGCollection Collection = new MTGCollection();

            // mmb - todo:

            // Info about Purchase String
            // Edition:TypeOfPurchase:Quanity
            // Edition Example: 10th is the only edition we have right now.
            // TypeOfPurchase Example: Foil, Preconstructed Theme Deck, Starter Deck, and/or Fat Pack
            // Quantity Example:  1, 2, 3, etc.  How many do they want to buy?


//Set 	                    Set symbol 	            Set code     	Release date 	    Size    Common 	Uncommon 	Rare 	Basic Land 	Other
//Core Set - Tenth Edition 	A Roman-numeral ten 	10E 	        July 14, 2007[13] 	383 	121 	121 	    121 	20 	        —
            


            //Tenth Edition  features 383 cards, including randomly inserted premium versions of all cards in the set. 
            //It is available in booster packs, preconstructed theme decks, fat packs, and two-player starter packs.

            // Magic the Gathering Tenth Edition Core Set includes: 
            // a Player's Guide with complete visual encyclopedia, 
            // two card boxes with panoramic art and six plastic dividers, 
            // six Tenth Edition booster packs, 
            // 40 card Tenth Edition basic land pack, 
            // Tenth Edition Spindown life counter, (available only in the fat pack), 
            // plus one random Pro Tour Player card. 
            
            // Magic The Gathering - 10th Edition Theme Deck Set Of 5 Includes
            // Each starter theme deck includes a pre-constructed, ready to play 40-card deck
            // A strategy insert, and a random Pro Player card.
            // Theme deck includes:
            // Kamahl's Temper (Red), Arcanis's Guile (Blue), Molimo's Might (Green) , Evincar's Tyranny (Black), Cho-Manno's Resolve (White) Theme Decks

            // Foil = 15 Cards.  1 Land, 1 Rare or Mythic Rare, 3 Uncommon, and 10 Common.

            /*
             * 	
Kamahl's Temper
Core Set - Tenth Edition Theme Deck
            
             * Patience is no virtue. With the pit fighter Kamahl and a horde of temper-challenged "haste" creatures at your command, 
             * you'll scorch your way to victory before your enemy even finds the snooze button. 
             * Attack and burn anything that stands in your way. Why wait?

#	Name	            Rarity	Cost
1	Raging Goblin	        C   Red Mana
1	Viashino Sandscout	    C	1 ManaRed Mana
2	Bloodrock Cyclops	    C	2 ManaRed Mana
2	Bogardan Firefiend	    C	2 ManaRed Mana
1	Prodigal Pyromancer	    C	2 ManaRed Mana
2	Lightning Elemental	    C	3 ManaRed Mana
1	Furnace Whelp	        U	2 ManaRed ManaRed Mana
2	Thundering Giant	    U	3 ManaRed ManaRed Mana
1	Kamahl, Pit Fighter	    R	4 ManaRed ManaRed Mana
1	Shock	                C	Red Mana
2	Incinerate	            C	1 ManaRed Mana
2	Spitting Earth	        C	1 ManaRed Mana
1	Threaten	            U   2 ManaRed Mana
1	Beacon of Destruction	R	3 ManaRed ManaRed Mana
1	Blaze	                U	X ManaRed Mana
1	Dragon's Claw	        U	2 Mana
1	Phyrexian Vault	        U	3 Mana
17	Mountain		
	Kamahl's Temper

* = from a previous set
             * */


            try
            {
                // Edition:TypeOfPurchase:Quantity
                Int32 FirstColon = Purchase.IndexOf(":");
                Int32 SecondColon = Purchase.IndexOf(":", FirstColon + 1);
                String Edition = Purchase.Substring(0, FirstColon);
                String TypeOfPurchase = Purchase.Substring(FirstColon + 1, SecondColon - FirstColon - 1);
                Int32 Quantity = Convert.ToInt32(Purchase.Substring(SecondColon + 1));

                // mmb - don't do anything about the Edition right now... Will always be 10E

                // loop for the quantity
                for (Int32 i = 0; i < Quantity; i++)
                {
                    // 
                    switch (TypeOfPurchase)
                    {
                        case "FOIL":

                            // Foil = 15 Cards.  1 Land, 1 Rare or Mythic Rare, 3 Uncommon, and 10 Common.

                            // mmb - make cards picks random!

                            // mmb - but for current testing use these...

                            // land x 1
                            Collection.Cards.Add(129559);

                            // commons x 10
                            Collection.Cards.Add(130522);
                            Collection.Cards.Add(135185);
                            Collection.Cards.Add(130985);
                            Collection.Cards.Add(132106);
                            Collection.Cards.Add(135194);
                            Collection.Cards.Add(129671);
                            Collection.Cards.Add(134758);
                            Collection.Cards.Add(135216);
                            Collection.Cards.Add(129579);
                            Collection.Cards.Add(129533);

                            // uncommon x 3
                            Collection.Cards.Add(135267);
                            Collection.Cards.Add(129459);
                            Collection.Cards.Add(129495);

                            // rare x 1
                            Collection.Cards.Add(106426);

                            break;
                        case "KAMAHLSTEMPER":

                            // Kamahl's Temper Red Theme Deck for 10th Edition

                            // lands x 17
                            for (i = 0; i < 17; i++)
                            {
                                Collection.Cards.Add(129650);
                            }

                            // commons x 14
                            Collection.Cards.Add(129688);
                            Collection.Cards.Add(130387);
                            Collection.Cards.Add(130384);
                            Collection.Cards.Add(130384);
                            Collection.Cards.Add(130534);
                            Collection.Cards.Add(130534);
                            Collection.Cards.Add(134752);
                            Collection.Cards.Add(129624);
                            Collection.Cards.Add(129624);
                            Collection.Cards.Add(129624);
                            Collection.Cards.Add(134751);
                            Collection.Cards.Add(134751);
                            Collection.Cards.Add(136509);
                            Collection.Cards.Add(136509);

                            // uncommon x 7
                            Collection.Cards.Add(130386);
                            Collection.Cards.Add(130381);
                            Collection.Cards.Add(130381);
                            Collection.Cards.Add(129767);
                            Collection.Cards.Add(129484);
                            Collection.Cards.Add(129527);
                            Collection.Cards.Add(135281);

                            // rare x 2
                            Collection.Cards.Add(106398);
                            Collection.Cards.Add(135262);
                                                        
                            break;
                    }
                }

                // Add these purchases to the player's current collection
                // mmb - todo

                // if this is a preconstructed theme deck, then add it to the decks too
                if (TypeOfPurchase == "KAMAHLSTEMPER")
                {
                    Collection.Decks.Add("Kamahl's Temper", Collection.Cards);
                }
            }
            catch (Exception ex)
            {
                AddError(String.Format("DeterminePurchases: {0}", ex.Message));
            }

            // send back the players newly updated collection
            return Collection;
        }
コード例 #6
0
        /// <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 + "]");
            }
        }
コード例 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ar"></param>
        private void OnReceive(IAsyncResult ar)
        {
            Int32 size = 0;


            try
            {
                LogDebug("Client has received a message from the server.");

                if (ar.IsCompleted)
                {
                    size = clientSocket.EndReceive(ar);


                    if (size < PacketSize)
                    {
                        if (WaitingForData > 1)
                        {
                            byte[] temp = new byte[PacketSize * WaitingForData];
                            WaitingData.CopyTo(temp, 0);
                            byteData.CopyTo(temp, WaitingData.Length);
                            WaitingData = new byte[PacketSize * WaitingForData];
                            WaitingData = temp;
                        }
                        else
                        {
                            WaitingForData = 1;
                            byteData.CopyTo(WaitingData, 0);
                        }

                        MTGNetworkPacket packet = new MTGNetworkPacket(WaitingData);

                        //Accordingly process the message received
                        switch (packet.OpCode)
                        {
                            case MTGNetworkPacket.MTGOpCode.Login:
                                String result = packet.Data.ToString();
                                //AddStatus("Login: [" + result + "]");                                

                                // was login successful?
                                if (result != "0")
                                {
                                    // if so, then change login button, make edit boxes uneditable, etc
                                    SetLoginButtonText("Logout");
                                    EnableUserTextBox(false);
                                    EnablePasswordTextBox(false);

                                    LogInfo("Login successful!  Welcome to the MTG Server!");
                                    UpdateStatusStrip("Successfully Logged on to the MTG Server");

                                    // check to see if this user is an admin
                                    if (result == "2")
                                    {
                                        Admin = true;
                                    }

                                    EnableTabPages(true);
                                }
                                else
                                {
                                    // if not, then disconnect from server
                                    UpdateStatusStrip("Failed to Log on to the MTG Server");

                                    // message was successfully sent
                                    clientSocket.Close();

                                    SetLoginButtonText("Login");
                                    EnableUserTextBox(true);
                                    EnablePasswordTextBox(true);

                                    Connected = false;
                                    LogInfo("Log on has failed!  Disconnected");
                                }
                                break;

                            case MTGNetworkPacket.MTGOpCode.Logout:

                                // mmb - this won't happen!

                                LogDebug("Logout: [" + packet.Data.ToString() + "]");
                                UpdateStatusStrip("Successfully Logged off the MTG Server");

                                EnableTabPages(false);
                                Receiving = true;

                                break;

                            case MTGNetworkPacket.MTGOpCode.PurchaseReceive:
                                LogDebug("PurchaseReceive: [" + packet.Data.ToString() + "]");
                                MTGCollection NewCards = (MTGCollection)packet.Data;
                                UpdateStatusStrip("Purchase made.");
                                AddToCollection(NewCards);
                                UpdateStatusStrip("New purchase of cards have been added to your collection.");
                                break;

                            case MTGNetworkPacket.MTGOpCode.ReceiveCollection:
                                LogDebug("ReceiveCollection: [" + packet.Data.ToString() + "]");
                                Collection.Clear();
                                Collection = (MTGCollection)packet.Data;
                                UpdateStatusStrip("Player Collection has been received.");
                                break;

                            case MTGNetworkPacket.MTGOpCode.Chat:
                                Log(packet.Data.ToString());
                                break;
                        }

                        WaitingData = new byte[PacketSize];
                    }
                    else
                    {
                        // wait for more data?
                        LogDebug("OnReceive:  Waiting for more data from server...");
                                                
                        byte[] temp = new byte[PacketSize * WaitingForData];
                        WaitingData.CopyTo(temp, 0);
                        byteData.CopyTo(temp, (PacketSize * (WaitingForData - 1)));
                        WaitingData = new byte[PacketSize * WaitingForData];
                        WaitingData = temp;
                        WaitingForData++;
                    }
                }
            }
            catch (ObjectDisposedException exo)
            {
                String Error = "OnReceive:  Unable to receive. ObjectDisposed. [" + exo.Message + "]";
                //AddError(Error);
                LogError("Connection to the server was terminated.");
            }
            catch (Exception ex)
            {
                LogError("OnReceive:  Unable to receive. [" + ex.Message + "]");
            }

            if (size != 0 && Connected)
            {
                // now wait for a reply
                try
                {
                    byteData = new byte[PacketSize];
                    clientSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
                }
                catch (Exception ex)
                {
                    LogError("OnReceive:  Unable to begin to receive. [" + ex.Message + "]");
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public MTGCollection GetPlayerCollection(String Player)
        {
            MTGCollection collection = new MTGCollection();


            // mmb - todo

            return collection;            
        }