Exemplo n.º 1
0
        public void DeleteItem(int id, int quantity)
        {
            lock (ItemsList)
            {
                if (ItemsList.Any(x => x.ID == id))
                {
                    var item = ItemsList.First(x => x.ID == id);

                    if (item.Quantity <= quantity)
                    {
                        Client.Pods -= (item.Quantity * item.Model.Pods);

                        ItemsList.Remove(item);
                        Client.NClient.Send(string.Concat("OR", item.ID));

                        RefreshBonus();
                    }
                    else
                    {
                        Client.Pods -= (quantity * item.Model.Pods);

                        item.Quantity -= quantity;
                        Client.NClient.Send(string.Format("OQ{0}|{1}", item.ID, item.Quantity));

                        RefreshBonus();
                    }
                }
                else
                {
                    Client.NClient.Send("BN");
                }
            }
        }
Exemplo n.º 2
0
        public void GetTypesList()
        {
            if (!ItemsList.Any())
            {
                ItemsList = App.Database.GetItemTypes().ToList();
            }

            PickerList = ItemsList.Select(t => t.TypeName).ToList();
        }
Exemplo n.º 3
0
        public CharacterItem GetItemByPos(int pos)
        {
            if (!ItemsList.Any(x => x.Position == pos))
            {
                return(null);
            }

            return(ItemsList.First(x => x.Position == pos));
        }
 public override void OnAppearing()
 {
     base.OnAppearing();
     MainThread.BeginInvokeOnMainThread(async() =>
     {
         if (ItemsList.Any())
         {
             return;
         }
         await GetDataAsync();
     });
 }
Exemplo n.º 5
0
        public void UseItem(string datas)
        {
            if (Client.State.OnMove == true)
            {
                Client.NClient.Send("BN");
                return;
            }

            var allDatas = datas.Split('|');

            var itemID = int.Parse(allDatas[0]);
            var charID = Client.ID;
            var cellID = Client.MapCell;

            if (allDatas.Length > 2)
            {
                charID = int.Parse(allDatas[1]);
                cellID = int.Parse(allDatas[2]);
            }

            if (!ItemsList.Any(x => x.ID == itemID))
            {
                Client.NClient.Send("OUE");
                return;
            }

            var item = ItemsList.First(x => x.ID == itemID);

            if (item.Model.isUsable == false)
            {
                Client.NClient.Send("BN");
                return;
            }

            var usable = Entities.Requests.ItemsRequests.UsablesList.First(x => x.Base == item.Model.ID);

            var character = SunDofus.Entities.Requests.CharactersRequests.CharactersList.First(x => x.ID == charID);

            if (!ItemsHandler.ConditionsAvaliable(item.Model, Client))
            {
                Client.NClient.Send("Im119|44");
                return;
            }

            usable.ParseEffect(character);

            if (usable.MustDelete == true)
            {
                DeleteItem(item.ID, 1);
            }
        }
Exemplo n.º 6
0
        protected void AddScreen(WorkflowAction item, string prefix)
        {
            ListItem listItem = new ListItem(Consts.KEY_NAME, $"{LocalizationHelper.Translate(RES_SCREEN_TEXT)} \"{item.DisplayTitle}\"")
            {
                Command = new MethodDelegateCommand(() => ChooseKeyAction(prefix + item.Name))
            };

            listItem.SetLabel(KEY_KEYMAP, "");
            listItem.SetLabel(KEY_KEYMAP_NAME, item.DisplayTitle);
            listItem.AdditionalProperties[KEY_KEYMAP_DATA] = prefix + item.Name;
            if (!_items.Any(i => string.Compare((string)i.AdditionalProperties[KEY_KEYMAP_DATA], (string)listItem.AdditionalProperties[KEY_KEYMAP_DATA], true) == 0))
            {
                _items.Add(listItem);
            }
        }
Exemplo n.º 7
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()));
                }
            }
        }
Exemplo n.º 8
0
        protected void UpdateTotalSum()
        {
            if (SummedAmount == null)
            {
                return;
            }

            var oldSum = TotalSum;

            TotalSum = ItemsList.Any()
                ? ItemsList.Sum(_ => SummedAmount(_)) : 0;

            if (TotalSum != oldSum)
            {
                TotalSumChanged?.Invoke(this, TotalSum);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// this will add a location
        /// to the _locationsExposed and _locations list
        /// </summary>
        /// <param name="item"></param>
        public void AddLocation(ListItem item)
        {
            // Don't add it if it's already in there
            if (_locationsExposed.Any(i => i["Id"].Equals(item["Id"])))
            {
                return;
            }

            _locationsExposed.Add(item);
            // Create a CitySetupObject and add it to the loctions list
            CitySetupInfo c = new CitySetupInfo(item["Name"], item["Id"])
            {
                Detail = item["Detail"]
            };

            _locations.Add(c);
            _locationsExposed.FireChange();
        }
Exemplo n.º 10
0
        public void SetUserProfile(UserProfile userProfile, ItemsList localSharesList = null, ItemsList serverSharesList = null)
        {
            Id                      = userProfile.ProfileId;
            TemplateId              = userProfile.TemplateId;
            Name                    = userProfile.Name;
            Password                = userProfile.Password;
            _originalPassword       = userProfile.Password;
            ProfileType             = userProfile.ProfileType;
            LastLogin               = userProfile.LastLogin ?? DateTime.MinValue;
            Image                   = userProfile.Image;
            EnableRestrictionGroups = userProfile.EnableRestrictionGroups;
            RestrictionGroups       = userProfile.RestrictionGroups;

            SelectedShares.Clear();

            foreach (var data in userProfile.AdditionalData)
            {
                foreach (var val in data.Value)
                {
                    if (data.Key == UserDataKeysKnown.KEY_ALLOWED_SHARE)
                    {
                        Guid shareId = Guid.Parse(val.Value);
                        if (localSharesList != null && localSharesList.Any(i => ((Share)i.AdditionalProperties[Consts.KEY_SHARE]).ShareId == shareId) ||
                            serverSharesList != null && serverSharesList.Any(i => ((Share)i.AdditionalProperties[Consts.KEY_SHARE]).ShareId == shareId))
                        {
                            SelectedShares.Add(shareId);
                        }
                    }
                }
            }

            RestrictAges               = userProfile.RestrictAges;
            RestrictShares             = userProfile.RestrictShares;
            AllowedAge                 = userProfile.AllowedAge ?? 5;
            IncludeParentGuidedContent = userProfile.IncludeParentGuidedContent;
            IncludeUnratedContent      = userProfile.IncludeUnratedContent;
        }
Exemplo n.º 11
0
        public void MoveItem(int id, int pos, int quantity)
        {
            if (!ItemsList.Any(x => x.ID == id))
            {
                return;
            }

            var item = ItemsList.First(x => x.ID == id);

            if (ItemsHandler.PositionAvaliable(item.Model.Type, item.Model.isUsable, pos) == false ||
                pos == 1 && item.Model.isTwoHands == true && isOccuptedPos(15) || pos == 15 && isOccuptedPos(1))
            {
                Client.NClient.Send("BN");
                return;
            }

            if (!ItemsHandler.ConditionsAvaliable(item.Model, Client))
            {
                Client.NClient.Send("Im119|44");
                return;
            }

            if (IsEquippablePos(pos) & HasTemplateEquipped(item.Model.ID))
            {
                Client.NClient.Send("OAEA");
                return;
            }

            if (item.Model.Type == 23 && pos != -1)
            {
                if (!ItemsList.Any(x => x.Model.ID == item.Model.ID && x.Position != -1 && x.Model.Type == 23))
                {
                    Client.NClient.Send("OAEA");
                    return;
                }
            }

            if (item.Model.Level > Client.Level)
            {
                Client.NClient.Send("OAEL");
                return;
            }

            var lastpos = item.Position;

            item.Position = pos;

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

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

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

                    if (Client.State.Party != null && IsEquippablePos(lastpos))
                    {
                        Client.State.Party.UpdateMembers();
                    }

                    return;
                }
            }
            else
            {
                if (item.Quantity > 1)
                {
                    if (item.Model.Type == 12 || item.Model.Type == 13 || item.Model.Type == 14 || item.Model.Type == 28 ||
                        item.Model.Type == 33 || item.Model.Type == 37 || item.Model.Type == 42 || item.Model.Type == 49 ||
                        item.Model.Type == 69 || item.Model.Type == 87)
                    {
                        if (quantity <= 0)
                        {
                            return;
                        }

                        var Copy = item.Copy();
                        Copy.Quantity -= quantity;

                        if (item.Quantity == quantity)
                        {
                            Copy.Position = pos;
                        }
                        else
                        {
                            Copy.Position = -1;
                        }

                        item.Quantity = quantity;
                        AddItem(Copy, false);
                    }
                    else
                    {
                        var Copy = item.Copy();

                        Copy.Quantity -= 1;
                        Copy.Position  = -1;

                        item.Quantity = 1;
                        AddItem(Copy, false);
                    }

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

            if (Client.State.Party != null && IsEquippablePos(pos))
            {
                Client.State.Party.UpdateMembers();
            }

            Client.NClient.Send(string.Format("OM{0}|{1}", item.ID, (item.Position != -1 ? item.Position.ToString() : "")));
            Client.GetMap().Send(string.Format("Oa{0}|{1}", Client.ID, Client.GetItemsPos()));

            RefreshBonus();
        }
Exemplo n.º 12
0
 public void UpdateIsResourceProviderSelected()
 {
     IsResourceProviderSelected = _allBaseResourceProvidersList.Any(resourceProviderItem => resourceProviderItem.Selected);
 }
 protected void ItemToRemoveSelectionChanged(AbstractProperty property, object oldValue)
 {
     ItemsToRemoveValid = _itemsToRemoveList.Any(i => i.Selected);
 }
 protected void UpdateIsConfigurationSelected()
 {
     IsConfigurationSelected = _configurationItemsToRemove.Any(l => l.Selected);
 }
Exemplo n.º 15
0
        public void SetUserProfile(UserProfile userProfile, ItemsList localSharesList = null, ItemsList serverSharesList = null)
        {
            Id                      = userProfile.ProfileId;
            TemplateId              = userProfile.TemplateId;
            Name                    = userProfile.Name;
            Password                = userProfile.Password;
            _originalPassword       = userProfile.Password;
            ProfileType             = userProfile.ProfileType;
            LastLogin               = userProfile.LastLogin ?? DateTime.MinValue;
            Image                   = userProfile.Image;
            EnableRestrictionGroups = userProfile.EnableRestrictionGroups;
            RestrictionGroups       = userProfile.RestrictionGroups;

            string         defaultText = LocalizationHelper.CreateResourceString("[UserConfig.Default]").Evaluate();
            RegionSettings settings    = ServiceRegistration.Get <ISettingsManager>().Load <RegionSettings>();

            LanguageAudioMain         = settings.Culture;
            LanguageMenuMain          = settings.Culture;
            LanguageSubtitleMain      = settings.Culture;
            LanguageAudioSecondary    = defaultText;
            LanguageMenuSecondary     = defaultText;
            LanguageSubtitleSecondary = defaultText;

            var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);

            SelectedShares.Clear();
            foreach (var data in userProfile.AdditionalData)
            {
                foreach (var val in data.Value)
                {
                    if (data.Key == UserDataKeysKnown.KEY_ALLOWED_SHARE)
                    {
                        Guid shareId = Guid.Parse(val.Value);
                        if (localSharesList != null && localSharesList.Any(i => ((Share)i.AdditionalProperties[Consts.KEY_SHARE]).ShareId == shareId) ||
                            serverSharesList != null && serverSharesList.Any(i => ((Share)i.AdditionalProperties[Consts.KEY_SHARE]).ShareId == shareId))
                        {
                            SelectedShares.Add(shareId);
                        }
                    }
                    else if (data.Key == UserDataKeysKnown.KEY_PREFERRED_AUDIO_LANGUAGE)
                    {
                        if (val.Key == 0)
                        {
                            LanguageAudioMain = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageAudioMain;
                        }
                        else if (val.Key == 1)
                        {
                            LanguageAudioSecondary = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageAudioSecondary;
                        }
                    }
                    else if (data.Key == UserDataKeysKnown.KEY_PREFERRED_SUBTITLE_LANGUAGE)
                    {
                        if (val.Key == 0)
                        {
                            LanguageSubtitleMain = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageSubtitleMain;
                        }
                        else if (val.Key == 1)
                        {
                            LanguageSubtitleSecondary = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageSubtitleSecondary;
                        }
                    }
                    else if (data.Key == UserDataKeysKnown.KEY_PREFERRED_MENU_LANGUAGE)
                    {
                        if (val.Key == 0)
                        {
                            LanguageMenuMain = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageMenuMain;
                        }
                        else if (val.Key == 1)
                        {
                            LanguageMenuSecondary = cultures.FirstOrDefault(c => c.TwoLetterISOLanguageName == val.Value)?.DisplayName ?? LanguageMenuSecondary;
                        }
                    }
                }
            }

            RestrictAges               = userProfile.RestrictAges;
            RestrictShares             = userProfile.RestrictShares;
            AllowedAge                 = userProfile.AllowedAge ?? 5;
            IncludeParentGuidedContent = userProfile.IncludeParentGuidedContent;
            IncludeUnratedContent      = userProfile.IncludeUnratedContent;
        }
Exemplo n.º 16
0
 public bool isOccuptedPos(int pos)
 {
     return(ItemsList.Any(x => x.Position == pos));
 }
Exemplo n.º 17
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()));
            }
        }