Example #1
0
 public void addWeapon(Weapon _weapon)
 {
     this.element = _weapon.element;
     this.typeWeapon = _weapon.typeWeapon;
     this.damage += _weapon.damage;
     this.attributes += _weapon.attributes;
     //this.damage.addDamage(_weapon.damage);
     //this.attributes.addAttributes(_weapon.attributes);
 }
Example #2
0
 public void addWeapon(Weapon _weapon)
 {
     this.element     = _weapon.element;
     this.typeWeapon  = _weapon.typeWeapon;
     this.damage     += _weapon.damage;
     this.attributes += _weapon.attributes;
     //this.damage.addDamage(_weapon.damage);
     //this.attributes.addAttributes(_weapon.attributes);
 }
Example #3
0
        public void removeWeapon(Weapon _weapon)
        {
            this.element = _Element.Null;
            this.typeWeapon = _Weapon.Null;

            this.damage -= _weapon.damage;
            this.attributes -= _weapon.attributes;

            /*
            this.damage.removeDamage(_weapon.damage);
            this.attributes.removeAttributes(_weapon.attributes);*/
        }
Example #4
0
        public void removeWeapon(Weapon _weapon)
        {
            this.element    = _Element.Null;
            this.typeWeapon = _Weapon.Null;

            this.damage     -= _weapon.damage;
            this.attributes -= _weapon.attributes;

            /*
             * this.damage.removeDamage(_weapon.damage);
             * this.attributes.removeAttributes(_weapon.attributes);*/
        }
Example #5
0
        public Weapon(Weapon _weapon)
        {
            this.id = _weapon.id;
            this.amount = _weapon.amount;
            this.image = _weapon.image;
            this.name = _weapon.name;
            this.typeItem = _weapon.typeItem;

            this.element = _weapon.element;
            this.typeWeapon = _weapon.typeWeapon;
            this.damage = new Damage(_weapon.damage);
            this.attributes = new Attributes(_weapon.attributes);
        }
Example #6
0
        public Weapon()
        {
            this.id = 0;
            this.amount = 0;
            this.image = "";
            this.name = "";
            this.typeItem = _Item.Null;

            this.element = _Element.Null;
            this.typeWeapon = _Weapon.Null;
            this.damage = new Damage();
            this.attributes = new Attributes();
        }
Example #7
0
        public Weapon(Weapon _weapon)
        {
            this.id       = _weapon.id;
            this.amount   = _weapon.amount;
            this.image    = _weapon.image;
            this.name     = _weapon.name;
            this.typeItem = _weapon.typeItem;

            this.element    = _weapon.element;
            this.typeWeapon = _weapon.typeWeapon;
            this.damage     = new Damage(_weapon.damage);
            this.attributes = new Attributes(_weapon.attributes);
        }
Example #8
0
        public Weapon()
        {
            this.id       = 0;
            this.amount   = 0;
            this.image    = "";
            this.name     = "";
            this.typeItem = _Item.Null;

            this.element    = _Element.Null;
            this.typeWeapon = _Weapon.Null;
            this.damage     = new Damage();
            this.attributes = new Attributes();
        }
Example #9
0
        public Ability ( Ability _ability)
	    {
            this.id = _ability.id;
            this.image = _ability.image;
            this.name = _ability.name;
            this.desc = _ability.desc;
            this.cooldown = _ability.cooldown;
            this.cost = _ability.cost;
            this.damage = _ability.damage;
            this.armor = _ability.armor;
            this.attributes = _ability.attributes;
            this.effects = _ability.effects;
            this.element = _ability.element;
	    }
Example #10
0
	    public Ability()
	    {
            this.id = 0;
            this.image = "";
            this.name = "";
		    this.desc = "";
            this.cooldown = 0F;
            this.cost = 0;
		    this.damage = new Damage();
		    this.armor = new Armor();
            this.attributes = new Attributes();
            this.effects = new Effect[0];
            this.element = _Element.Null;
	    }
Example #11
0
 public Ability(Ability _ability)
 {
     this.id         = _ability.id;
     this.image      = _ability.image;
     this.name       = _ability.name;
     this.desc       = _ability.desc;
     this.cooldown   = _ability.cooldown;
     this.cost       = _ability.cost;
     this.damage     = _ability.damage;
     this.armor      = _ability.armor;
     this.attributes = _ability.attributes;
     this.effects    = _ability.effects;
     this.element    = _ability.element;
 }
Example #12
0
 public Ability()
 {
     this.id         = 0;
     this.image      = "";
     this.name       = "";
     this.desc       = "";
     this.cooldown   = 0F;
     this.cost       = 0;
     this.damage     = new Damage();
     this.armor      = new Armor();
     this.attributes = new Attributes();
     this.effects    = new Effect[0];
     this.element    = _Element.Null;
 }
        public void Add()
        {
            var l = new IntrusiveLinkedList <_Element>(5);

            Assert.Null(l.Head);
            Assert.Null(l.Tail);

            var a = new _Element("a");

            l.Add(a, 0);
            Assert.Equal(0, l.Head);
            Assert.Equal(0, l.Tail);
            Assert.Null(a.PreviousIndex);
            Assert.Null(a.NextIndex);

            var b = new _Element("b");

            l.Add(b, 1);
            Assert.Equal(0, l.Head);
            Assert.Equal(1, l.Tail);
            Assert.Null(a.PreviousIndex);
            Assert.Equal(1, a.NextIndex);
            Assert.Equal(0, b.PreviousIndex);
            Assert.Null(b.NextIndex);

            var c = new _Element("c");

            l.Add(c, 2);
            Assert.Equal(0, l.Head);
            Assert.Equal(2, l.Tail);
            Assert.Null(a.PreviousIndex);
            Assert.Equal(1, a.NextIndex);
            Assert.Equal(0, b.PreviousIndex);
            Assert.Equal(2, b.NextIndex);
            Assert.Equal(1, c.PreviousIndex);
            Assert.Null(c.NextIndex);

            var d = new _Element("d");

            l.Add(d, 3);
            Assert.Equal(0, l.Head);
            Assert.Equal(3, l.Tail);
            Assert.Null(a.PreviousIndex);
            Assert.Equal(1, a.NextIndex);
            Assert.Equal(0, b.PreviousIndex);
            Assert.Equal(2, b.NextIndex);
            Assert.Equal(1, c.PreviousIndex);
            Assert.Equal(3, c.NextIndex);
            Assert.Equal(2, d.PreviousIndex);
            Assert.Null(d.NextIndex);

            var e = new _Element("e");

            l.Add(e, 4);
            Assert.Equal(0, l.Head);
            Assert.Equal(4, l.Tail);
            Assert.Null(a.PreviousIndex);
            Assert.Equal(1, a.NextIndex);
            Assert.Equal(0, b.PreviousIndex);
            Assert.Equal(2, b.NextIndex);
            Assert.Equal(1, c.PreviousIndex);
            Assert.Equal(3, c.NextIndex);
            Assert.Equal(2, d.PreviousIndex);
            Assert.Equal(4, d.NextIndex);
            Assert.Equal(3, e.PreviousIndex);
            Assert.Null(e.NextIndex);
        }
        public void Compact()
        {
            // empty
            {
                var l = new IntrusiveLinkedList <_Element>(5);

                l.Compact(Array.Empty <int>());
                Assert.Null(l.Head);
                Assert.Null(l.Tail);
            }

            // no change
            {
                var l = new IntrusiveLinkedList <_Element>(5);
                var a = new _Element("a");
                var b = new _Element("b");
                var c = new _Element("c");
                var d = new _Element("d");
                var e = new _Element("e");
                l.Add(a, 0);
                l.Add(b, 1);
                l.Add(c, 2);
                l.Add(d, 3);
                l.Add(e, 4);

                var newMapping = new[] { 0, 1, 2, 3, 4 };
                l.Compact(newMapping);
                Assert.Equal(0, l.Head);
                Assert.Equal(4, l.Tail);

                Assert.Equal("a", l.Elements[0].Value);
                Assert.Null(a.PreviousIndex);
                Assert.Equal(1, a.NextIndex);

                Assert.Equal("b", l.Elements[1].Value);
                Assert.Equal(0, b.PreviousIndex);
                Assert.Equal(2, b.NextIndex);

                Assert.Equal("c", l.Elements[2].Value);
                Assert.Equal(1, c.PreviousIndex);
                Assert.Equal(3, c.NextIndex);

                Assert.Equal("d", l.Elements[3].Value);
                Assert.Equal(2, d.PreviousIndex);
                Assert.Equal(4, d.NextIndex);

                Assert.Equal("e", l.Elements[4].Value);
                Assert.Equal(3, e.PreviousIndex);
                Assert.Null(e.NextIndex);
            }

            // reverse
            {
                var l = new IntrusiveLinkedList <_Element>(5);
                var a = new _Element("a");
                var b = new _Element("b");
                var c = new _Element("c");
                var d = new _Element("d");
                var e = new _Element("e");
                l.Add(a, 0);
                l.Add(b, 1);
                l.Add(c, 2);
                l.Add(d, 3);
                l.Add(e, 4);

                var newMapping = new[] { 4, 3, 2, 1, 0 };
                l.Compact(newMapping);
                Assert.Equal(4, l.Head);
                Assert.Equal(0, l.Tail);

                Assert.Equal("e", l.Elements[0].Value);
                Assert.Equal(1, e.PreviousIndex);
                Assert.Null(e.NextIndex);

                Assert.Equal("d", l.Elements[1].Value);
                Assert.Equal(2, d.PreviousIndex);
                Assert.Equal(0, d.NextIndex);

                Assert.Equal("c", l.Elements[2].Value);
                Assert.Equal(3, c.PreviousIndex);
                Assert.Equal(1, c.NextIndex);

                Assert.Equal("b", l.Elements[3].Value);
                Assert.Equal(4, b.PreviousIndex);
                Assert.Equal(2, b.NextIndex);

                Assert.Equal("a", l.Elements[4].Value);
                Assert.Null(a.PreviousIndex);
                Assert.Equal(3, a.NextIndex);
            }

            // gaps
            {
                var l = new IntrusiveLinkedList <_Element>(10);
                var a = new _Element("a");
                var c = new _Element("c");
                var e = new _Element("e");

                l.Add(a, 1);
                l.Add(c, 9);
                l.Add(e, 3);

                var newMapping = new[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 2 };
                l.Compact(newMapping);

                Assert.Equal(0, l.Head);
                Assert.Equal(1, l.Tail);

                Assert.Equal("a", l.Elements[0].Value);
                Assert.Null(a.PreviousIndex);
                Assert.Equal(2, a.NextIndex);

                Assert.Equal("e", l.Elements[1].Value);
                Assert.Equal(2, e.PreviousIndex);
                Assert.Null(e.NextIndex);

                Assert.Equal("c", l.Elements[2].Value);
                Assert.Equal(0, c.PreviousIndex);
                Assert.Equal(1, c.NextIndex);
            }
        }
        public void Remove()
        {
            var l = new IntrusiveLinkedList <_Element>(5);
            var a = new _Element("a");
            var b = new _Element("b");
            var c = new _Element("c");
            var d = new _Element("d");
            var e = new _Element("e");

            l.Add(a, 0);
            l.Add(b, 1);
            l.Add(c, 2);
            l.Add(d, 3);
            l.Add(e, 4);

            // remove the head
            {
                l.Remove(0);

                // removed elements are null'd
                Assert.Null(l.Elements[0]);
                Assert.Null(a.NextIndex);
                Assert.Null(a.PreviousIndex);

                // head & tail correct
                Assert.Equal(1, l.Head);
                Assert.Equal(4, l.Tail);

                // linked list in correct order
                Assert.Null(b.PreviousIndex);
                Assert.Equal(2, b.NextIndex);
                Assert.Equal(1, c.PreviousIndex);
                Assert.Equal(3, c.NextIndex);
                Assert.Equal(2, d.PreviousIndex);
                Assert.Equal(4, d.NextIndex);
                Assert.Equal(3, e.PreviousIndex);
                Assert.Null(e.NextIndex);
            }

            // remove the tail
            {
                l.Remove(4);

                // removed elements are null'd
                Assert.Null(l.Elements[0]);
                Assert.Null(a.NextIndex);
                Assert.Null(a.PreviousIndex);
                Assert.Null(l.Elements[4]);
                Assert.Null(e.NextIndex);
                Assert.Null(e.PreviousIndex);

                // head & tail correct
                Assert.Equal(1, l.Head);
                Assert.Equal(3, l.Tail);

                // linked list in correct order
                Assert.Null(b.PreviousIndex);
                Assert.Equal(2, b.NextIndex);
                Assert.Equal(1, c.PreviousIndex);
                Assert.Equal(3, c.NextIndex);
                Assert.Equal(2, d.PreviousIndex);
                Assert.Null(d.NextIndex);
            }

            // remove in middle
            {
                l.Remove(2);

                // removed elements are null'd
                Assert.Null(l.Elements[0]);
                Assert.Null(a.NextIndex);
                Assert.Null(a.PreviousIndex);
                Assert.Null(l.Elements[2]);
                Assert.Null(c.NextIndex);
                Assert.Null(c.PreviousIndex);
                Assert.Null(l.Elements[4]);
                Assert.Null(e.NextIndex);
                Assert.Null(e.PreviousIndex);

                // head & tail correct
                Assert.Equal(1, l.Head);
                Assert.Equal(3, l.Tail);

                // linked list in correct order
                Assert.Null(b.PreviousIndex);
                Assert.Equal(3, b.NextIndex);
                Assert.Equal(1, d.PreviousIndex);
                Assert.Null(d.NextIndex);
            }

            // remove rest
            {
                l.Remove(1);

                // removed elements are null'd
                Assert.Null(l.Elements[0]);
                Assert.Null(a.NextIndex);
                Assert.Null(a.PreviousIndex);
                Assert.Null(l.Elements[1]);
                Assert.Null(b.NextIndex);
                Assert.Null(b.PreviousIndex);
                Assert.Null(l.Elements[2]);
                Assert.Null(c.NextIndex);
                Assert.Null(c.PreviousIndex);
                Assert.Null(l.Elements[4]);
                Assert.Null(e.NextIndex);
                Assert.Null(e.PreviousIndex);

                // head & tail correct
                Assert.Equal(3, l.Head);
                Assert.Equal(3, l.Tail);

                // linked list in correct order
                Assert.Null(d.PreviousIndex);
                Assert.Null(d.NextIndex);

                l.Remove(3);

                // removed elements are null'd
                Assert.Null(l.Elements[0]);
                Assert.Null(a.NextIndex);
                Assert.Null(a.PreviousIndex);
                Assert.Null(l.Elements[1]);
                Assert.Null(b.NextIndex);
                Assert.Null(b.PreviousIndex);
                Assert.Null(l.Elements[2]);
                Assert.Null(c.NextIndex);
                Assert.Null(c.PreviousIndex);
                Assert.Null(l.Elements[3]);
                Assert.Null(d.NextIndex);
                Assert.Null(d.PreviousIndex);
                Assert.Null(l.Elements[4]);
                Assert.Null(e.NextIndex);
                Assert.Null(e.PreviousIndex);

                // head & tail correct
                Assert.Null(l.Head);
                Assert.Null(l.Tail);
            }
        }