public void SetupList(Player player, List<Team> listOfTeams )
        {

            ListWithOutAdded = new List<Team>();
            foreach (var team in listOfTeams)
            {
                ListWithOutAdded.Add(team);
            }
             TeamsAdded = player.Teams;
            foreach (var tm in listOfTeams)
            {
                foreach (var tmA in TeamsAdded)
                {
                    if (tm.Id == tmA.Id)
                    {
                        ListWithOutAdded.Remove(tm);
                    }
                }
            }
            
        }
        /// <summary>
        /// Removes some book from repository (if this book was there)
        /// </summary>
        /// <param name="book">Some book to remove</param>
        public void RemoveBook(Book book)
        {
            try
            {
                if (book == null)
                    throw new ArgumentException("Book is null");

                books = repository.LoadToList();
                if (!books.Contains(book))
                    throw new ArgumentException("There is no this book in booklist");
                else
                {
                    books.Remove(book);
                    logger.Info("Book was removed successfully");
                    repository.LoadToFile(books);
                }
            }
            catch (Exception e)
            {
                logger.Info(e.Message);
                logger.Error(e.StackTrace);
            }
        }
Beispiel #3
0
 private IEnumerable<String> ParseTags(String tags)
 {
     var tagsList =new  List<String>(Regex.Split(Regex.Replace(tags, @"\s\s+", @"\s"), @"\s*,\s+"));
     tagsList.Remove("");
     return tagsList;
 }
Beispiel #4
0
 public void UniquePaypalUserInBasket(ref List<Basket> allBasket, int EventId)
 {
     Events eventAdded = db.Events.FirstOrDefault(e => e.EventsId == EventId);
     foreach (Basket b in allBasket)
     {
         if (eventAdded.PaypalEmail != b.Event.PaypalEmail)
         {
             RemoveProduct(b.EventId);
             allBasket.Remove(b);
         }
     }
 }
        void c_ClientAcceptImbueItemInfo(object sender, ClientAcceptImbueItemEventArgs e)
        {
            Client c = (Client)sender;
            AcceptImbueItem i = e.Info;
            int itemCount = 1;
            BaseItem item = null;
            BaseItem imbueItem = null, imbueItem2 = null, imbueItem3 = null;  // Stone\Crystal\Jewel
            ImbueError error = ImbueError.FailedToRemake;   // Default error = fail
            ImbueStat stat = ImbueStat.CriticalHit;     // Default stat to imbue = critical
            List<ImbueStat> WhiteStats = null;      // List of possible stats to imbue
            List<ImbueStat> RedStats = null;

            try
            {
                imbueItem = c.MyCharacter.Bags[i.ImbueItem1Bag - 1].Items.Single(x => (x.ItemID == i.ImbueItem1ID));
                if (!(imbueItem is ImbueItem))      // If not using imbue item
                {
                    // Output error - not imbue item
                    return;
                }
                ImbueItem imbueitem = imbueItem as ImbueItem;

                item = c.MyCharacter.Bags[i.ToImbueItemBag - 1].Items.Single(x => (x.ItemID == i.ToImbueItemID && x.Slot == i.ToImbueItemSlot));
                if (!(item is Equipment))      // See if item can be imbued
                {
                    // Output error - not imbuable item
                    return;
                }
                Equipment Item = item as Equipment;

                int SuccessChance = 75;     // Success rate offset
                int increaseAbility = 0;

                if (i.ImbueItem2ID != 0)
                {
                    imbueItem2 = c.MyCharacter.Bags[i.ImbueItem2Bag - 1].Items.Single(x => (x.ItemID == i.ImbueItem2ID));
                    itemCount++;
                    if (i.ImbueItem3ID != 0)
                    {
                        imbueItem3 = c.MyCharacter.Bags[i.ImbueItem3Bag - 1].Items.Single(x => (x.ItemID == i.ImbueItem3ID));
                        itemCount++;
                    }
                }

                SuccessChance += imbueitem.ImbueChance * itemCount;
                increaseAbility += imbueitem.IncreaseValue;

                int value = (int)(Item.RequiredLevel) + increaseAbility;        // Base increase value is req level

                if (imbueItem is Black)     // Using a black imbue item
                {
                    // Increase value increases according to plus and type of rock
                    value += (int)(((value * 0.1) * Item.Plus) + ((imbueitem.ImbueChance / 5) * Item.Plus));
                    if(Item is Feet)
                        value = (int)(Math.Round((double)(value / 50))) + 1;

                    if (XiahRandom.PercentSuccess(SuccessChance - Item.Plus * 4))      // Attempt imbue
                    {
                        gameEngine.BlackImbue(Item, ref stat, imbueitem, 1);        // Imbue the item
                        if (!(Item is Feet))
                            if(Item.RebirthHole == (short)(RebirthHoleItems.BlackImbueTier1) ||
                                Item.RebirthHole == (short)(RebirthHoleItems.BlackImbueTier2) ||
                                Item.RebirthHole == (short)(RebirthHoleItems.BlackImbueTier3))
                            {
                                value += Item.RebirthHoleStat;
                            }
                        Item.Plus++;        // Increase plus by 1
                        error = ImbueError.Success;     // Return success message
                    }
                    else   // Failed to imbue
                    {
                        error = ImbueError.FailedToRemake;      // Error failed to imbue
                        stat = ImbueStat.None;      // No stat imbued
                        if (Item.Plus >= 4 && XiahRandom.PercentSuccess(Item.Plus * 2))    // Drop?
                        {
                            value = gameEngine.BlackImbue(Item, ref stat, imbueitem, -1);       // Lose value
                            Item.Plus--;        // Reduce plus by 1
                        }
                        value *= -1;
                    }
                }
                else if (imbueItem is White)
                {
                    if (Item is Cape)
                    {
                        byte[] cannotbeImbued = PacketManager.SendImbueMessage(ImbueError.ImbueImpossible, ImbueStat.None, 0, Item);
                        c.Send(cannotbeImbued);
                        return;
                    }

                    value += (int)(((value * 0.1) * Item.Slvl) + ((imbueitem.ImbueChance / 5) * Item.Slvl));
                    WhiteStats = new List<ImbueStat>();
                    WhiteStats.Add(ImbueStat.Damage);
                    WhiteStats.Add(ImbueStat.Defense);
                    WhiteStats.Add(ImbueStat.AttackRating);
                    WhiteStats.Add(ImbueStat.MaxLife);
                    WhiteStats.Add(ImbueStat.MaxMana);
                    WhiteStats.Add(ImbueStat.LifeReg);
                    WhiteStats.Add(ImbueStat.ManaReg);
                    WhiteStats.Add(ImbueStat.CriticalHit);

                    if (XiahRandom.PercentSuccess(SuccessChance - Item.Slvl * 4))
                    {
                        value = gameEngine.WhiteImbue(Item, ref stat, imbueitem);
                        Item.Slvl++;
                        error = ImbueError.Success;
                    }
                    else
                    {
                        error = ImbueError.FailedToRemake;
                        stat = ImbueStat.None;

                        if (Item.Slvl >= 4 && XiahRandom.PercentSuccess(Item.Slvl * 2))
                        {
                            Item.Slvl--;
                            if (Item is Cape)
                            {
                                WhiteStats.Remove(ImbueStat.Damage);
                                WhiteStats.Remove(ImbueStat.Defense);

                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Hand)
                            {
                                WhiteStats.Remove(ImbueStat.Damage);

                                if (Item.Defence == 0)
                                    WhiteStats.Remove(ImbueStat.Defense);
                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Head)
                            {
                                WhiteStats.Remove(ImbueStat.AttackRating);

                                if (Item.Damage == 0)
                                    WhiteStats.Remove(ImbueStat.Damage);
                                if (Item.Defence == 0)
                                    WhiteStats.Remove(ImbueStat.Defense);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Body)
                            {
                                WhiteStats.Remove(ImbueStat.Defense);

                                if (Item.Damage == 0)
                                    WhiteStats.Remove(ImbueStat.Damage);
                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Feet)
                            {
                                WhiteStats.Remove(ImbueStat.CriticalHit);

                                if (Item.Defence == 0)
                                    WhiteStats.Remove(ImbueStat.Defense);
                                if (Item.Damage == 0)
                                    WhiteStats.Remove(ImbueStat.Damage);
                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Ring)
                            {
                                WhiteStats.Remove(ImbueStat.MaxLife);

                                if (Item.Defence == 0)
                                    WhiteStats.Remove(ImbueStat.Defense);
                                if (Item.Damage == 0)
                                    WhiteStats.Remove(ImbueStat.Damage);
                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }
                            if (Item is Necklace)
                            {
                                WhiteStats.Remove(ImbueStat.MaxMana);

                                if (Item.Defence == 0)
                                    WhiteStats.Remove(ImbueStat.Defense);
                                if (Item.Damage == 0)
                                    WhiteStats.Remove(ImbueStat.Damage);
                                if (Item.AttackRating == 0)
                                    WhiteStats.Remove(ImbueStat.AttackRating);
                                if (Item.IncMaxLife == 0)
                                    WhiteStats.Remove(ImbueStat.MaxLife);
                                if (Item.IncMaxMana == 0)
                                    WhiteStats.Remove(ImbueStat.MaxMana);
                                if (Item.IncLifeRegen == 0)
                                    WhiteStats.Remove(ImbueStat.LifeReg);
                                if (Item.IncManaRegen == 0)
                                    WhiteStats.Remove(ImbueStat.ManaReg);
                                if (Item.Critical == 0)
                                    WhiteStats.Remove(ImbueStat.CriticalHit);
                            }

                            int randomStat = XiahRandom.Next(0, WhiteStats.Count);
                            stat = WhiteStats[randomStat];

                            switch (stat)
                            {
                                case ImbueStat.Damage:
                                    value = Item.Damage;
                                    Item.Damage = 0;
                                    break;

                                case ImbueStat.Defense:
                                    value = Item.Defence;
                                    Item.Defence = 0;
                                    break;

                                case ImbueStat.AttackRating:
                                    value = Item.AttackRating;
                                    Item.AttackRating = 0;
                                    break;

                                case ImbueStat.MaxLife:
                                    value = Item.IncMaxLife;
                                    Item.IncMaxLife = 0;
                                    break;

                                case ImbueStat.MaxMana:
                                    value = Item.IncMaxMana;
                                    Item.IncMaxMana = 0;
                                    break;

                                case ImbueStat.LifeReg:
                                    value = Item.IncLifeRegen;
                                    Item.IncLifeRegen = 0;
                                    break;

                                case ImbueStat.ManaReg:
                                    value = Item.IncManaRegen;
                                    Item.IncManaRegen = 0;
                                    break;

                                case ImbueStat.CriticalHit:
                                    value = Item.Critical;
                                    Item.Critical = 0;
                                    break;
                            }

                            #region drop less than all stats
                            //else THIS IS IF WE WANNA DROP LIKE 30 FROM WHITE FAILURE BUT F**K THAT ITS ALL OR NOTHING MANG (H)
                            //{
                            //    switch (stat)
                            //    {
                            //        case ImbueStat.Damage:
                            //            Item.Damage -= (Item.Damage < (short)value) ? Item.Damage : (short)value;
                            //            break;

                            //        case ImbueStat.Defense:
                            //            Item.Defence -= (Item.Defence < (short)value) ? Item.Defence : (short)value;
                            //            break;

                            //        case ImbueStat.AttackRating:
                            //            Item.AttackRating -= (Item.AttackRating < (short)value) ? Item.AttackRating : (short)value;
                            //            break;

                            //        case ImbueStat.MaxLife:
                            //            Item.IncMaxLife -= (Item.IncMaxLife < (short)value) ? Item.IncMaxLife : (short)value;
                            //            break;

                            //        case ImbueStat.MaxMana:
                            //            Item.IncMaxMana -= (Item.IncMaxMana < (short)value) ? Item.IncMaxMana : (short)value;
                            //            break;

                            //        case ImbueStat.LifeReg:
                            //            Item.IncLifeRegen -= (Item.IncLifeRegen < (short)value) ? Item.IncLifeRegen : (short)value;
                            //            break;

                            //        case ImbueStat.ManaReg:
                            //            Item.IncManaRegen -= (Item.IncManaRegen < (short)value) ? Item.IncManaRegen : (short)value;
                            //            break;

                            //        case ImbueStat.CriticalHit:
                            //            value = (int)(Math.Round((double)(value / 50))) + 1;
                            //            Item.Critical -= (Item.Critical < (short)value) ? Item.Critical : (short)value;
                            //            break;
                            //    }
                            //}
                            #endregion

                            value *= -1;
                        }
                    }
                }
                if (imbueItem is Red)
                {
                    value = -imbueitem.IncreaseValue;
                    int randStat = 0;
                    BaseItem temp = itemDataManager.GetItemByReferenceID(item.ReferenceID);
                    Equipment Temp = temp as Equipment;
                    stat = ImbueStat.None;

                    RedStats = new List<ImbueStat>();
                    RedStats.Add(ImbueStat.RequiredLevel);
                    RedStats.Add(ImbueStat.RequiredEnergy);
                    RedStats.Add(ImbueStat.RequiredDexterity);
                    RedStats.Add(ImbueStat.RequiredStamina);
                    RedStats.Add(ImbueStat.RequiredStrength);

                    if (Item.RequiredLevel == 0)
                        RedStats.Remove(ImbueStat.RequiredLevel);
                    if (Item.RequiredEnergy == 0)
                        RedStats.Remove(ImbueStat.RequiredEnergy);
                    if (Item.RequiredDexterity == 0)
                        RedStats.Remove(ImbueStat.RequiredDexterity);
                    if (Item.RequiredStamina == 0)
                        RedStats.Remove(ImbueStat.RequiredStamina);
                    if (Item.RequiredStrength == 0)
                        RedStats.Remove(ImbueStat.RequiredStrength);

                    if (RedStats.Count == 0) // no stats left blabla
                        error = ImbueError.ImbueImpossible;
                    else // theres one stat to remove :)
                    {
                        if (imbueitem.ImbueData == 0)
                        {
                            if (RedStats.Count == 1)
                                stat = RedStats[0];
                            else
                            {
                                randStat = XiahRandom.Next(0, RedStats.Count);
                                stat = RedStats[randStat];
                            }
                        }
                        else
                        {
                            switch (imbueitem.ImbueData)
                            {
                                case 2:
                                    stat = ImbueStat.RequiredLevel;
                                    break;
                                case 3:
                                    stat = ImbueStat.RequiredStrength;
                                    break;
                                case 4:
                                    stat = ImbueStat.RequiredStamina;
                                    break;
                                case 5:
                                    stat = ImbueStat.RequiredDexterity;
                                    break;
                                case 6:
                                    stat = ImbueStat.RequiredEnergy;
                                    break;
                                default:
                                    stat = ImbueStat.RequiredLevel;
                                    break;
                            }
                        }

                        if (stat == ImbueStat.RequiredLevel)
                        {

                            if (XiahRandom.PercentSuccess(SuccessChance - (Temp.RequiredLevel - Item.RequiredLevel) * 4))
                                gameEngine.RedImbue(Item, stat, ref value, true, ref error); //if succeeded, pass the success value as 1, as well as pass the error
                            else
                                gameEngine.RedImbue(Item, stat, ref value, false, ref error); //if failed, random between -1 and 0, as well as pass the error
                        }
                        else if (stat == ImbueStat.RequiredStrength)
                        {
                            if (XiahRandom.PercentSuccess(SuccessChance - (Temp.RequiredStrength - Item.RequiredStrength) * 4))

                                gameEngine.RedImbue(Item, stat, ref value, true, ref error);
                            else
                                gameEngine.RedImbue(Item, stat, ref value, false, ref error);
                        }
                        else if (stat == ImbueStat.RequiredStamina)
                        {
                            if (XiahRandom.PercentSuccess(SuccessChance - (Temp.RequiredStamina - Item.RequiredStamina) * 4))
                                gameEngine.RedImbue(Item, stat, ref value, true, ref error);
                            else
                                gameEngine.RedImbue(Item, stat, ref value, false, ref error);
                        }
                        else if (stat == ImbueStat.RequiredDexterity)
                        {
                            if (XiahRandom.PercentSuccess(SuccessChance - (Temp.RequiredDexterity - Item.RequiredDexterity) * 4))
                                gameEngine.RedImbue(Item, stat, ref value, true, ref error);
                            else
                                gameEngine.RedImbue(Item, stat, ref value, false, ref error);
                        }
                        else if (stat == ImbueStat.RequiredEnergy)
                        {
                            if (XiahRandom.PercentSuccess(SuccessChance - (Temp.RequiredEnergy - Item.RequiredEnergy) * 4))
                                gameEngine.RedImbue(Item, stat, ref value, true, ref error);
                            else
                                gameEngine.RedImbue(Item, stat, ref value, false, ref error);
                        }
                    }
                }
                if (imbueitem is RbHoleItem)
                {
                    if (Item.RebirthHole == 1)
                    {
                        if (c.MyCharacter.Money >= (imbueitem.Price * 10))
                        {
                            c.MyCharacter.Money -= (imbueitem.Price * 10);
                            Item.RebirthHole = imbueitem.ImbueChance;
                            Item.RebirthHoleStat = imbueitem.IncreaseValue;

                            if (imbueitem.ImbueChance == (short)RebirthHoleItems.Durability ||
                                imbueitem.ImbueChance == (short)RebirthHoleItems.LevelReq)
                            {
                                if (imbueitem.ImbueChance == (short)RebirthHoleItems.Durability)
                                {
                                    float curdur = (float)Item.MaxDurability;
                                    float incDur = curdur * 0.20f;
                                    Item.MaxDurability += (short)incDur;
                                    Item.Durability = Item.MaxDurability;
                                }
                                else
                                {
                                    Item.RequiredLevel -= 5;
                                }
                            }

                            c.Send(PacketManager.SendMoneyLeft(c.MyCharacter.Money));

                            stat = (ImbueStat)255;
                            value = 0;
                            error = ImbueError.Success;
                        }
                        else
                        {
                            c.Send(PacketManager.SendImbueMessage(ImbueError.NotEnoughtMoney, 0, 0, Item));
                            return;
                        }
                    }
                    else
                    {
                        c.Send(PacketManager.SendImbueMessage(ImbueError.ImbueImpossible, 0, 0, Item));
                        return;
                    }
                }

                if (imbueitem is Red && error == ImbueError.FailedToRemake && value == 0)
                {
                    stat = ImbueStat.None;
                    // just send failed to remake blabla
                }
                else if (imbueitem is Red && error == ImbueError.FailedToRemake && value < 0)
                {
                    value = -value; // so it shows increasement
                }

                c.Send(PacketManager.SendImbueMessage(error, stat, value, Item));

                c.Send(PacketManager.SendRemoveItem(i.ImbueItem1Bag, i.ImbueItem1Slot));

                itemDataManager.DeleteItem(imbueItem.ItemID);
                c.MyCharacter.Bags[i.ImbueItem1Bag - 1].RemoveItem(imbueItem);

                if (imbueItem2 != null)
                {
                    c.Send(PacketManager.SendRemoveItem(i.ImbueItem2Bag, i.ImbueItem2Slot));
                    itemDataManager.DeleteItem(imbueItem2.ItemID);
                    c.MyCharacter.Bags[i.ImbueItem2Bag - 1].RemoveItem(imbueItem2);
                    if (imbueItem3 != null)
                    {
                        c.Send(PacketManager.SendRemoveItem(i.ImbueItem3Bag, i.ImbueItem3Slot));
                        itemDataManager.DeleteItem(imbueItem3.ItemID);
                        c.MyCharacter.Bags[i.ImbueItem3Bag - 1].RemoveItem(imbueItem3);
                    }
                }

                Item.ImbueTries++;
                c.Send(PacketManager.SendImbuedItem(Item));

                itemDataManager.UpdateItem(Item);
            }
            catch
            {
            }
        }
Beispiel #6
0
        public int WhiteImbue(Equipment Item, ref ImbueStat stat, ImbueItem imbueitem)
        {
            int value = (int)(Item.RequiredLevel);
            value += (int)(((value * 0.1) * Item.Slvl) + ((imbueitem.ImbueChance / 5) * Item.Slvl));

            List<ImbueStat> WhiteStats = new List<ImbueStat>();
            WhiteStats.Add(ImbueStat.Damage);
            WhiteStats.Add(ImbueStat.Defense);
            WhiteStats.Add(ImbueStat.AttackRating);
            WhiteStats.Add(ImbueStat.MaxLife);
            WhiteStats.Add(ImbueStat.MaxMana);
            WhiteStats.Add(ImbueStat.LifeReg);
            WhiteStats.Add(ImbueStat.ManaReg);
            WhiteStats.Add(ImbueStat.CriticalHit);

            if (Item is Cape)
            {
                WhiteStats.Remove(ImbueStat.Damage);
                WhiteStats.Remove(ImbueStat.Defense);
            }
            if (Item is Hand)
            {
                Hand weapon = Item as Hand;
                WhiteStats.Remove(weapon.NotWithWhite);
            }
            if (Item is Head)
            {
                Head hat = Item as Head;
                WhiteStats.Remove(hat.NotWithWhite);
            }
            if (Item is Body)
            {
                Body armor = Item as Body;
                WhiteStats.Remove(armor.NotWithWhite);
            }
            if (Item is Ring)
            {
                Ring ring = Item as Ring;
                value *= (int)2.94;
            }
            if (Item is Necklace)
            {
                Necklace neck = Item as Necklace;
                value *= (int)1.85;
            }

            if (imbueitem.ImbueData == 0)
            {
                int randomStat = Random.Next(0, WhiteStats.Count);
                stat = WhiteStats[randomStat];
            }
            else
            {
                switch (imbueitem.ImbueData)
                {
                    case 2:
                        stat = ImbueStat.Damage;
                        break;
                    case 3:
                        stat = ImbueStat.Defense;
                        break;

                    case 4:
                        stat = ImbueStat.AttackRating;
                        break;

                    case 5:
                        stat = ImbueStat.CriticalHit;
                        break;

                    case 6:
                        stat = ImbueStat.MaxLife;
                        break;

                    case 7:
                        stat = ImbueStat.MaxMana;
                        break;

                    case 8:
                        stat = ImbueStat.LifeReg;
                        break;

                    case 9:
                        stat = ImbueStat.ManaReg;
                        break;

                    default:
                        stat = ImbueStat.CriticalHit;
                        break;
                }
            }
            switch (stat)
            {
                case ImbueStat.Damage:
                    Item.Damage += (short)value;
                    break;

                case ImbueStat.Defense:
                    Item.Defence += (short)value;
                    break;

                case ImbueStat.AttackRating:
                    Item.AttackRating += (short)value;
                    break;

                case ImbueStat.MaxLife:
                    Item.IncMaxLife += (short)value;
                    break;

                case ImbueStat.MaxMana:
                    Item.IncMaxMana += (short)value;
                    break;

                case ImbueStat.LifeReg:
                    Item.IncLifeRegen += (short)value;
                    break;

                case ImbueStat.ManaReg:
                    Item.IncManaRegen += (short)value;
                    break;

                case ImbueStat.CriticalHit:
                    value = (int)(Math.Round((double)(value / 50))) + 1;
                    Item.Critical += (short)value;
                    break;
            }

            return value;
        }
 /// <summary>
 /// grvKhuyenMaiSL_CellDoubleClick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void grvKhuyenMaiSL_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         // Lay source
         Entities.KhuyenMaiSoLuong[] source = (Entities.KhuyenMaiSoLuong[])grvKhuyenMaiSL.DataSource;
         List<Entities.KhuyenMaiSoLuong> list = new List<Entities.KhuyenMaiSoLuong>();
         list = source.ToList();
         // lay item khi click
         Entities.KhuyenMaiSoLuong item = (Entities.KhuyenMaiSoLuong)grvKhuyenMaiSL.Rows[e.RowIndex].DataBoundItem;
         // remove item trong list
         list.Remove(item);
         // nhet data vao control
         SetData(item);
         // nhet data vao list view
         grvKhuyenMaiSL.DataSource = list.ToArray();
     }
     catch
     {
     }
 }