public void ParseItems(string items) { if (items == "") return; var splited = items.Split(';'); foreach (var infos in splited) { var allInfos = infos.Split('~'); var item = new Characters.Items.CharacterItem(Entities.Requests.ItemsRequests.ItemsList.First(x => x.ID == Convert.ToInt32(allInfos[0], 16))); item.EffectsList.Clear(); item.ID = Characters.Items.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); } } Items.Add(item); } }
public void ParseItems(string items) { if (items == "") { return; } var splited = items.Split(';'); foreach (var infos in splited) { var allInfos = infos.Split('~'); var item = new Characters.Items.CharacterItem(Entities.Requests.ItemsRequests.ItemsList.First(x => x.ID == Convert.ToInt32(allInfos[0], 16))); item.EffectsList.Clear(); item.ID = Characters.Items.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); } } Items.Add(item); } }
public void MoveItem(Characters.Character character, Characters.Items.CharacterItem item, int quantity, bool add) { if (memberOne.Character == character) { if (add) { Reset(); lock (memberOne.Items) { if (memberOne.Items.Any(x => x.Item == item)) { var item2 = memberOne.Items.First(x => x.Item == item); item2.Quantity += quantity; if (item2.Quantity > item.Quantity) { item2.Quantity = item.Quantity; } memberOne.Send(string.Format("EMKO+{0}|{1}", item.ID, item2.Quantity)); memberTwo.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", item.ID, item2.Quantity, item.Model.ID, item.EffectsInfos())); } else { var newItem = new ExchangeItem(item); newItem.Quantity = quantity; memberOne.Items.Add(newItem); memberOne.Send(string.Format("EMKO+{0}|{1}", item.ID, newItem.Quantity)); memberTwo.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", item.ID, newItem.Quantity, item.Model.ID, item.EffectsInfos())); } } } else { Reset(); lock (memberOne.Items) { var Item = memberOne.Items.First(x => x.Item == item); if (Item.Quantity <= quantity) { memberOne.Items.Remove(Item); memberOne.Send(string.Concat("EMKO-", Item.Item.ID)); memberTwo.Send(string.Concat("EmKO-", Item.Item.ID)); } else { Item.Quantity -= quantity; memberOne.Send(string.Format("EMKO+{0}|{1}", Item.Item.ID, Item.Quantity)); memberTwo.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", Item.Item.ID, Item.Quantity, Item.Item.Model.ID, Item.Item.EffectsInfos())); } } } } else if (memberTwo.Character == character) { if (add) { Reset(); lock (memberTwo.Items) { if (memberTwo.Items.Any(x => x.Item == item)) { var item2 = memberTwo.Items.First(x => x.Item == item); item2.Quantity += quantity; if (item2.Quantity > item.Quantity) { item2.Quantity = item.Quantity; } memberTwo.Send(string.Format("EMKO+{0}|{1}", item.ID, item2.Quantity)); memberOne.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", item.ID, item2.Quantity, item.Model.ID, item.EffectsInfos())); } else { var newItem = new ExchangeItem(item); newItem.Quantity = quantity; memberTwo.Items.Add(newItem); memberTwo.Send(string.Format("EMKO+{0}|{1}", item.ID, newItem.Quantity)); memberOne.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", item.ID, newItem.Quantity, item.Model.ID, item.EffectsInfos())); } } } else { Reset(); lock (memberTwo.Items) { var Item = memberTwo.Items.First(x => x.Item == item); if (Item.Quantity <= quantity) { memberTwo.Items.Remove(Item); memberTwo.Send(string.Concat("EMKO-", Item.Item.ID)); memberOne.Send(string.Concat("EmKO-", Item.Item.ID)); } else { Item.Quantity -= quantity; memberTwo.Send(string.Format("EMKO+{0}|{1}", Item.Item.ID, Item.Quantity)); memberOne.Send(string.Format("EmKO+{0}|{1}|{2}|{3}", Item.Item.ID, Item.Quantity, Item.Item.Model.ID, Item.Item.EffectsInfos())); } } } } }