예제 #1
0
            private void _reload()
            {
                if (_skillDbTuple != null)
                {
                    Name = _skillDbTuple.GetStringValue(ServerSkillAttributes.Desc.Index);

                    if (String.IsNullOrEmpty(Name))
                    {
                        Name = _skillDbTuple.Key.ToString(CultureInfo.InvariantCulture);
                    }
                }

                if (_mobSkillDbTuple != null)
                {
                    int    icondition = _mobSkillDbTuple.GetValue <int>(ServerMobSkillAttributes.ConditionType);
                    string condition  = Enum.GetValues(typeof(ConditionType)).Cast <Enum>().Select(Description.GetDescription).ToList()[icondition];

                    Condition = condition.
                                Replace("[CValue]", _mobSkillDbTuple.GetStringValue(ServerMobSkillAttributes.ConditionValue.Index)).
                                Replace("[Val1]", _mobSkillDbTuple.GetStringValue(ServerMobSkillAttributes.Val1.Index));

                    if (String.IsNullOrEmpty(Name))
                    {
                        Name = "#Not found - " + _mobSkillDbTuple.GetIntNoThrow(ServerMobSkillAttributes.SkillId);
                    }
                }

                if (String.IsNullOrEmpty(Name))
                {
                    Name = "#Invalid ID";
                }
            }
예제 #2
0
        private void _miPaste_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (_tab.List.SelectedItem == null)
                {
                    return;
                }
                if (!Clipboard.ContainsText())
                {
                    return;
                }

                ReadableTuple <int> tuple = (ReadableTuple <int>)_tab.List.SelectedItem;
                string        text        = Clipboard.GetText();
                StringBuilder builder     = new StringBuilder();
                string        sid         = tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture);
                string        name        = tuple.GetStringValue(ServerMobAttributes.KRoName.Index);

                foreach (string line in text.Replace("\r", "").Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    string[] args = line.Split(',');

                    if (args.Length < 5)
                    {
                        throw new Exception("Not enough arguments to parse the lines (invalid clipboard data).");
                    }

                    builder.AppendLine(String.Join(",", new string[] { sid, name + "@" + args[1].Split('@')[1] }.Concat(args.Skip(2)).ToArray()));
                }

                string tempPath = TemporaryFilesManager.GetTemporaryFilePath("db_tmp_{0:0000}.txt");
                File.WriteAllText(tempPath, builder.ToString());

                AbstractDb <string> db;
                var isEnabled = _tab.GetDb <string>(ServerDbs.MobSkills2).IsEnabled;

                if (_tab.Settings.DbData == ServerDbs.Mobs || !isEnabled)
                {
                    db = _tab.GetDb <string>(ServerDbs.MobSkills);
                }
                else
                {
                    db = _tab.GetDb <string>(ServerDbs.MobSkills2);
                }

                var table = db.Table;

                try {
                    table.Commands.Begin();
                    db.LoadFromClipboard(tempPath);
                }
                catch {
                    table.Commands.CancelEdit();
                }
                finally {
                    table.Commands.EndEdit();
                    _tab.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
예제 #3
0
        public GroupCommand <TKey, ReadableTuple <TKey> > Generate <TKey>(ReadableTuple <TKey> item, ReadableTuple <int> tupleSource, AbstractDb <int> mobDb1, AbstractDb <int> mobDb2, AbstractDb <int> pet1, AbstractDb <int> pet2)
        {
            var description = item.GetValue <ParameterHolder>(ClientItemAttributes.Parameters).Values[ParameterHolderKeys.Description] ?? "";

            description = ParameterHolder.ClearDescription(description);

            ParameterHolder holder = new ParameterHolder();
            GroupCommand <TKey, ReadableTuple <TKey> > commands = GroupCommand <TKey, ReadableTuple <TKey> > .Make();

            int numSlotC = _getInt(ClientItemAttributes.NumberOfSlots, item);
            int numSlotS = _getInt(ServerItemAttributes.NumberOfSlots, tupleSource);

            if (ProjectConfiguration.AutocompleteViewId)
            {
                int viewIdC = _getInt(ClientItemAttributes.ClassNumber, item);
                int viewIdS = _getInt(ServerItemAttributes.ClassNumber, tupleSource);

                if (viewIdC != viewIdS)
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.ClassNumber, viewIdS));
                }
            }

            if (ProjectConfiguration.AutocompleteNumberOfSlot)
            {
                if (numSlotC != numSlotS)
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.NumberOfSlots, numSlotS));
                }
            }

            if ((TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type) != TypeType.Card)
            {
                if (item.GetValue <bool>(ClientItemAttributes.IsCard))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, false));
                }
            }

            string idDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name);

            if (_emptyFill(ClientItemAttributes.IdentifiedDisplayName, item) && ProjectConfiguration.AutocompleteIdDisplayName && _isNotNullDifferent(idDisplayName, ClientItemAttributes.IdentifiedDisplayName, item))
            {
                commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDisplayName, idDisplayName));
            }

            DbAttribute attribute;
            TypeType    itemType = (TypeType)tupleSource.GetValue <int>(ServerItemAttributes.Type);

            if (itemType == TypeType.Weapon || itemType == TypeType.Armor)
            {
                if (itemType == TypeType.Armor && !ItemParser.IsArmorType(tupleSource))
                {
                    if (itemType == TypeType.Armor)
                    {
                        itemType = TypeType.Weapon;
                    }
                    else
                    {
                        itemType = TypeType.Armor;
                    }
                }
            }

            // Weight:
            //holder = item.GetValue<ParameterHolder>(ClientItemAttributes.Parameters);
            //
            //switch (itemType) {
            //	case TypeType.Weapon:
            //	case TypeType.Ammo:
            //	case TypeType.Armor:
            //	case TypeType.Card:
            //	case TypeType.PetEgg:
            //	case TypeType.PetEquip:
            //	case TypeType.UsableItem:
            //	case TypeType.EtcItem:
            //	case TypeType.HealingItem:
            //	case TypeType.ShadowEquip:
            //	case TypeType.UsableWithDelayed:
            //	case TypeType.UsableWithDelayed2:
            //		_autoAddWeight(tupleSource, holder);
            //		break;
            //}

            DbAttribute equipLevelAttribute = ServerItemAttributes.EquipLevel;

            if (tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevelMin) > tupleSource.GetIntNoThrow(ServerItemAttributes.EquipLevel))
            {
                equipLevelAttribute = ServerItemAttributes.EquipLevelMin;
            }

            switch (itemType)
            {
            case TypeType.Weapon:
                string type = _findWeaponType(tupleSource) ?? "Weapon";
                holder.Values[ParameterHolderKeys.Class] = type;

                string unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findWeaponUnidentifiedResource(tupleSource) ?? "");
                attribute = ClientItemAttributes.UnidentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }

                string identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index);
                attribute = ClientItemAttributes.IdentifiedResourceName;
                if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }

                attribute = ClientItemAttributes.UnidentifiedDisplayName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(type, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, type));
                }

                if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable))
                {
                    if (!description.Contains("Impossible to refine") &&
                        !description.Contains("Cannot be upgraded") &&
                        !description.ToLower().Contains("rental item"))
                    {
                        description += "\r\nImpossible to refine this item.";
                    }
                }

                if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable))
                {
                    if (description.Contains("Impossible to refine"))
                    {
                        description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n');
                    }
                }

                _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder);
                _autoAddWeight(tupleSource, holder);
                _autoAdd(ServerItemAttributes.WeaponLevel, ParameterHolderKeys.WeaponLevel, tupleSource, holder);
                _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource));
                _autoAddElement(tupleSource, holder);
                break;

            case TypeType.Ammo:
                type = _findAmmoType(tupleSource.GetStringValue(ServerItemAttributes.ApplicableJob.Index)) ?? "Ammunition";
                holder.Values[ParameterHolderKeys.Class] = type;

                _autoAdd(ServerItemAttributes.Attack, ParameterHolderKeys.Attack, tupleSource, holder, -1);
                _autoAddWeight(tupleSource, holder);
                _autoAddElement(tupleSource, holder);
                break;

            case TypeType.Armor:
                int location = _getInt(ServerItemAttributes.Location, tupleSource);
                type = _findArmorType(location) ?? "Armor";
                holder.Values[ParameterHolderKeys.Class] = type;

                unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(_findArmorUnidentifiedResource(tupleSource, item) ?? "");
                attribute = ClientItemAttributes.UnidentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }
                else
                {
                    unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName);
                }

                identifiedResourceName = item.GetStringValue(ClientItemAttributes.IdentifiedResourceName.Index);
                attribute = ClientItemAttributes.IdentifiedResourceName;
                if (String.IsNullOrEmpty(identifiedResourceName) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }

                string unDisplayName = _findArmorUnidentifiedDisplayName(unidentifiedResourceName);
                attribute = ClientItemAttributes.UnidentifiedDisplayName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName));
                }

                if ((_getInt(ServerItemAttributes.Location, tupleSource) & 374) != 0)
                {
                    if (!tupleSource.GetValue <bool>(ServerItemAttributes.Refineable))
                    {
                        if (!description.Contains("Impossible to refine"))
                        {
                            description += "\r\nImpossible to refine this item.";
                        }
                    }

                    if (tupleSource.GetValue <bool>(ServerItemAttributes.Refineable))
                    {
                        if (description.Contains("Impossible to refine"))
                        {
                            description = description.Replace("Impossible to refine this item.", "").Trim('\r', '\n');
                        }
                    }
                }

                _autoAdd(ServerItemAttributes.Defense, ParameterHolderKeys.Defense, tupleSource, holder);
                _autoAddEquippedOn(ServerItemAttributes.Location, ParameterHolderKeys.Location, tupleSource, holder);
                _autoAddWeight(tupleSource, holder);
                _autoAddJob(tupleSource, holder, _getInt(equipLevelAttribute, tupleSource));
                break;

            case TypeType.Card:
                holder.Values[ParameterHolderKeys.Class] = "Card";
                _autoAddCompound(ServerItemAttributes.Location, ParameterHolderKeys.CompoundOn, tupleSource, holder);
                _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1);
                _autoAddWeight(tupleSource, holder);

                if (!item.GetValue <bool>(ClientItemAttributes.IsCard))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IsCard, true));
                }

                if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Illustration)))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Illustration, "sorry"));
                }

                if (String.IsNullOrEmpty(item.GetValue <string>(ClientItemAttributes.Affix)))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.Affix, tupleSource.GetValue <string>(ServerItemAttributes.Name)));
                }

                const string CardResource = "À̸§¾ø´ÂÄ«µå";

                unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name);
                attribute     = ClientItemAttributes.UnidentifiedDisplayName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName));
                }

                unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding(CardResource);
                attribute = ClientItemAttributes.UnidentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }

                attribute = ClientItemAttributes.IdentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }
                break;

            case TypeType.PetEgg:
                holder.Values[ParameterHolderKeys.Class] = "Monster Egg";
                _autoAddWeight(tupleSource, holder);
                break;

            case TypeType.PetEquip:
                holder.Values[ParameterHolderKeys.Class] = "Cute Pet Armor";
                _autoAddWeight(tupleSource, holder);

                int id = item.GetKey <int>();

                List <ReadableTuple <int> > tuples = pet1.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value).Concat(
                    pet2.Table.Tuples.Where(p => p.Value.GetValue <int>(ServerPetAttributes.EquipId) == id).Select(p => p.Value)
                    ).ToList();

                if (tuples.Count > 0)
                {
                    // Try to retrieve the names
                    List <string> values = new List <string>();

                    foreach (ReadableTuple <int> tuple in tuples)
                    {
                        var pid = tuple.GetKey <int>();

                        var pTuple = mobDb2.Table.TryGetTuple(pid) ?? mobDb1.Table.TryGetTuple(pid);

                        if (pTuple != null)
                        {
                            values.Add(pTuple.GetValue <string>(ServerMobAttributes.KRoName));
                        }
                    }

                    if (values.Count > 0)
                    {
                        holder.Values[ParameterHolderKeys.ApplicablePet] = String.Join(", ", values.ToArray());
                    }
                }
                break;

            case TypeType.UsableItem:
                _autoAddPet(tupleSource, holder);
                _autoAddWeight(tupleSource, holder);
                _autoAddJobIfRestricted(tupleSource, holder);
                break;

            case TypeType.EtcItem:
            case TypeType.HealingItem:
            case TypeType.ShadowEquip:
            case TypeType.UsableWithDelayed:
            case TypeType.UsableWithDelayed2:
                _autoAddWeight(tupleSource, holder);
                _autoAddJobIfRestricted(tupleSource, holder);
                break;
            }

            _autoAdd(equipLevelAttribute, ParameterHolderKeys.RequiredLevel, tupleSource, holder, 1);

            holder.Values[ParameterHolderKeys.Description] = description == "" ? ProjectConfiguration.AutocompleteDescNotSet : description;

            var idDescription = holder.GenerateDescription();

            if (ProjectConfiguration.AutocompleteIdDescription)
            {
                if (idDescription != item.GetValue <string>(ClientItemAttributes.IdentifiedDescription))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.IdentifiedDescription, idDescription));
                }
            }

            var unDescription = item.GetValue <string>(ClientItemAttributes.UnidentifiedDescription);

            // unidentified
            switch (tupleSource.GetValue <TypeType>(ServerItemAttributes.Type))
            {
            case TypeType.Ammo:
            case TypeType.EtcItem:
            case TypeType.HealingItem:
            case TypeType.PetEgg:
            case TypeType.UsableItem:
            case TypeType.UsableWithDelayed:
            case TypeType.UsableWithDelayed2:
                if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription)
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription));
                }

                string unDisplayName = tupleSource.GetValue <string>(ServerItemAttributes.Name);
                attribute = ClientItemAttributes.UnidentifiedDisplayName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnDisplayName && _isNotNullDifferent(unDisplayName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unDisplayName));
                }

                string unidentifiedResourceName = item.GetValue <string>(ClientItemAttributes.IdentifiedResourceName);
                if (String.IsNullOrEmpty(unidentifiedResourceName))
                {
                    unidentifiedResourceName = EncodingService.FromAnyToDisplayEncoding("Á¶°¢ÄÉÀÌÅ©");                             // Cake
                }

                attribute = ClientItemAttributes.UnidentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteUnResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }

                attribute = ClientItemAttributes.IdentifiedResourceName;
                if (_emptyFill(attribute, item) && ProjectConfiguration.AutocompleteIdResourceName && _isNotNullDifferent(unidentifiedResourceName, attribute, item))
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, attribute, unidentifiedResourceName));
                }
                break;

            case TypeType.Card:
                if (ProjectConfiguration.AutocompleteUnDescription && unDescription != idDescription)
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, idDescription));
                }
                break;

            default:
                if (ProjectConfiguration.AutocompleteUnDescription && unDescription != ProjectConfiguration.AutocompleteUnDescriptionFormat)
                {
                    commands.Add(new ChangeTupleProperty <TKey, ReadableTuple <TKey> >(item, ClientItemAttributes.UnidentifiedDescription, ProjectConfiguration.AutocompleteUnDescriptionFormat));
                }
                break;
            }

            if (commands.Commands.Count == 0)
            {
                return(null);
            }

            return(commands);
        }