Example #1
0
        public CharacterItem Copy()
        {
            var item = new CharacterItem(Model);

            item.EffectsList.Clear();

            lock (item.EffectsList)
                EffectsList.ForEach(x => item.EffectsList.Add(new Effects.EffectItem(x)));

            item.ID       = ItemsHandler.GetNewID();
            item.Position = Position;
            item.Quantity = Quantity;

            return(item);
        }
Example #2
0
        public void AddItem(CharacterItem item, bool offline)
        {
            lock (ItemsList)
            {
                if (offline == true)
                {
                    if (ItemsList.Any(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position))
                    {
                        var item2 = ItemsList.First(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position);

                        item2.Quantity += item.Quantity;
                        Client.Pods    += (item.Model.Pods * item.Quantity);

                        return;
                    }

                    item.ID = ItemsHandler.GetNewID();

                    ItemsList.Add(item);
                    Client.Pods += (item.Model.Pods * item.Quantity);
                }
                else if (offline == false)
                {
                    if (ItemsList.Any(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position))
                    {
                        var item2 = ItemsList.First(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position);

                        item2.Quantity += item.Quantity;
                        Client.Pods    += (item.Model.Pods * item.Quantity);

                        RefreshBonus();
                        Client.NClient.Send(string.Format("OQ{0}|{1}", item2.ID, item2.Quantity));

                        return;
                    }

                    item.ID = ItemsHandler.GetNewID();
                    ItemsList.Add(item);

                    Client.Pods += (item.Model.Pods * item.Quantity);
                    RefreshBonus();

                    Client.NClient.Send(string.Concat("OAKO", item.ToString()));
                }
            }
        }
Example #3
0
        public void ParseItems(string datas)
        {
            var splited = datas.Split(';');

            foreach (var infos in splited)
            {
                var allInfos = infos.Split('~');
                var item     = new CharacterItem(Entities.Requests.ItemsRequests.ItemsList.First(x => x.ID == Convert.ToInt32(allInfos[0], 16)));
                item.EffectsList.Clear();

                item.ID       = ItemsHandler.GetNewID();
                item.Quantity = Convert.ToInt32(allInfos[1], 16);

                if (allInfos[2] != "")
                {
                    item.Position = Convert.ToInt32(allInfos[2], 16);
                }
                else
                {
                    item.Position = -1;
                }

                if (allInfos[3] != "")
                {
                    var effectsList = allInfos[3].Split(',');

                    foreach (var effect in effectsList)
                    {
                        var      NewEffect   = new Effects.EffectItem();
                        string[] EffectInfos = effect.Split('#');

                        NewEffect.ID = Convert.ToInt32(EffectInfos[0], 16);

                        if (EffectInfos[1] != "")
                        {
                            NewEffect.Value = Convert.ToInt32(EffectInfos[1], 16);
                        }

                        if (EffectInfos[2] != "")
                        {
                            NewEffect.Value2 = Convert.ToInt32(EffectInfos[2], 16);
                        }

                        if (EffectInfos[3] != "")
                        {
                            NewEffect.Value3 = Convert.ToInt32(EffectInfos[3], 16);
                        }

                        NewEffect.Effect = EffectInfos[4];

                        lock (item.EffectsList)
                            item.EffectsList.Add(NewEffect);
                    }
                }

                Client.Pods += (item.Model.Pods * item.Quantity);

                lock (ItemsList)
                    ItemsList.Add(item);
            }
        }
Example #4
0
        public void AddItem(int id, bool offline, int jet = 4)
        {
            if (offline == true)
            {
                if (!Entities.Requests.ItemsRequests.ItemsList.Any(x => x.ID == id))
                {
                    return;
                }

                var baseItem = Entities.Requests.ItemsRequests.ItemsList.First(x => x.ID == id);
                var item     = new CharacterItem(baseItem);

                item.GeneratItem(jet);

                lock (ItemsList)
                {
                    if (ItemsList.Any(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position))
                    {
                        var item2 = ItemsList.First(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position);

                        item2.Quantity += item.Quantity;
                        Client.Pods    += (item.Model.Pods * item.Quantity);

                        return;
                    }

                    item.ID = ItemsHandler.GetNewID();

                    ItemsList.Add(item);

                    Client.Pods += (item.Model.Pods * item.Quantity);
                }
            }
            else if (offline == false)
            {
                if (!Entities.Requests.ItemsRequests.ItemsList.Any(x => x.ID == id))
                {
                    return;
                }

                var baseItem = Entities.Requests.ItemsRequests.ItemsList.First(x => x.ID == id);
                var item     = new CharacterItem(baseItem);

                item.GeneratItem(jet);

                lock (ItemsList)
                {
                    if (ItemsList.Any(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position))
                    {
                        var item2 = ItemsList.First(x => x.EffectsInfos() == item.EffectsInfos() && x.Model.ID == item.Model.ID && x.Position == item.Position);

                        item2.Quantity += item.Quantity;
                        Client.Pods    += (item.Model.Pods * item.Quantity);

                        RefreshBonus();
                        Client.NClient.Send(string.Format("OQ{0}|{1}", item2.ID, item2.Quantity));

                        return;
                    }

                    item.ID = ItemsHandler.GetNewID();

                    ItemsList.Add(item);
                }

                Client.Pods += (item.Model.Pods * item.Quantity);
                RefreshBonus();

                Client.NClient.Send(string.Concat("OAKO", item.ToString()));
            }
        }