Ejemplo n.º 1
0
        public List <Party> Read()
        {
            List <Party> party = new List <Party>();
            Party        p     = null;

            IDbCommand command = _connector.CreateCommand();

            command.CommandText = "SELECT [Naam], [Lijsttrekker], [AantalLeden], [Stemmen], [Zetels] FROM Partij JOIN PartijUitslag ON Partij.ID = PartijUitslag.PartijID";

            using (IDataReader reader = _connector.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    p = new Party()
                    {
                        Name            = reader.GetString(0),
                        PartyLeader     = reader.GetString(1),
                        AmountOfMembers = reader.GetInt32(2),
                        Votes           = reader.GetInt32(3),
                        Seats           = reader.GetInt32(4)
                    };
                    party.Add(p);
                }
            }

            return(party);
        }
Ejemplo n.º 2
0
        public List <Card> FetchAllCards()
        {
            List <Card> cards = new List <Card>();

            List <int>    cardIDs       = new List <int>();
            List <string> cardNames     = new List <string>();
            List <string> manaCosts     = new List <string>();
            List <int>    CMCs          = new List <int>();
            List <int>    Ps            = new List <int>();
            List <int>    Ts            = new List <int>();
            List <int>    Ls            = new List <int>();
            List <string> rules         = new List <string>();
            List <string> flavor        = new List <string>();
            List <string> artist        = new List <string>();
            List <string> generatedMana = new List <string>();
            List <int>    rarity        = new List <int>();

            List <List <string> > types         = new List <List <string> >();
            List <List <string> > color         = new List <List <string> >();
            List <List <string> > colorIdentity = new List <List <string> >();

            IDbCommand command = connector.CreateCommand();

            command.CommandText = "SELECT ID, mtgCard.name, manacost, converted_manacost, p as 'Power', t as 'Toughness', l as 'Loyalty', rulesText, flavor, artist, generated_mana FROM mtgcard";
            using (IDataReader reader = connector.ExecuteReader(command))
            {
                while (reader.Read())
                {
                    cardIDs.Add(reader.GetInt32(0));
                    cardNames.Add(reader.GetString(1));
                    manaCosts.Add(reader.GetString(2));
                    CMCs.Add(reader.GetInt32(3));
                    Ps.Add(reader.GetInt32(4));
                    Ts.Add(reader.GetInt32(5));
                    Ls.Add(reader.GetInt32(6));
                    rules.Add(reader.GetString(7));
                    flavor.Add(reader.GetString(8));
                    artist.Add(reader.GetString(9));
                    generatedMana.Add(reader.GetString(10));
                }
            }
            foreach (int i in cardIDs)
            {
                List <string> cardtypes       = new List <string>();
                IDbCommand    commandGetTypes = connector.CreateCommand();
                command.CommandText = "SELECT cardType.Name FROM cardTypeCard JOIN cardType ON cardTypeCard.cardType = cardType.id WHERE cardID = " + i;
                //command.AddParameterWithValue("cardID", i);
                using (IDataReader reader = connector.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        cardtypes.Add(reader.GetString(0));
                    }
                }
                types.Add(cardtypes);

                List <string> cardcolors       = new List <string>();
                IDbCommand    commandGetColors = connector.CreateCommand();
                command.CommandText = "SELECT Color.Name FROM cardColor JOIN Color ON cardColor.colorCode = color.Code WHERE cardID = " + i;
                //command.AddParameterWithValue("cardID2", i);
                using (IDataReader reader = connector.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        cardcolors.Add(reader.GetString(0));
                    }
                }
                color.Add(cardcolors);

                List <string> cardColorIdentities = new List <string>();
                IDbCommand    commandGetCIs       = connector.CreateCommand();
                command.CommandText = "SELECT Color.Name FROM cardColorIdentity JOIN Color ON cardColorIdentity.colorCode = color.Code WHERE cardID = " + i;
                //command.AddParameterWithValue("cardID3", i);
                using (IDataReader reader = connector.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        cardColorIdentities.Add(reader.GetString(0));
                    }
                }
                colorIdentity.Add(cardColorIdentities);

                IDbCommand commandGetRarity = connector.CreateCommand();
                command.CommandText = "SELECT rarity.code FROM cardRarity JOIN rarity ON cardRarity.rarity = rarity.code WHERE cardRarity.cardID = " + i;
                //command.AddParameterWithValue("cardID4", i);
                using (IDataReader reader = connector.ExecuteReader(command))
                {
                    rarity.Add(1 /*reader.GetInt32(0)*/);
                }
            }

            foreach (int id in cardIDs)
            {
                if (types[id - 1] != null && id < 165)
                {
                    if (types[id - 1].Contains("Artifact") || types[id - 1].Contains("Creature") || types[id - 1].Contains("Enchantment") || types[id - 1].Contains("Land") || types[id - 1].Contains("Planeswalker"))
                    { //Hier ArgumentOutOfBoundsException, op [164], in een lijst van Count=165, en [164] is gewoon gevuld!
                        cards.Add(new Permanent(cardIDs[id - 1], cardNames[id - 1], color[id - 1], colorIdentity[id - 1], manaCosts[id - 1], CMCs[id], types[id - 1], (Rarity)rarity[id - 1], rules[id], flavor[id - 1], Ps[id - 1], Ts[id - 1], Ls[id - 1]));
                    }
                    else
                    {
                        if (types[id - 1].Contains("Tribal"))
                        {
                            cards.Add(new NonPermanent(cardIDs[id - 1], cardNames[id - 1], color[id - 1], colorIdentity[id], manaCosts[id - 1], CMCs[id - 1], types[id - 1], (Rarity)rarity[id - 1], rules[id - 1], flavor[id - 1], true));
                        }
                        else
                        {
                            cards.Add(new NonPermanent(cardIDs[id - 1], cardNames[id - 1], color[id - 1], colorIdentity[id], manaCosts[id - 1], CMCs[id - 1], types[id - 1], (Rarity)rarity[id - 1], rules[id - 1], flavor[id - 1], false));
                        }
                    }
                }
                System.Diagnostics.Debug.Print("hope this works");
            }
            return(cards);
        }