protected override async Task Handle(CellonItemEvent e, CancellationToken cancellation)
        {
            if (!(e.Sender is IPlayerEntity player))
            {
                return;
            }


            await player.GoldLess(e.GoldAmount);

            //Session.Character.Inventory.RemoveItemAmount(cellon.ItemVNum);

            // GENERATE OPTION
            EquipmentOptionDto option = CellonGeneratorHelper.Instance.GenerateOption(e.Cellon.Item.EffectValue);

            // FAIL

            /*
             * if (option == null || e.Jewelry.EquipmentOptions.Any(s => s.Type == option.Type))
             * {
             *  player.SendTopscreenMessage("CELLONING_FAILED", MsgPacketType.White);
             *  player.GenerateShopEndPacket(ShopEndPacketType.CloseSubWindow);
             *  return;
             * }
             *
             * // SUCCESS
             * e.Jewelry.EquipmentOptions.Add(option);
             */
            await player.SendTopscreenMessage("CELLONING_SUCCESS", MsgPacketType.White);

            await player.SendPacketAsync(player.GenerateShopEndPacket(ShopEndPacketType.CloseSubWindow));
        }
示例#2
0
        public EquipmentOptionDto GenerateOption(int itemEffectValue)
        {
            Dictionary <JewelOptionType, CellonGenerator> dictionary = _generatorDictionary[itemEffectValue];

            Dictionary <JewelOptionType, CellonGenerator> .ValueCollection list = dictionary.Values;
            var result = new EquipmentOptionDto();
            int rand   = new Random().Next(list.Count);

            for (int i = 0; i < list.Count; i++)
            {
                if (i != rand)
                {
                    continue;
                }

                result.Value = new Random().Next(list.ElementAt(i).Min, list.ElementAt(i).Max);
                result.Level = (byte)itemEffectValue;
                result.Type  = (byte)i;
                return(result);
            }

            return(null);
        }