Пример #1
0
        public async Task Test_Wear_Put_Item_CorrectSlotAsync(EquipmentType type)
        {
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type  = NoscorePocketType.Equipment, VNum = 1, EquipmentSlot = type,
                    Class = 31 //sum of all 2^class
                }
            };

            _item = new ItemGenerationService(items, new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(
                                                  new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);

            _session !.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                                 _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.All(s =>
                                                                  (s.Value.Slot == (short)type) && (s.Value.Type == NoscorePocketType.Wear)));
        }
Пример #2
0
        public async Task Test_Wear_GoodHeroLevelAsync()
        {
            _session !.Character.HeroLevel = 3;
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type          = NoscorePocketType.Equipment, VNum = 1,
                    EquipmentSlot = EquipmentType.MainWeapon,
                    IsHeroic      = true,
                    LevelMinimum  = 3
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);
            _session.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                               _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.All(s => s.Value.Type == NoscorePocketType.Wear));
        }
Пример #3
0
        public async Task Test_Binding_RequiredAsync()
        {
            var items = new List <ItemDto>
            {
                new Item {
                    Type = NoscorePocketType.Equipment, VNum = 1, RequireBinding = true
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);

            _session !.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                                 _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            var packet = (QnaPacket?)_session.LastPackets.FirstOrDefault(s => s is QnaPacket);

            Assert.IsTrue(packet?.YesPacket is UseItemPacket yespacket &&
                          (yespacket.Slot == 0) &&
                          (yespacket.Type == PocketType.Equipment) &&
                          (packet.Question == _session.GetMessageFromKey(LanguageKey.ASK_BIND)));
            Assert.IsTrue(_session.Character.InventoryService.Any(s =>
                                                                  (s.Value.ItemInstance !.ItemVNum == 1) && (s.Value.Type == NoscorePocketType.Equipment)));
        }
Пример #4
0
        public async Task Test_Wear_DestroyedSpAsync()
        {
            _session !.Character.HeroLevel = 1;
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type          = NoscorePocketType.Equipment, VNum = 1,
                    EquipmentSlot = EquipmentType.Sp
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);
            _session.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1, -2),
                                                                                               _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.Any(s => s.Value.Type == NoscorePocketType.Equipment));
            var packet = (MsgPacket?)_session.LastPackets.FirstOrDefault(s => s is MsgPacket);

            Assert.IsTrue(packet?.Message == GameLanguage.Instance.GetMessageFromKey(LanguageKey.CANT_EQUIP_DESTROYED_SP,
                                                                                     _session.Account.Language));
        }
Пример #5
0
        public async Task Test_Wear_BadHeroLevelAsync()
        {
            _session !.Character.HeroLevel = 1;
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type          = NoscorePocketType.Equipment, VNum = 1,
                    EquipmentSlot = EquipmentType.MainWeapon,
                    IsHeroic      = true,
                    LevelMinimum  = 3
                }
            };

            _item = new ItemGenerationService(items, new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(
                                                  new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);
            _session.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                               _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.All(s => s.Value.Type == NoscorePocketType.Equipment));
            var packet = (SayPacket?)_session.LastPackets.FirstOrDefault(s => s is SayPacket);

            Assert.IsTrue((packet?.Message == GameLanguage.Instance.GetMessageFromKey(LanguageKey.BAD_EQUIPMENT,
                                                                                      _session.Account.Language)) && (packet.Type == SayColorType.Yellow));
        }
        public async Task SetupAsync()
        {
            SystemTime.Freeze();
            await TestHelpers.ResetAsync().ConfigureAwait(false);

            _item    = TestHelpers.Instance.GenerateItemProvider();
            _session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            _spTransformPacketHandler = new SpTransformPacketHandler();
        }
Пример #7
0
 public MapNpc(IItemGenerationService?itemProvider, ILogger logger, IHeuristic distanceCalculator)
 {
     _itemProvider = itemProvider;
     _logger       = logger;
     Requests      = new Dictionary <Type, Subject <RequestData> >()
     {
         [typeof(INrunEventHandler)] = new Subject <RequestData>()
     };
     _distanceCalculator = distanceCalculator;
 }
Пример #8
0
        public async Task SetupAsync()
        {
            SystemTime.Freeze();
            await TestHelpers.ResetAsync().ConfigureAwait(false);

            _item    = TestHelpers.Instance.GenerateItemProvider();
            _session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            _getPacketHandler = new GetPacketHandler(Logger, TestHelpers.Instance.DistanceCalculator);
        }
Пример #9
0
        public async Task SetupAsync()
        {
            await TestHelpers.ResetAsync().ConfigureAwait(false);

            SystemTime.Freeze();
            _session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            _item             = TestHelpers.Instance.GenerateItemProvider();
            _mailHttpClient   = new Mock <IMailHttpClient>();
            _itemInstanceDao  = new Mock <IDao <IItemInstanceDto?, Guid> >();
            _pclPacketHandler = new PclPacketHandler(_mailHttpClient.Object, _item, _itemInstanceDao.Object);
        }
Пример #10
0
        public async Task SetupAsync()
        {
            await TestHelpers.ResetAsync().ConfigureAwait(false);

            _session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            _item         = TestHelpers.Instance.GenerateItemProvider();
            _nrRunService = new NrunService(
                new List <IEventHandler <Tuple <IAliveEntity, NrunPacket>, Tuple <IAliveEntity, NrunPacket> > >
            {
                new ChangeClassEventHandler()
            });
        }
Пример #11
0
        public async Task SetupAsync()
        {
            await TestHelpers.ResetAsync();

            var items = new List <ItemDto>
            {
                new Item {
                    VNum = 1, ItemType = ItemType.Title, EffectValue = 0, Type = NoscorePocketType.Main
                },
            };

            _itemProvider = new GameObject.Services.ItemGenerationService.ItemGenerationService(items,
                                                                                                new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >()), _logger);

            Session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            Handler = new TitleGuriHandler();
        }
Пример #12
0
        public async Task Test_Wear_Put_Item_BadGenderAsync(GenderType genderToTest)
        {
            _session !.Character.Gender = genderToTest;
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type = NoscorePocketType.Equipment, VNum = 1, EquipmentSlot = EquipmentType.MainWeapon,
                    Sex  = (byte)(3 - Math.Pow(2, (byte)genderToTest))
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);

            _session.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                               _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.All(s => s.Value.Type == NoscorePocketType.Equipment));
            var packet = (SayPacket?)_session.LastPackets.FirstOrDefault(s => s is SayPacket);

            Assert.IsTrue((packet?.Message == GameLanguage.Instance.GetMessageFromKey(LanguageKey.BAD_EQUIPMENT,
                                                                                      _session.Account.Language)) && (packet.Type == SayColorType.Yellow));

            foreach (var validClass in Enum.GetValues(typeof(GenderType)).OfType <GenderType>()
                     .Where(s => s != genderToTest).ToList())
            {
                _session.Character.Gender = validClass;
                var item = _session.Character.InventoryService.First();
                await _wearPacketHandler.ExecuteAsync(new WearPacket { InventorySlot = 0, Type = PocketType.Equipment }, _session).ConfigureAwait(false);

                Assert.IsTrue(item.Value.Type == NoscorePocketType.Wear);
                item.Value.Type = NoscorePocketType.Equipment;
                item.Value.Slot = 0;
            }
        }
Пример #13
0
        public async Task SetupAsync()
        {
            await TestHelpers.ResetAsync();

            var items = new List <ItemDto>
            {
                new Item {
                    VNum = 1, ItemType = ItemType.Magical, Type = NoscorePocketType.Etc, Effect = ItemEffectType.Speaker
                },
            };

            _logger       = new Mock <ILogger>();
            _itemProvider = new GameObject.Services.ItemGenerationService.ItemGenerationService(items,
                                                                                                new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >()), _logger.Object);

            Session = await TestHelpers.Instance.GenerateSessionAsync().ConfigureAwait(false);

            Handler = new SpeakerGuriHandler(_logger.Object);
            Broadcaster.Instance.LastPackets.Clear();
        }
Пример #14
0
        public async Task Test_Wear_SpInLoadingAsync()
        {
            _session !.Character.HeroLevel = 1;
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type          = NoscorePocketType.Equipment, VNum = 1,
                    EquipmentSlot = EquipmentType.Sp
                },
                new Item
                {
                    Type          = NoscorePocketType.Equipment, VNum = 2,
                    EquipmentSlot = EquipmentType.Sp
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);
            _session.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                               _session.Character.CharacterId));
            _session.Character.InventoryService.AddItemToPocket(InventoryItemInstance.Create(_item.Create(2, 1),
                                                                                             _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            _session.Character.SpCooldown = 30;
            await _wearPacketHandler.ExecuteAsync(new WearPacket { InventorySlot = 1, Type = PocketType.Equipment }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.Any(s =>
                                                                  (s.Value.ItemInstance !.ItemVNum == 2) && (s.Value.Type == NoscorePocketType.Equipment)));
            var packet = (MsgPacket?)_session.LastPackets.FirstOrDefault(s => s is MsgPacket);

            Assert.IsTrue(packet?.Message ==
                          string.Format(GameLanguage.Instance.GetMessageFromKey(LanguageKey.SP_INLOADING, _session.Account.Language),
                                        30));
        }
Пример #15
0
        public async Task Test_Wear_WearFairy_SpUseGoodSecondElementAsync()
        {
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type    = NoscorePocketType.Equipment, VNum = 1, EquipmentSlot = EquipmentType.Fairy,
                    Element = ElementType.Water
                },
                new Item
                {
                    Type             = NoscorePocketType.Equipment, VNum = 2, EquipmentSlot = EquipmentType.Sp,
                    Element          = ElementType.Fire,
                    SecondaryElement = ElementType.Water
                }
            };

            _item = new ItemGenerationService(items, new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(
                                                  new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);

            _session !.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                                 _session.Character.CharacterId));
            _session.Character.InventoryService.AddItemToPocket(InventoryItemInstance.Create(_item.Create(2, 1),
                                                                                             _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 1, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            _session.Character.UseSp = true;
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 0, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            Assert.IsTrue(
                _session.Character.InventoryService.Any(s =>
                                                        (s.Value.ItemInstance?.ItemVNum == 1) && (s.Value.Type == NoscorePocketType.Wear)));
        }
Пример #16
0
        public async Task Test_Wear_WearFairy_SpUseBadElementAsync()
        {
            var items = new List <ItemDto>
            {
                new Item
                {
                    Type    = NoscorePocketType.Equipment, VNum = 1, EquipmentSlot = EquipmentType.Fairy,
                    Element = ElementType.Light
                },
                new Item
                {
                    Type             = NoscorePocketType.Equipment, VNum = 2, EquipmentSlot = EquipmentType.Sp,
                    Element          = ElementType.Fire,
                    SecondaryElement = ElementType.Water
                }
            };

            _item = new ItemGenerationService(items,
                                              new EventLoaderService <Item, Tuple <InventoryItemInstance, UseItemPacket>, IUseItemEventHandler>(new List <IEventHandler <Item, Tuple <InventoryItemInstance, UseItemPacket> > >
            {
                new WearEventHandler(Logger)
            }), Logger);

            _session !.Character.InventoryService !.AddItemToPocket(InventoryItemInstance.Create(_item.Create(1, 1),
                                                                                                 _session.Character.CharacterId));
            _session.Character.InventoryService.AddItemToPocket(InventoryItemInstance.Create(_item.Create(2, 1),
                                                                                             _session.Character.CharacterId));
            await _wearPacketHandler !.ExecuteAsync(new WearPacket {
                InventorySlot = 1, Type = PocketType.Equipment
            }, _session).ConfigureAwait(false);

            _session.Character.UseSp = true;
            await _wearPacketHandler.ExecuteAsync(new WearPacket { InventorySlot = 0, Type = PocketType.Equipment }, _session).ConfigureAwait(false);

            Assert.IsTrue(_session.Character.InventoryService.Any(s =>
                                                                  (s.Value.ItemInstance !.ItemVNum == 1) && (s.Value.Type == NoscorePocketType.Equipment)));
            var packet = (MsgiPacket?)_session.LastPackets.FirstOrDefault(s => s is MsgiPacket);

            Assert.IsTrue(packet?.Message == Game18NConstString.SpecialistAndFairyDifferentElement);
        }