Exemple #1
0
        public static List <MageKnightData> GetMageKnights()
        {
            List <MageKnightData> mageKnights = new List <MageKnightData>();

            SqlConnection connection = MageKnightDataDB.GetConnection();
            string        selectStatement
                = "SELECT Id, [Index], [Set], Name, PointValue, Faction, FrontArc, Targets, Range, Rank, Rarity, ModelImage "
                  + "FROM AllMageKnights ";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            try
            {
                connection.Open();

                SqlDataReader reader = selectCommand.ExecuteReader();


                while (reader.Read())
                {
                    MageData data = new MageData();
                    data.Id         = Guid.Parse(reader["Id"].ToString());
                    data.Index      = Int32.Parse(reader["Index"].ToString());
                    data.Name       = reader["Name"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.Set        = reader["Set"].ToString();
                    data.PointValue = Int32.Parse(reader["PointValue"].ToString());
                    data.Range      = Int32.Parse(reader["Range"].ToString());
                    data.FrontArc   = Int32.Parse(reader["FrontArc"].ToString());
                    data.Targets    = Int32.Parse(reader["Targets"].ToString());
                    data.Rank       = reader["Rank"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.ModelImage = reader["ModelImage"] as byte[];
                    data.Dial       = GetDialStats(data);
                    MageKnightData mage = new MageKnightData(data);
                    mageKnights.Add(mage);
                }



                connection.Close();

                return(mageKnights);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"something is wrong GetMageKnight:{ex.ToString()}");
            }

            return(null);
        }
Exemple #2
0
        public static MageKnightData GetMageKnight(int index)
        {
            SqlConnection connection = MageKnightDataDB.GetConnection();
            string        selectStatment
                = "SELECT Id, [Index], [Set], Name, PointValue, Faction, FrontArc, Targets, Range, Rank, Rarity, ModelImage "
                  + "FROM AllMageKnights "
                  + "WHERE [Index] = @Index";
            SqlCommand selectCommand = new SqlCommand(selectStatment, connection);

            selectCommand.Parameters.AddWithValue("@Index", index);

            try
            {
                connection.Open();
                MageData       data   = new MageData();
                MageKnightData mage   = null;
                SqlDataReader  reader = selectCommand.ExecuteReader(System.Data.CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    data.Id         = Guid.Parse(reader["Id"].ToString());
                    data.Index      = Int32.Parse(reader["Index"].ToString());
                    data.Name       = reader["Name"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.Set        = reader["Set"].ToString();
                    data.PointValue = Int32.Parse(reader["PointValue"].ToString());
                    data.Range      = Int32.Parse(reader["Range"].ToString());
                    data.FrontArc   = Int32.Parse(reader["FrontArc"].ToString());
                    data.Targets    = Int32.Parse(reader["Targets"].ToString());
                    data.Rank       = reader["Rank"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.ModelImage = reader["ModelImage"] as byte[];
                    data.Dial       = GetDialStats(data);
                    mage            = new MageKnightData(data);
                }

                connection.Close();

                return(mage);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"something is wrong GetMageKnight:{ex.ToString()}");
            }
            finally
            {
                connection.Close();
            }

            return(null);
        }
Exemple #3
0
        public static MageKnightData GetRandomMage(BoosterPack set)
        {
            int rarityFilter = RandomNumber(1, 1000);
            int rarity       = 1;

            if (rarityFilter < 250) //  %25 chance of pulling rarity 1
            {
                rarity = 1;
            }
            else if (rarityFilter >= 250 && rarityFilter < 450) //  %20 chance of pulling rarity 2
            {
                rarity = 2;
            }
            else if (rarityFilter >= 450 && rarityFilter < 620) // %17
            {
                rarity = 3;
            }
            else if (rarityFilter >= 620 && rarityFilter < 760)// %14
            {
                rarity = 4;
            }
            else if (rarityFilter >= 760 && rarityFilter < 890)//  %13
            {
                rarity = 5;
            }
            else if (rarityFilter >= 500 && rarityFilter < 980)//  %9
            {
                rarity = 6;
            }
            else if (rarityFilter >= 980 && rarityFilter <= 1000)//  %2
            {
                rarity = 7;
            }

            SqlConnection connection = MageKnightDataDB.GetConnection();
            string        selectStatement
                = "SELECT Id, [Index], [Set], Name, PointValue, Faction, FrontArc, Targets, Range, Rank, Rarity, ModelImage "
                  + "FROM AllMageKnights "
                  + "WHERE Rarity = @Rarity";

            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue(
                "@Rarity", rarity);

            try
            {
                connection.Open();

                SqlDataReader reader = selectCommand.ExecuteReader();

                List <MageData> mages = new List <MageData>();
                while (reader.Read())
                {
                    MageData data = new MageData();
                    data.Id         = Guid.Parse(reader["Id"].ToString());
                    data.Index      = Int32.Parse(reader["Index"].ToString());
                    data.Name       = reader["Name"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.Set        = reader["Set"].ToString();
                    data.PointValue = Int32.Parse(reader["PointValue"].ToString());
                    data.Range      = Int32.Parse(reader["Range"].ToString());
                    data.FrontArc   = Int32.Parse(reader["FrontArc"].ToString());
                    data.Targets    = Int32.Parse(reader["Targets"].ToString());
                    data.Rank       = reader["Rank"].ToString();
                    data.Faction    = reader["Faction"].ToString();
                    data.ModelImage = reader["ModelImage"] as byte[];
                    data.Dial       = GetDialStats(data);
                    mages.Add(data);
                }

                int randomlySelectedIndex = RandomNumber(0, mages.Count - 1);

                connection.Close();

                MageKnightData mage = new MageKnightData(mages.ElementAt(randomlySelectedIndex));
                return(mage);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"something is wrong GetMageKnight:{ex.ToString()}");
            }

            return(null);
        }