Ejemplo n.º 1
0
 private void replaceUnavailableToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (BatchCharacter character in BatchCharacterList)
     {
         if (character.Character != null)
         {
             for (int slot = 0; slot < 19; slot++)
             {
                 Item    item    = character.Character[(Character.CharacterSlot)slot];
                 Enchant enchant = character.Character.GetEnchantBySlot((Character.CharacterSlot)slot);
                 if (item != null)
                 {
                     string        id     = item.Id.ToString();
                     string        anyGem = id + ".*.*.*";
                     List <string> list   = character.Character.AvailableItems.FindAll(x => x.StartsWith(id));
                     List <string> sublist;
                     if (list.Contains(item.GemmedId + ".*"))
                     {
                         // available
                     }
                     else if ((sublist = list.FindAll(x => x.StartsWith(item.GemmedId))).Count > 0)
                     {
                         if (sublist.Contains(item.GemmedId + "." + (enchant != null ? enchant.Id.ToString() : "0")))
                         {
                             // available
                         }
                         else
                         {
                             // have to replace enchant
                             string s = sublist[0];
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(s.Substring(s.LastIndexOf('.') + 1)), item.Slot));
                             character.UnsavedChanges = true;
                         }
                     }
                     else if (list.Contains(id))
                     {
                         // available
                     }
                     else if ((sublist = list.FindAll(x => x.StartsWith(anyGem))).Count > 0)
                     {
                         if (sublist.Contains(anyGem + "." + (enchant != null ? enchant.Id.ToString() : "0")))
                         {
                             // available
                         }
                         else
                         {
                             // have to replace enchant
                             string s = sublist[0];
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(s.Substring(s.LastIndexOf('.') + 1)), item.Slot));
                             character.UnsavedChanges = true;
                         }
                     }
                     else if (list.Count > 0)
                     {
                         string s = list[0];
                         item = ItemCache.FindItemById(s.Substring(0, s.LastIndexOf('.')));
                         character.Character[(Character.CharacterSlot)slot] = item;
                         string se = s.Substring(s.LastIndexOf('.') + 1);
                         if (se != "*")
                         {
                             character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(se), item.Slot));
                         }
                         character.UnsavedChanges = true;
                     }
                     else
                     {
                         foreach (string s in character.Character.AvailableItems)
                         {
                             if (s.IndexOf('.') < 0)
                             {
                                 item = ItemCache.FindItemById(int.Parse(s));
                             }
                             else
                             {
                                 string[] slist = s.Split('.');
                                 if (slist[1] == "*")
                                 {
                                     item = ItemCache.FindItemById(int.Parse(slist[0]));
                                 }
                                 else
                                 {
                                     item = ItemCache.FindItemById(s.Substring(0, s.LastIndexOf('.')));
                                 }
                             }
                             if (item != null && item.FitsInSlot((Character.CharacterSlot)slot))
                             {
                                 character.Character[(Character.CharacterSlot)slot] = item;
                                 string se = s.Substring(s.LastIndexOf('.') + 1);
                                 if (se != "*")
                                 {
                                     character.Character.SetEnchantBySlot((Character.CharacterSlot)slot, Enchant.FindEnchant(int.Parse(se), item.Slot));
                                 }
                                 character.UnsavedChanges = true;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
Archivo: Item.cs Proyecto: say1981/Rawr
 private void OnIdsChanging()
 {
     ItemCache.DeleteItem(this, false);
 }
Ejemplo n.º 3
0
        void _optimizer_OptimizeCharacterCompleted(object sender, OptimizeCharacterCompletedEventArgs e)
        {
            int maxRounds = trackBarMaxRounds.Value;

            switch (currentOperation)
            {
            case AsyncOperation.Optimize:
                if (e.Cancelled || e.Error != null)
                {
                    currentOperation        = AsyncOperation.None;
                    buttonCancel.Enabled    = false;
                    statusLabel.Text        = "";
                    statusProgressBar.Value = 0;
                    break;
                }
                if (e.OptimizedCharacterValue > e.CurrentCharacterValue + 0.00001f)
                {
                    Character _character    = CurrentBatchCharacter.Character;
                    Character bestCharacter = e.OptimizedCharacter;

                    _character.Back             = bestCharacter.Back == null ? null : ItemCache.FindItemById(bestCharacter.Back.GemmedId);
                    _character.Chest            = bestCharacter.Chest == null ? null : ItemCache.FindItemById(bestCharacter.Chest.GemmedId);
                    _character.Feet             = bestCharacter.Feet == null ? null : ItemCache.FindItemById(bestCharacter.Feet.GemmedId);
                    _character.Finger1          = bestCharacter.Finger1 == null ? null : ItemCache.FindItemById(bestCharacter.Finger1.GemmedId);
                    _character.Finger2          = bestCharacter.Finger2 == null ? null : ItemCache.FindItemById(bestCharacter.Finger2.GemmedId);
                    _character.Hands            = bestCharacter.Hands == null ? null : ItemCache.FindItemById(bestCharacter.Hands.GemmedId);
                    _character.Head             = bestCharacter.Head == null ? null : ItemCache.FindItemById(bestCharacter.Head.GemmedId);
                    _character.Legs             = bestCharacter.Legs == null ? null : ItemCache.FindItemById(bestCharacter.Legs.GemmedId);
                    _character.MainHand         = bestCharacter.MainHand == null ? null : ItemCache.FindItemById(bestCharacter.MainHand.GemmedId);
                    _character.Neck             = bestCharacter.Neck == null ? null : ItemCache.FindItemById(bestCharacter.Neck.GemmedId);
                    _character.OffHand          = bestCharacter.OffHand == null ? null : ItemCache.FindItemById(bestCharacter.OffHand.GemmedId);
                    _character.Projectile       = bestCharacter.Projectile == null ? null : ItemCache.FindItemById(bestCharacter.Projectile.GemmedId);
                    _character.ProjectileBag    = bestCharacter.ProjectileBag == null ? null : ItemCache.FindItemById(bestCharacter.ProjectileBag.GemmedId);
                    _character.Ranged           = bestCharacter.Ranged == null ? null : ItemCache.FindItemById(bestCharacter.Ranged.GemmedId);
                    _character.Shoulders        = bestCharacter.Shoulders == null ? null : ItemCache.FindItemById(bestCharacter.Shoulders.GemmedId);
                    _character.Trinket1         = bestCharacter.Trinket1 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket1.GemmedId);
                    _character.Trinket2         = bestCharacter.Trinket2 == null ? null : ItemCache.FindItemById(bestCharacter.Trinket2.GemmedId);
                    _character.Waist            = bestCharacter.Waist == null ? null : ItemCache.FindItemById(bestCharacter.Waist.GemmedId);
                    _character.Wrist            = bestCharacter.Wrist == null ? null : ItemCache.FindItemById(bestCharacter.Wrist.GemmedId);
                    _character.BackEnchant      = bestCharacter.BackEnchant;
                    _character.ChestEnchant     = bestCharacter.ChestEnchant;
                    _character.FeetEnchant      = bestCharacter.FeetEnchant;
                    _character.Finger1Enchant   = bestCharacter.Finger1Enchant;
                    _character.Finger2Enchant   = bestCharacter.Finger2Enchant;
                    _character.HandsEnchant     = bestCharacter.HandsEnchant;
                    _character.HeadEnchant      = bestCharacter.HeadEnchant;
                    _character.LegsEnchant      = bestCharacter.LegsEnchant;
                    _character.MainHandEnchant  = bestCharacter.MainHandEnchant;
                    _character.OffHandEnchant   = bestCharacter.OffHandEnchant;
                    _character.RangedEnchant    = bestCharacter.RangedEnchant;
                    _character.ShouldersEnchant = bestCharacter.ShouldersEnchant;
                    _character.WristEnchant     = bestCharacter.WristEnchant;
                    _character.OnItemsChanged();

                    CurrentBatchCharacter.UnsavedChanges = true;
                    //CurrentBatchCharacter.NewScore = e.OptimizedCharacterValue;
                    CurrentBatchCharacter.NewScore = Optimizer.GetOptimizationValue(_character, CurrentBatchCharacter.Model);     // on item change always evaluate with equipped gear first (needed by mage module to store incremental data)

                    optimizerRound = 0;
                }
                else if (Math.Abs(e.OptimizedCharacterValue - e.CurrentCharacterValue) < 0.00001f && !e.CurrentCharacterInjected)
                {
                    optimizerRound = maxRounds;
                }
                else
                {
                    optimizerRound++;
                }
                if (optimizerRound >= maxRounds)
                {
                    do
                    {
                        batchIndex++;
                    } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                    optimizerRound = 0;
                }

                if (batchIndex < BatchCharacterList.Count)
                {
                    OptimizeCurrentBatchCharacter();
                }
                else
                {
                    currentOperation        = AsyncOperation.None;
                    buttonCancel.Enabled    = false;
                    statusLabel.Text        = "";
                    statusProgressBar.Value = 0;
                }
                break;
            }
        }
Ejemplo n.º 4
0
 void _menuItemEquipAll_Click(object sender, EventArgs e)
 {
     _character.IsLoading        = true;
     _character.Back             = _itemCharacter.Back == null ? null : ItemCache.FindItemById(_itemCharacter.Back.GemmedId);
     _character.Chest            = _itemCharacter.Chest == null ? null : ItemCache.FindItemById(_itemCharacter.Chest.GemmedId);
     _character.Feet             = _itemCharacter.Feet == null ? null : ItemCache.FindItemById(_itemCharacter.Feet.GemmedId);
     _character.Finger1          = _itemCharacter.Finger1 == null ? null : ItemCache.FindItemById(_itemCharacter.Finger1.GemmedId);
     _character.Finger2          = _itemCharacter.Finger2 == null ? null : ItemCache.FindItemById(_itemCharacter.Finger2.GemmedId);
     _character.Hands            = _itemCharacter.Hands == null ? null : ItemCache.FindItemById(_itemCharacter.Hands.GemmedId);
     _character.Head             = _itemCharacter.Head == null ? null : ItemCache.FindItemById(_itemCharacter.Head.GemmedId);
     _character.Legs             = _itemCharacter.Legs == null ? null : ItemCache.FindItemById(_itemCharacter.Legs.GemmedId);
     _character.MainHand         = _itemCharacter.MainHand == null ? null : ItemCache.FindItemById(_itemCharacter.MainHand.GemmedId);
     _character.Neck             = _itemCharacter.Neck == null ? null : ItemCache.FindItemById(_itemCharacter.Neck.GemmedId);
     _character.OffHand          = _itemCharacter.OffHand == null ? null : ItemCache.FindItemById(_itemCharacter.OffHand.GemmedId);
     _character.Projectile       = _itemCharacter.Projectile == null ? null : ItemCache.FindItemById(_itemCharacter.Projectile.GemmedId);
     _character.ProjectileBag    = _itemCharacter.ProjectileBag == null ? null : ItemCache.FindItemById(_itemCharacter.ProjectileBag.GemmedId);
     _character.Ranged           = _itemCharacter.Ranged == null ? null : ItemCache.FindItemById(_itemCharacter.Ranged.GemmedId);
     _character.Shoulders        = _itemCharacter.Shoulders == null ? null : ItemCache.FindItemById(_itemCharacter.Shoulders.GemmedId);
     _character.Trinket1         = _itemCharacter.Trinket1 == null ? null : ItemCache.FindItemById(_itemCharacter.Trinket1.GemmedId);
     _character.Trinket2         = _itemCharacter.Trinket2 == null ? null : ItemCache.FindItemById(_itemCharacter.Trinket2.GemmedId);
     _character.Waist            = _itemCharacter.Waist == null ? null : ItemCache.FindItemById(_itemCharacter.Waist.GemmedId);
     _character.Wrist            = _itemCharacter.Wrist == null ? null : ItemCache.FindItemById(_itemCharacter.Wrist.GemmedId);
     _character.BackEnchant      = _itemCharacter.BackEnchant;
     _character.ChestEnchant     = _itemCharacter.ChestEnchant;
     _character.FeetEnchant      = _itemCharacter.FeetEnchant;
     _character.Finger1Enchant   = _itemCharacter.Finger1Enchant;
     _character.Finger2Enchant   = _itemCharacter.Finger2Enchant;
     _character.HandsEnchant     = _itemCharacter.HandsEnchant;
     _character.HeadEnchant      = _itemCharacter.HeadEnchant;
     _character.LegsEnchant      = _itemCharacter.LegsEnchant;
     _character.MainHandEnchant  = _itemCharacter.MainHandEnchant;
     _character.OffHandEnchant   = _itemCharacter.OffHandEnchant;
     _character.RangedEnchant    = _itemCharacter.RangedEnchant;
     _character.ShouldersEnchant = _itemCharacter.ShouldersEnchant;
     _character.WristEnchant     = _itemCharacter.WristEnchant;
     _character.IsLoading        = false;
     _character.OnItemsChanged();
 }
Ejemplo n.º 5
0
 void _menuItemEquip_Click(object sender, EventArgs e)
 {
     this.Character[_equipSlot] = _item == null ? null : ItemCache.FindItemById(_item.GemmedId);
 }
Ejemplo n.º 6
0
 void _menuItemDelete_Click(object sender, EventArgs e)
 {
     ItemCache.DeleteItem(_item);
 }
Ejemplo n.º 7
0
 protected override void OnAfterCheck(TreeViewEventArgs e)
 {
     base.OnAfterCheck(e);
     if (e.Action != TreeViewAction.Unknown)
     {
         // user changed checked state
         TreeNode        node  = e.Node;
         ItemFilterRegex regex = (ItemFilterRegex)node.Tag;
         if (regex != null)
         {
             // enabled on a regex changed
             if (node.Checked)
             {
                 SetChildNodes(node, true);
                 // it got checked, make sure parents are checked also
                 while (regex != null)
                 {
                     node.Checked  = true;
                     regex.Enabled = true;
                     node          = node.Parent;
                     if (node != null)
                     {
                         regex = (ItemFilterRegex)node.Tag;
                     }
                     else
                     {
                         regex = null;
                     }
                 }
             }
             else
             {
                 // it got unchecked, make sure all child nodes are unchecked
                 SetChildNodes(node, false);
                 AutoDisable(node.Parent);
             }
         }
         else
         {
             // enabled for other got changed, there are no child nodes
             if (node.Parent == null)
             {
                 // this is the global other
                 ItemFilter.OtherEnabled = node.Checked;
             }
             else
             {
                 // other below a regex
                 if (node.Checked)
                 {
                     // make sure all parents are checked
                     node  = node.Parent;
                     regex = (ItemFilterRegex)node.Tag;
                     regex.OtherRegexEnabled = true;
                     while (regex != null && !regex.Enabled)
                     {
                         node.Checked  = true;
                         regex.Enabled = true;
                         node          = node.Parent;
                         if (node != null)
                         {
                             regex = (ItemFilterRegex)node.Tag;
                         }
                         else
                         {
                             regex = null;
                         }
                     }
                 }
                 else
                 {
                     // just disable it
                     node  = node.Parent;
                     regex = (ItemFilterRegex)node.Tag;
                     regex.OtherRegexEnabled = false;
                     AutoDisable(node.Parent);
                 }
             }
         }
         // trigger item update
         FormMain.Instance.Cursor = Cursors.WaitCursor;
         ItemCache.OnItemsChanged();
         FormMain.Instance.Cursor = Cursors.Default;
     }
 }