int EquipSlotToEquipSlotCategoryKey(Saint.EquipSlot sEquipSlot) { switch (sEquipSlot.Key) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: return(sEquipSlot.Key + 1); case 12: // Fingers share an EquipSlotCategory return(12); default: throw new NotImplementedException(); } }
public static bool IsSlot(this EquipSlot self, ItemSlots slot) { switch (slot) { // TODO: ensuire this works in every laguage! case ItemSlots.MainHand: return(self.Name == "Main Hand"); case ItemSlots.Head: return(self.Name == "Head"); case ItemSlots.Body: return(self.Name == "Body"); case ItemSlots.Hands: return(self.Name == "Hands"); case ItemSlots.Waist: return(self.Name == "Waist"); case ItemSlots.Legs: return(self.Name == "Legs"); case ItemSlots.Feet: return(self.Name == "Feet"); case ItemSlots.OffHand: return(self.Name == "Off Hand"); case ItemSlots.Ears: return(self.Name == "Ears"); case ItemSlots.Neck: return(self.Name == "Neck"); case ItemSlots.Wrists: return(self.Name == "Wrists"); case ItemSlots.RightRing: return(self.Name == "Right Ring"); case ItemSlots.LeftRing: return(self.Name == "Left Ring"); } throw new Exception($"Unknown item slot: {slot}"); }
public static ItemSlots ToSlot(this EquipSlot self) { ItemSlots slot; if (!slotLookup.TryGetValue(self, out slot)) { string name = self.Name; slot = name switch { "Main Hand" => ItemSlots.MainHand, "Head" => ItemSlots.Head, "Body" => ItemSlots.Body, "Hands" => ItemSlots.Hands, "Waist" => ItemSlots.Waist, "Legs" => ItemSlots.Legs, "Feet" => ItemSlots.Feet, "Off Hand" => ItemSlots.OffHand, "Ears" => ItemSlots.Ears, "Neck" => ItemSlots.Neck, "Wrists" => ItemSlots.Wrists, "Right Ring" => ItemSlots.RightRing, "Left Ring" => ItemSlots.LeftRing, "Soul Crystal" => ItemSlots.SoulCrystal, _ => throw new Exception("Unknown slot name: " + name), }; slotLookup.Add(self, slot); } return(slot); }
Tuple <Saint.Items.Equipment, int> Match(Saint.EquipSlot slot, Saint.Quad key) { if (!_equipmentBySlotByModelKey.ContainsKey(slot)) { Console.WriteLine(_equipmentBySlotByModelKey.Keys.ToString()); } var equipmentByModelKey = _equipmentBySlotByModelKey[slot]; // Check for an exact match. if (equipmentByModelKey.TryGetValue(key, out var equipment)) { return(Tuple.Create(equipment, 0)); } // Search for the closest-matching equipment with this key. var matchComplexity = int.MaxValue; var matchUncertainty = int.MaxValue; Saint.Items.Equipment matchEquipment = null; foreach (var pair in equipmentByModelKey) { // The first value must always match. if (pair.Key.Value1 != key.Value1) { continue; } // If the equipment is a weapon or shield, the second value must always match too. if ((pair.Value is Saint.Items.Weapon || pair.Value is Saint.Items.Shield) && pair.Key.Value2 != key.Value2) { continue; } // For every 10 levels of variance in the second value, match uncertainty increases. var uncertainty = 1 + Math.Abs(pair.Key.Value2 - key.Value2) / 10; if (uncertainty > matchUncertainty) { continue; } // Now find the least complicated match on the lowest uncertainty level. var complexity = _complexity.GetNqComplexity(pair.Value.Key); if (complexity < matchComplexity) { matchUncertainty = uncertainty; matchEquipment = pair.Value; } } return(Tuple.Create(matchEquipment, matchUncertainty)); }
void StoreModelKey(Dictionary <Saint.EquipSlot, ModelData> keys, UInt32 model, Saint.Stain stain, Saint.EquipSlot slot) { // UInt32.MaxValue is an override used to remove a piece from the template. if (model == UInt32.MaxValue) { keys.Remove(slot); } else if (model > 0) { keys[slot] = new ModelData(new Saint.Quad(model), stain); } }
void StoreModelKey(Dictionary <Saint.EquipSlot, ModelData> keys, Saint.Quad model, Saint.Stain stain, Saint.EquipSlot slot) { if (!model.IsEmpty) { keys[slot] = new ModelData(model, stain); } }
public static bool IsSlot(this EquipSlot self, ItemSlots slot) { return(self.ToSlot() == slot); }