Beispiel #1
0
        private static void GivePlayerSoulboundItemWithRune(Player player, int offset, GameModeStatics.GameModes mode, out Item item, out Item rune)
        {
            var formerPlayer = new PlayerBuilder()
                               .With(p => p.User, new UserBuilder()
                                     .With(u => u.Id, "former")
                                     .BuildAndSave()
                                     )
                               .With(p => p.Id, 100 + offset)
                               .BuildAndSave();

            item = new ItemBuilder()
                   .With(i => i.Id, 500 + offset)
                   .With(i => i.FormerPlayer, formerPlayer)
                   .With(i => i.PvPEnabled, (int)mode)
                   .BuildAndSave();

            rune = new ItemBuilder()
                   .With(i => i.Id, 600 + offset)
                   .With(i => i.PvPEnabled, (int)mode)
                   .With(i => i.ItemSource, new ItemSourceBuilder()
                         .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                         .BuildAndSave())
                   .BuildAndSave();

            item.SoulbindToPlayer(player);
            item.AttachRune(rune);
        }
Beispiel #2
0
        public void player_should_drop_all_items()
        {
            var player = new PlayerBuilder()
                         .With(p => p.Id, 50)
                         .BuildAndSave();

            var runeItem = new ItemBuilder()
                           .With(i => i.Id, 1)
                           .With(i => i.IsEquipped, false)
                           .With(i => i.Owner, player)
                           .With(i => i.ItemSource, new ItemSourceBuilder()
                                 .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                                 .BuildAndSave()
                                 )
                           .BuildAndSave();

            var nonRuneItem = new ItemBuilder()
                              .With(i => i.Id, 2)
                              .With(i => i.IsEquipped, false)
                              .With(i => i.Owner, player)
                              .With(i => i.ItemSource, new ItemSourceBuilder()
                                    .With(i => i.ItemType, PvPStatics.ItemType_Hat)
                                    .BuildAndSave()
                                    )
                              .BuildAndSave();

            var embeddedRune = new ItemBuilder()
                               .With(i => i.Id, 3)
                               .With(i => i.IsEquipped, false)
                               .With(i => i.Owner, player)
                               .With(i => i.ItemSource, new ItemSourceBuilder()
                                     .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                                     .BuildAndSave()
                                     )
                               .With(i => i.EmbeddedOnItem, nonRuneItem)
                               .BuildAndSave();

            nonRuneItem.AttachRune(embeddedRune);

            player.Items.Add(runeItem);
            player.Items.Add(nonRuneItem);

            player.DropAllItems();

            Assert.That(runeItem.Owner, Is.Null);
            Assert.That(runeItem.IsEquipped, Is.False);
            Assert.That(runeItem.dbLocationName, Is.EqualTo("street_70e9th"));

            Assert.That(nonRuneItem.Owner, Is.Null);
            Assert.That(nonRuneItem.IsEquipped, Is.False);
            Assert.That(nonRuneItem.dbLocationName, Is.EqualTo("street_70e9th"));

            Assert.That(embeddedRune.Owner, Is.Null);
            Assert.That(embeddedRune.dbLocationName, Is.Empty);
            Assert.That(embeddedRune.EmbeddedOnItem, Is.EqualTo(nonRuneItem));
        }
Beispiel #3
0
        public void Drop_attached_runes_stay_on_objects()
        {
            var owner = new PlayerBuilder()
                        .With(p => p.Location, "somewhere")
                        .With(p => p.BotId, AIStatics.PsychopathBotId)
                        .BuildAndSave();

            var item = new ItemBuilder()
                       .With(i => i.Id, 100)
                       .With(i => i.IsEquipped, false)
                       .With(i => i.Owner, owner)
                       .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8))
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Shirt)
                             .BuildAndSave())
                       .BuildAndSave();

            var rune = new ItemBuilder()
                       .With(i => i.IsEquipped, true)
                       .With(i => i.Owner, owner)
                       .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8))
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                             .BuildAndSave())
                       .BuildAndSave();

            var unembeddedRune = new ItemBuilder()
                                 .With(i => i.IsEquipped, false)
                                 .With(i => i.Owner, owner)
                                 .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8))
                                 .With(i => i.ItemSource, new ItemSourceBuilder()
                                       .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                                       .BuildAndSave())
                                 .BuildAndSave();

            item.AttachRune(rune);

            item.Drop(owner);

            Assert.That(item.IsEquipped, Is.False);
            Assert.That(item.Owner, Is.Null);
            Assert.That(item.Runes, Has.Exactly(1).Items);
            Assert.That(item.dbLocationName, Is.EqualTo(owner.Location));
            Assert.That(item.TimeDropped, Is.EqualTo(DateTime.UtcNow).Within(1).Minutes);

            Assert.That(rune.IsEquipped, Is.True);
            Assert.That(rune.EmbeddedOnItem.Id, Is.EqualTo(item.Id));

            unembeddedRune.Drop(owner);

            Assert.That(unembeddedRune.IsEquipped, Is.False);
            Assert.That(unembeddedRune.Owner, Is.Null);
            Assert.That(unembeddedRune.dbLocationName, Is.EqualTo(owner.Location));
            Assert.That(unembeddedRune.EmbeddedOnItem, Is.Null);
            Assert.That(unembeddedRune.TimeDropped, Is.EqualTo(DateTime.UtcNow).Within(1).Minutes);
        }
Beispiel #4
0
        public void can_unembed_runes_on_owned_items()
        {
            var owner = new PlayerBuilder()
                        .With(i => i.Id, 1010)
                        .With(i => i.Location, "somewhere")
                        .BuildAndSave();

            var ownedItem = new ItemBuilder()
                            .With(i => i.Id, 600)
                            .With(i => i.Level, 1)
                            .With(i => i.Owner, owner)
                            .With(i => i.dbLocationName, String.Empty)
                            .With(i => i.ItemSource, new ItemSourceBuilder()
                                  .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                                  .BuildAndSave()
                                  ).BuildAndSave();

            var rune2 = new ItemBuilder()
                        .With(i => i.Id, 1000)
                        .With(i => i.IsEquipped, false)
                        .With(i => i.ItemSource, new ItemSourceBuilder()
                              .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                              .BuildAndSave())
                        .BuildAndSave();

            ownedItem.AttachRune(rune);
            ownedItem.AttachRune(rune2);

            owner.GiveItem(ownedItem);

            ownedItem.RemoveRunes();
            Assert.That(ownedItem.Runes, Is.Empty);

            Assert.That(rune.EmbeddedOnItem, Is.Null);
            Assert.That(rune.IsEquipped, Is.False);
            Assert.That(rune.Owner.Id, Is.EqualTo(owner.Id));
            Assert.That(rune.dbLocationName, Is.Empty);

            Assert.That(rune2.EmbeddedOnItem, Is.Null);
            Assert.That(rune2.IsEquipped, Is.False);
            Assert.That(rune2.Owner.Id, Is.EqualTo(owner.Id));
            Assert.That(rune2.dbLocationName, Is.Empty);
        }
Beispiel #5
0
        public void can_only_attach_two_runes_for_pets()
        {
            var rune2 = new ItemBuilder()
                        .With(i => i.ItemSource, new ItemSourceBuilder()
                              .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                              .BuildAndSave())
                        .BuildAndSave();

            var item = new ItemBuilder()
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                             .BuildAndSave()
                             ).BuildAndSave();

            Assert.That(item.HasRoomForRunes(), Is.True);
            item.AttachRune(rune);
            Assert.That(item.HasRoomForRunes(), Is.True);
            item.AttachRune(rune2);
            Assert.That(item.HasRoomForRunes(), Is.False);
        }
Beispiel #6
0
        public void can_only_attach_one_rune_for_most_items()
        {
            var item = new ItemBuilder()
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Shoes)
                             .BuildAndSave()
                             ).BuildAndSave();

            Assert.That(item.HasRoomForRunes(), Is.True);
            item.AttachRune(rune);
            Assert.That(item.HasRoomForRunes(), Is.False);
        }
Beispiel #7
0
        public void can_unembed_runes_on_unowned_items()
        {
            var unownedItem = new ItemBuilder()
                              .With(i => i.Id, 600)
                              .With(i => i.Level, 1)
                              .With(i => i.Owner, null)
                              .With(i => i.dbLocationName, "somewhere")
                              .With(i => i.ItemSource, new ItemSourceBuilder()
                                    .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                                    .BuildAndSave()
                                    ).BuildAndSave();

            var rune2 = new ItemBuilder()
                        .With(i => i.Id, 1000)
                        .With(i => i.IsEquipped, false)
                        .With(i => i.ItemSource, new ItemSourceBuilder()
                              .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                              .BuildAndSave())
                        .BuildAndSave();

            unownedItem.AttachRune(rune);
            unownedItem.AttachRune(rune2);

            unownedItem.RemoveRunes();
            Assert.That(unownedItem.Runes, Is.Empty);

            Assert.That(rune.EmbeddedOnItem, Is.Null);
            Assert.That(rune.IsEquipped, Is.False);
            Assert.That(rune.Owner, Is.Null);
            Assert.That(rune.dbLocationName, Is.EqualTo("somewhere"));
            Assert.That(rune.EquippedThisTurn, Is.True);

            Assert.That(rune2.EmbeddedOnItem, Is.Null);
            Assert.That(rune2.IsEquipped, Is.False);
            Assert.That(rune2.Owner, Is.Null);
            Assert.That(rune2.dbLocationName, Is.EqualTo("somewhere"));
            Assert.That(rune2.EquippedThisTurn, Is.True);
        }
Beispiel #8
0
        public void GetCurrentCarryWeight_returns_correct_weight_for_runes()
        {
            var player = new PlayerBuilder()
                         .With(p => p.Id, 50)
                         .BuildAndSave();

            var shirt = new ItemBuilder()
                        .With(i => i.Owner.Id, 50)
                        .With(i => i.ItemSource, new ItemSourceBuilder()
                              .With(i => i.ItemType, PvPStatics.ItemType_Shirt)
                              .BuildAndSave()
                              ).With(i => i.IsEquipped, true)
                        .BuildAndSave();

            var pants = new ItemBuilder()
                        .With(i => i.Owner.Id, 50)
                        .With(i => i.ItemSource, new ItemSourceBuilder()
                              .With(i => i.ItemType, PvPStatics.ItemType_Pants)
                              .BuildAndSave()
                              ).With(i => i.IsEquipped, false)
                        .BuildAndSave();

            var runeOnWornItem = new ItemBuilder()
                                 .With(i => i.Owner.Id, 50)
                                 .With(i => i.ItemSource, new ItemSourceBuilder()
                                       .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                                       .BuildAndSave()
                                       ).With(i => i.IsEquipped, false)
                                 .BuildAndSave();

            var runeOnCarriedItem = new ItemBuilder()
                                    .With(i => i.Owner.Id, 50)
                                    .With(i => i.ItemSource, new ItemSourceBuilder()
                                          .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                                          .BuildAndSave()
                                          ).With(i => i.IsEquipped, false)
                                    .BuildAndSave();

            shirt.AttachRune(runeOnWornItem);
            pants.AttachRune(runeOnCarriedItem);

            player.Items.Add(shirt);
            player.Items.Add(pants);

            Assert.That(player.GetCurrentCarryWeight(), Is.EqualTo(1));
        }
Beispiel #9
0
        public void ChangeOwner_transfers_runes()
        {
            var oldOwner = new PlayerBuilder()
                           .With(p => p.Id, 1)
                           .With(p => p.Location, "somewhere")
                           .BuildAndSave();

            var newOwner = new PlayerBuilder()
                           .With(p => p.Id, 1)
                           .With(p => p.Location, "somewhere")
                           .BuildAndSave();

            var item = new ItemBuilder()
                       .With(i => i.Id, 100)
                       .With(i => i.IsEquipped, false)
                       .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8))
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Shirt)
                             .BuildAndSave())
                       .BuildAndSave();

            var rune = new ItemBuilder()
                       .With(i => i.IsEquipped, true)
                       .With(i => i.Owner, oldOwner)
                       .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8))
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                             .BuildAndSave())
                       .BuildAndSave();

            item.AttachRune(rune);

            oldOwner.GiveItem(item);

            item.ChangeOwner(newOwner);

            Assert.That(item.Owner.Id, Is.EqualTo(newOwner.Id));
            Assert.That(item.Runes, Has.Exactly(1).Items);
            Assert.That(item.TimeDropped, Is.EqualTo(DateTime.UtcNow).Within(1).Minutes);

            Assert.That(rune.EmbeddedOnItem.Id, Is.EqualTo(100));
            Assert.That(rune.IsEquipped, Is.True);
        }
Beispiel #10
0
        public void can_equip_rune()
        {
            var item = new ItemBuilder()
                       .With(i => i.Id, 600)
                       .With(i => i.Level, 10)
                       .With(i => i.Owner, owner)
                       .With(i => i.ItemSource, new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                             .BuildAndSave()
                             ).BuildAndSave();

            item.AttachRune(rune);

            Assert.That(item.Runes, Has.Exactly(1).Items);
            Assert.That(item.Runes.First().ItemSource.FriendlyName, Is.EqualTo("Rune of Mana"));

            Assert.That(rune.EmbeddedOnItem.Id, Is.EqualTo(item.Id));
            Assert.That(rune.Owner, Is.Null);
            Assert.That(rune.EquippedThisTurn, Is.EqualTo(true));
        }
Beispiel #11
0
        private static void GivePlayerItemWithRune(Player player, int offset, GameModeStatics.GameModes mode,
                                                   out Item item, out Item rune)
        {
            item = new ItemBuilder()
                   .With(i => i.Id, 500 + offset)
                   .With(i => i.PvPEnabled, (int)mode)
                   .BuildAndSave();

            rune = new ItemBuilder()
                   .With(i => i.Id, 200 + offset)
                   .With(i => i.PvPEnabled, (int)mode)
                   .With(i => i.ItemSource, new ItemSourceBuilder()
                         .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                         .BuildAndSave()
                         )
                   .BuildAndSave();

            item.AttachRune(rune);
            player.GiveItem(item);
        }