Exemple #1
0
        /// <summary>
        /// Gets a input from the database
        /// </summary>
        /// <param name="BOGUS_ID">The ID of the input object to retreive</param>
        /// <param name="mongo">the database object to use to get the results</param>
        /// <returns>a Card object</returns>
        public Card getCardFromDB(int BOGUS_ID, IDataStore database)
        {
            #region oldCode
            /*
            Document query = new Document(

            Cursor cq = new Cursor();
            c

            query["BOGUS_ID"] = "$in" + BOGUS_ID;
            Document results = mongo["pokemon"]["cards"].Find(

            //TODO: Convert the strings to their proper type internally
            string Name = results["Name"].ToString();
            string Stage = results["Stage"].ToString();
            string Type = results["Type"].ToString();

            //Evolution code (Just noticed that the two keys in the database are in different case
            //now (after an ugly exception) whoever did that should get punched in the head :/
            string[] evolInto = results["EvolvesFrom"].ToString().Split(',');
            string[] evolFrom = results["evolvesInto"].ToString().Split(',');

            Enums.Element type = parseType(Type);
            Enums.Stage stage = parseStage(Stage);
            int HP = 0;
            string Weakness = "";
            string Resistance = "";
            int pNum = 0;
            Attack[] atk = new Attack[2];

            if (type != Enums.Element.Trainer && type != Enums.Element.Energy)
            {
                HP = int.Parse((results["HP"] ?? 0).ToString());
                Weakness = results["Weakness"].ToString();
                Resistance = results["Resistance"].ToString();

                //Give me the pokemon number or -1
                int tryP = -1;

                if (!(int.TryParse(results["pokemonNumberInt"].ToString(), out tryP)))
                {
                    Console.Write("?");
                }

                if (!(results["Attack1"].ToString() == string.Empty)) //If there is an attack 1
                {
                    atk[0] = new Attack(results["Attack1"].ToString());
                    atk[0].damage = results["TypicalDamage1"].ToString();
                }

                if (!(results["Attack2"].ToString() == string.Empty))
                {
                    atk[1] = new Attack(results["Attack2"].ToString());
                    atk[1].damage = (results["TypicalDamage2"].ToString());
                }
            }
            //Make sure to fix input to correct this issue.
            return new Card(BOGUS_ID, Name, HP, Stage, Weakness, Resistance, Type, atk, evolInto, evolFrom, pNum);

             * */
            #endregion
            database.connect();
            return database.getCardbyID(BOGUS_ID);
        }