public void pets_automatically_equipped_to_new_owner_when_owner_has_no_existing_pet()
        {
            var petItemSource = new ItemSourceBuilder()
                                .With(i => i.Id, 1000)
                                .With(i => i.FriendlyName, "Squeaky Pet")
                                .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                                .BuildAndSave();

            var petFormSource = new FormSourceBuilder()
                                .With(i => i.Id, 870)
                                .With(i => i.MobilityType, PvPStatics.MobilityPet)
                                .With(i => i.ItemSource, petItemSource)
                                .BuildAndSave();


            var cmd = new PlayerBecomesItem {
                AttackerId = attacker.Id, VictimId = victim.Id, NewFormId = petFormSource.Id
            };

            Assert.That(DomainRegistry.Repository.Execute(cmd),
                        Has.Property("AttackerLog").EqualTo("<br><b>You fully transformed Victim MgGee into a Squeaky Pet</b>!")
                        .And.Property("VictimLog")
                        .EqualTo("<br><b>You have been fully transformed into a Squeaky Pet!</b>!")
                        .And.Property("LocationLog")
                        .EqualTo("<br><b>Victim MgGee was completely transformed into a Squeaky Pet</b> here."));

            var newItem = DataContext.AsQueryable <Item>().FirstOrDefault(i => i.FormerPlayer != null && i.FormerPlayer.Id == victim.Id);

            Assert.That(newItem, Is.Not.Null);
            Assert.That(newItem.Owner, Is.EqualTo(attacker));
            Assert.That(newItem.IsEquipped, Is.True);
        }
示例#2
0
        public void items_start_with_initial_permanenct_status_false(string itemType)
        {
            var itemSource = new ItemSourceBuilder()
                             .With(i => i.ItemType, itemType)
                             .BuildAndSave();

            Assert.That(itemSource.IsPermanentFromCreation(), Is.False);
        }
示例#3
0
        public void Should_create_new_tome()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 195).BuildAndSave();
            var cmd  = new CreateTome {
                Text = "This is a tome.", BaseItemId = item.Id
            };

            Assert.That(Repository.Execute(cmd), Is.GreaterThan(0));
        }
示例#4
0
        public void Should_create_new_RestockItem()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 195).BuildAndSave();
            var npc  = new NPCBuilder().With(ri => ri.Id, 4).BuildAndSave();

            var cmd = new CreateRestockItem {
                AmountBeforeRestock = 0, BaseItemId = item.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(Repository.Execute(cmd), Is.GreaterThan(0));
        }
示例#5
0
        public void Should_throw_error_when_no_restock_item_id()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            var cmd = new UpdateRestockItem {
                AmountBeforeRestock = 1, BaseItemId = item.Id, AmountToRestockTo = 1, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("RestockItemId must be set"));
        }
示例#6
0
        public void Should_throw_error_when_invalid_amount_to_restock()
        {
            var amount = -1;

            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();

            var cmd = new UpdateRestockItem {
                AmountBeforeRestock = amount, BaseItemId = item.Id, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmd),
                        Throws.TypeOf <DomainException>().With.Message.EqualTo("Minimum amount before restock must be 0"));
        }
示例#7
0
        public void Should_not_throw_error_when_amount_to_restock_is_zero()
        {
            var amount = 0;

            var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave();
            var npc  = new NPCBuilder().With(n => n.Id, 7).BuildAndSave();

            var cmd = new CreateRestockItem {
                AmountBeforeRestock = amount, BaseItemId = item.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(Repository.Execute(cmd), Is.GreaterThan(0));
        }
示例#8
0
        public void human_items_have_old_last_souled_timestamp()
        {
            var player = new PlayerBuilder()
                         .With(p => p.BotId, AIStatics.ActivePlayerBotId)
                         .BuildAndSave();

            var itemSource = new ItemSourceBuilder().BuildAndSave();

            var createItemCmd = new CreateItem();

            var item = Item.Create(player, null, itemSource, createItemCmd);

            var timeDifference = Math.Abs((item.LastSouledTimestamp - DateTime.UtcNow).TotalDays);

            Assert.That(timeDifference, Is.LessThan(1));
        }
示例#9
0
        public void Should_not_throw_error_when_amount_to_restock_is_zero()
        {
            var amount = 0;

            var item = new ItemSourceBuilder().With(cr => cr.Id, 215).BuildAndSave();

            var cmd = new UpdateRestockItem {
                AmountBeforeRestock = amount, BaseItemId = item.Id, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmd), Throws.Nothing);

            var editedRestockItem = DataContext.AsQueryable <RestockItem>().FirstOrDefault(cr => cr.Id == 13);

            Assert.That(editedRestockItem, Is.Not.Null);
            Assert.That(editedRestockItem.Id, Is.EqualTo(13));
        }
示例#10
0
        public void can_set_item_source_as_FK()
        {
            var itemSource = new ItemSourceBuilder()
                             .With(i => i.Id, 50)
                             .BuildAndSave();

            var formSource = new FormSourceBuilder()
                             .With(f => f.Id, 33)
                             .BuildAndSave();

            Assert.That(
                () => DomainRegistry.Repository.Execute(new SetFormSourceBecomesItemFK
            {
                FormSourceId = formSource.Id, ItemSourceId = itemSource.Id
            }), Throws.Nothing);
            Assert.That(DataContext.AsQueryable <FormSource>().First(t => t.Id == formSource.Id).ItemSource.Id,
                        Is.EqualTo(itemSource.Id));
        }
示例#11
0
        public void Should_update_RestockItem()
        {
            var item = new ItemSourceBuilder().With(cr => cr.Id, 222).BuildAndSave();

            var cmdEdit = new UpdateRestockItem {
                RestockItemId = 13, AmountBeforeRestock = 25, BaseItemId = item.Id, AmountToRestockTo = 50, BotId = AIStatics.LindellaBotId
            };

            Assert.That(() => Repository.Execute(cmdEdit), Throws.Nothing);

            var editedRestockItem = DataContext.AsQueryable <RestockItem>().FirstOrDefault(cr => cr.Id == 13);

            Assert.That(editedRestockItem, Is.Not.Null);
            Assert.That(editedRestockItem.Id, Is.EqualTo(13));
            Assert.That(editedRestockItem.AmountBeforeRestock, Is.EqualTo(25));
            Assert.That(editedRestockItem.AmountToRestockTo, Is.EqualTo(50));
            Assert.That(editedRestockItem.BaseItem.Id, Is.EqualTo(222));
            Assert.That(editedRestockItem.BotId, Is.EqualTo(AIStatics.LindellaBotId));
        }
示例#12
0
        public void should_give_items_of_type()
        {
            var player = new PlayerBuilder()
                         .With(i => i.Items, new List <Item>())
                         .BuildAndSave();

            var itemSource = new ItemSourceBuilder()
                             .With(i => i.Id, 50)
                             .With(i => i.FriendlyName, "Socks")
                             .BuildAndSave();

            player.GiveItemsOfType(itemSource, 3);
            Assert.That(player.Items, Has.Exactly(3).Items);
            Assert.That(player.Items.ElementAt(0).ItemSource.FriendlyName, Is.EqualTo(itemSource.FriendlyName));
            Assert.That(player.Items.ElementAt(0).dbLocationName, Is.Empty);
            Assert.That(player.Items.ElementAt(1).ItemSource.FriendlyName, Is.EqualTo(itemSource.FriendlyName));
            Assert.That(player.Items.ElementAt(1).dbLocationName, Is.Empty);
            Assert.That(player.Items.ElementAt(2).ItemSource.FriendlyName, Is.EqualTo(itemSource.FriendlyName));
            Assert.That(player.Items.ElementAt(2).dbLocationName, Is.Empty);
        }
示例#13
0
        public void can_save_pvp_leaderboard()
        {
            new WorldBuilder()
            .With(i => i.RoundNumber, "Alpha Round 13")
            .With(i => i.TurnNumber, 5000)
            .With(i => i.RoundDuration, 5000)
            .With(i => i.ChaosMode, false)
            .BuildAndSave();

            var itemSource1 = new ItemSourceBuilder()
                              .With(f => f.Id, 100)
                              .With(f => f.FriendlyName, "Cute Panties")
                              .With(f => f.ItemType, PvPStatics.ItemType_Underpants)
                              .BuildAndSave();

            var itemSource2 = new ItemSourceBuilder()
                              .With(f => f.Id, 172)
                              .With(f => f.FriendlyName, "Balloon")
                              .With(f => f.ItemType, PvPStatics.ItemType_Accessory)
                              .BuildAndSave();

            var thirdPlaceTiedOnLevel = new ItemBuilder()
                                        .With(i => i.Id, 1234)
                                        .With(i => i.ItemSource, itemSource1)
                                        .With(i => i.FormerPlayer, new PlayerBuilder()
                                              .With(p => p.FirstName, "Gary")
                                              .With(p => p.LastName, "Underwear")
                                              .With(p => p.ItemXP, new InanimateXPBuilder()
                                                    .With(i => i.Amount, 199)
                                                    .BuildAndSave())
                                              .BuildAndSave())
                                        .With(i => i.Level, 5)
                                        .BuildAndSave();

            var secondPlace = new ItemBuilder()
                              .With(i => i.Id, 55)
                              .With(i => i.ItemSource, itemSource2)
                              .With(i => i.FormerPlayer, new PlayerBuilder()
                                    .With(p => p.FirstName, "Susan")
                                    .With(p => p.LastName, "Panties")
                                    .With(p => p.ItemXP, new InanimateXPBuilder()
                                          .With(i => i.Amount, 200)
                                          .BuildAndSave())
                                    .BuildAndSave())
                              .With(i => i.Level, 5)
                              .BuildAndSave();

            var firstPlace = new ItemBuilder()
                             .With(i => i.Id, 50)
                             .With(i => i.ItemSource, itemSource1)
                             .With(i => i.FormerPlayer, new PlayerBuilder()
                                   .With(p => p.FirstName, "Bob")
                                   .With(p => p.LastName, "Panties")
                                   .With(p => p.ItemXP, new InanimateXPBuilder()
                                         .With(i => i.Amount, 200)
                                         .BuildAndSave())
                                   .BuildAndSave())
                             .With(i => i.Level, 10)
                             .BuildAndSave();

            DomainRegistry.Repository.Execute(new SaveItemLeaderboards {
                RoundNumber = 13
            });

            var leaders = DataContext.AsQueryable <TT.Domain.World.Entities.ItemLeaderboardEntry>();

            Assert.That(leaders, Has.Exactly(3).Items);

            var first = leaders.ElementAt(0);

            Assert.That(first.PlayerName,
                        Is.EqualTo($"{firstPlace.FormerPlayer.FirstName} {firstPlace.FormerPlayer.LastName}"));
            Assert.That(first.ItemName, Is.EqualTo(itemSource1.FriendlyName));
            Assert.That(first.ItemSource.Id, Is.EqualTo(itemSource1.Id));
            Assert.That(first.Level, Is.EqualTo(firstPlace.Level));
            Assert.That(first.ItemType, Is.EqualTo(itemSource1.ItemType));

            var second = leaders.ElementAt(1);

            Assert.That(second.PlayerName,
                        Is.EqualTo($"{secondPlace.FormerPlayer.FirstName} {secondPlace.FormerPlayer.LastName}"));
            Assert.That(second.ItemName, Is.EqualTo(itemSource2.FriendlyName));
            Assert.That(second.ItemSource.Id, Is.EqualTo(itemSource2.Id));

            var third = leaders.ElementAt(2);

            Assert.That(third.PlayerName,
                        Is.EqualTo(
                            $"{thirdPlaceTiedOnLevel.FormerPlayer.FirstName} {thirdPlaceTiedOnLevel.FormerPlayer.LastName}"));
        }
        public void should_delete_expired_consumable_items_on_merchants()
        {
            var lindella = new PlayerBuilder()
                           .With(p => p.Id, 1).BuildAndSave();

            var skaldyr = new PlayerBuilder()
                          .With(p => p.Id, 2).BuildAndSave();

            var consumable = new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Consumable)
                             .With(i => i.Id, 7)
                             .BuildAndSave();

            var pet = new ItemSourceBuilder()
                      .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                      .With(i => i.Id, 8)
                      .BuildAndSave();

            var dungeonArtifact = new ItemSourceBuilder()
                                  .With(i => i.ItemType, PvPStatics.ItemType_Consumable)
                                  .With(i => i.Id, PvPStatics.ItemType_DungeonArtifact_Id)
                                  .BuildAndSave();

            // eligible -- owned by lindella
            new ItemBuilder()
            .With(p => p.Id, 1)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // eligible -- owned by skaldyr
            new ItemBuilder()
            .With(p => p.Id, 2)
            .With(i => i.Owner, skaldyr)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- dropped too recently
            new ItemBuilder()
            .With(p => p.Id, 3)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow)
            .BuildAndSave();

            // ineligible -- not owned
            new ItemBuilder()
            .With(p => p.Id, 4)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- not a consumable type
            new ItemBuilder()
            .With(p => p.Id, 5)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, pet)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- dungeon artifact
            new ItemBuilder()
            .With(p => p.Id, 6)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, dungeonArtifact)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            var cmd = new DeleteExpiredConsumablesOnMerchants {
                LindellaId = 1, LorekeeperId = 2
            };

            Repository.Execute(cmd);

            var idsRemaining = DataContext.AsQueryable <Item>().Select(i => i.Id);

            Assert.That(idsRemaining, Has.Member(3));
            Assert.That(idsRemaining, Has.Member(4));
            Assert.That(idsRemaining, Has.Member(5));
            Assert.That(idsRemaining, Has.Member(6));

            Assert.That(idsRemaining, Has.No.Member(1));
            Assert.That(idsRemaining, Has.No.Member(2));
        }
        public void should_delete_expired_consumable_items_on_ground()
        {
            var person = new PlayerBuilder()
                         .With(p => p.Id, 1).BuildAndSave();

            var consumable = new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Consumable)
                             .With(i => i.Id, 7)
                             .BuildAndSave();

            var pet = new ItemSourceBuilder()
                      .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                      .With(i => i.Id, 8)
                      .BuildAndSave();

            var dungeonArtifact = new ItemSourceBuilder()
                                  .With(i => i.ItemType, PvPStatics.ItemType_Consumable)
                                  .With(i => i.Id, PvPStatics.ItemType_DungeonArtifact_Id)
                                  .BuildAndSave();

            // ineligible -- owned by a player
            new ItemBuilder()
            .With(p => p.Id, 1)
            .With(i => i.Owner, person)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- dropped too recently
            new ItemBuilder()
            .With(p => p.Id, 2)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow)
            .BuildAndSave();

            // eligible -- not owned
            new ItemBuilder()
            .With(p => p.Id, 3)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, consumable)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- not a consumable type
            new ItemBuilder()
            .With(p => p.Id, 4)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, pet)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- dungeon artifact
            new ItemBuilder()
            .With(p => p.Id, 6)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, dungeonArtifact)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            var cmd = new DeleteExpiredConsumablesOnGround();

            Assert.That(() => Repository.Execute(cmd), Throws.Nothing);

            var idsRemaining = DataContext.AsQueryable <Item>().Select(i => i.Id);

            Assert.That(idsRemaining, Has.Member(1));
            Assert.That(idsRemaining, Has.Member(2));
            Assert.That(idsRemaining, Has.Member(4));
            Assert.That(idsRemaining, Has.No.Member(3));
        }
示例#16
0
        public void should_delete_expired_runes_on_merchants()
        {
            var lindella = new PlayerBuilder()
                           .With(p => p.Id, 1)
                           .With(p => p.BotId, AIStatics.LindellaBotId)
                           .BuildAndSave();

            var skaldyr = new PlayerBuilder()
                          .With(p => p.Id, 2)
                          .With(p => p.BotId, AIStatics.LoremasterBotId)
                          .BuildAndSave();

            var runeSource = new ItemSourceBuilder()
                             .With(i => i.ItemType, PvPStatics.ItemType_Rune)
                             .With(i => i.Id, 7)
                             .BuildAndSave();

            var pet = new ItemSourceBuilder()
                      .With(i => i.ItemType, PvPStatics.ItemType_Pet)
                      .With(i => i.Id, 8)
                      .BuildAndSave();

            // eligible -- owned by lindella
            new ItemBuilder()
            .With(p => p.Id, 1)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, runeSource)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // eligible -- owned by skaldyr
            new ItemBuilder()
            .With(p => p.Id, 2)
            .With(i => i.Owner, skaldyr)
            .With(i => i.ItemSource, runeSource)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- dropped too recently
            new ItemBuilder()
            .With(p => p.Id, 3)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, runeSource)
            .With(i => i.TimeDropped, DateTime.UtcNow)
            .BuildAndSave();

            // ineligible -- not owned
            new ItemBuilder()
            .With(p => p.Id, 4)
            .With(i => i.Owner, null)
            .With(i => i.ItemSource, runeSource)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- not a rune type
            new ItemBuilder()
            .With(p => p.Id, 5)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, pet)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .BuildAndSave();

            // ineligible -- embedded on an item
            new ItemBuilder()
            .With(p => p.Id, 6)
            .With(i => i.Owner, lindella)
            .With(i => i.ItemSource, runeSource)
            .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-9))
            .With(i => i.EmbeddedOnItem, new ItemBuilder()
                  .With(i => i.Id, 999)
                  .With(i => i.Owner, lindella)
                  .BuildAndSave())
            .BuildAndSave();

            var cmd = new DeleteExpiredRunesOnMerchants();

            Assert.That(() => Repository.Execute(cmd), Throws.Nothing);

            var idsRemaining = DataContext.AsQueryable <Item>().Select(i => i.Id);

            Assert.That(idsRemaining, Has.Member(3));
            Assert.That(idsRemaining, Has.Member(4));
            Assert.That(idsRemaining, Has.Member(5));
            Assert.That(idsRemaining, Has.Member(6));

            Assert.That(idsRemaining, Has.No.Member(1));
            Assert.That(idsRemaining, Has.No.Member(2));
        }