Пример #1
0
        public CharProperty remove_property(List <string> path)
        {
            CharDictProperty dict_prop = this.properties;
            int i;

            for (i = 0; i < path.Count - 1; i++)
            {
                if (!dict_prop.value.ContainsKey(path[i]))
                {
                    throw new ArgumentOutOfRangeException(nameof(path));
                }
                dict_prop = dict_prop.value[path[i]] as CharDictProperty;
                if (dict_prop is null)
                {
                    throw new ArgumentOutOfRangeException(nameof(path));
                }
            }
            if (!dict_prop.value.ContainsKey(path[i]))
            {
                throw new ArgumentOutOfRangeException(nameof(path));
            }

            CharProperty result = dict_prop.value[path[i]];

            dict_prop.value.Remove(path[i]);

            return(result);
        }
Пример #2
0
 public override bool equals(CharProperty prop)
 {
     if (prop is CharNumProperty num_prop)
     {
         return(num_prop.value == this.value);
     }
     return(false);
 }
Пример #3
0
 public override bool equals(CharProperty prop)
 {
     if (prop is CharTextProperty text_prop)
     {
         return(text_prop.value == this.value);
     }
     return(false);
 }
Пример #4
0
        public override void subtract(CharProperty prop)
        {
            CharNumProperty p = prop as CharNumProperty;

            if (p is null)
            {
                throw new ArgumentOutOfRangeException(nameof(prop));
            }
            this.value -= p.value;
        }
Пример #5
0
        public override void subtract(CharProperty prop)
        {
            CharTextProperty p = prop as CharTextProperty;

            if (p is null)
            {
                throw new ArgumentOutOfRangeException(nameof(prop));
            }
            this.value = this.value.Replace(p.value, "");
        }
Пример #6
0
        public override void add(CharProperty prop)
        {
            CharTextProperty p = prop as CharTextProperty;

            if (p is null)
            {
                throw new ArgumentOutOfRangeException(nameof(prop));
            }
            this.value += p.value;
        }
Пример #7
0
        public override void add(CharProperty prop)
        {
            CharDictProperty p = prop as CharDictProperty;

            if (p is null)
            {
                throw new ArgumentOutOfRangeException(nameof(prop));
            }
            foreach (string k in p.value.Keys)
            {
                this.value[k] = p.value[k].copy();
            }
        }
Пример #8
0
        public override void subtract(CharProperty prop)
        {
            CharDictProperty p = prop as CharDictProperty;

            if (p is null)
            {
                throw new ArgumentOutOfRangeException(nameof(prop));
            }
            foreach (string k in p.value.Keys)
            {
                this.value.Remove(k);
            }
        }
Пример #9
0
        public CharProperty get_property(List <string> path)
        {
            CharProperty prop = this.properties;

            foreach (string s in path)
            {
                if (prop is not CharDictProperty dict_prop)
                {
                    throw new ArgumentOutOfRangeException(nameof(path));
                }
                if (!dict_prop.value.ContainsKey(s))
                {
                    throw new ArgumentOutOfRangeException(nameof(path));
                }
                prop = dict_prop.value[s];
            }
            return(prop);
        }
Пример #10
0
 public override bool equals(CharProperty prop)
 {
     if (prop is CharDictProperty dict_prop)
     {
         if (dict_prop.value.Count != this.value.Count)
         {
             return(false);
         }
         foreach (string k in this.value.Keys)
         {
             if ((!dict_prop.value.ContainsKey(k)) || (!this.value[k].equals(dict_prop.value[k])))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
Пример #11
0
 public override bool equals(CharProperty prop)
 {
     if (prop is CharSetProperty set_prop)
     {
         if (set_prop.value.Count != this.value.Count)
         {
             return(false);
         }
         foreach (string s in this.value)
         {
             if (!set_prop.value.Contains(s))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
Пример #12
0
 public override void merge_to(List <EntryAction> actions)
 {
     for (int i = actions.Count - 1; i >= 0; i--)
     {
         if (actions[i] is ActionCharacterSet ext_char_set)
         {
             if (ext_char_set.guid != this.guid)
             {
                 continue;
             }
             // existing ActionCharacterSet with this guid
             if ((ext_char_set.from is null) && (this.to is null))
             {
                 // we're deleting character; remove action creating it and we're done
                 actions.RemoveAt(i);
             }
             else
             {
                 // we're creating or updating character; update existing action's "to" field to match ours and we're done
                 actions[i] = new ActionCharacterSet(this.guid, ext_char_set.from, this.to, ext_char_set.restore);
             }
             return;
         }
         if (actions[i] is ActionCharacterPropertySet ext_prop_set)
         {
             if (ext_prop_set.guid != this.guid)
             {
                 continue;
             }
             // existing ActionCharacterPropertySet with this guid; delete it and update our "from" field
             if (ext_prop_set.from is null)
             {
                 this.from.remove_property(ext_prop_set.path);
             }
             else
             {
                 this.from.set_property(ext_prop_set.path, ext_prop_set.from);
             }
             actions.RemoveAt(i);
             continue;
         }
         if (actions[i] is ActionCharacterPropertyAdjust ext_prop_adj)
         {
             if ((ext_prop_adj.guids is null) || (ext_prop_adj.guids.Count != 1) || (!ext_prop_adj.guids.Contains(this.guid)))
             {
                 continue;
             }
             // existing ActionCharacterPropertyAdjust with this guid; delete it and update our "from" field
             CharProperty prop = this.from.get_property(ext_prop_adj.path);
             if (ext_prop_adj.add is not null)
             {
                 prop.subtract(ext_prop_adj.add);
             }
             if (ext_prop_adj.subtract is not null)
             {
                 prop.add(ext_prop_adj.subtract);
             }
             actions.RemoveAt(i);
             continue;
         }
         if (actions[i] is ActionCharacterSetInventory ext_set_inv)
         {
             if ((ext_set_inv.guid != this.guid) || (this.to is not null))
             {
                 continue;
             }
             // existing ActionCharacterSetInventory with this guid and we're deleting the character; delete the inventory set action
             actions.RemoveAt(i);
             continue;
         }
     }
Пример #13
0
 public abstract void subtract(CharProperty prop);
Пример #14
0
 public abstract void add(CharProperty prop);
Пример #15
0
 public abstract bool equals(CharProperty prop);