Пример #1
0
 /// <summary>
 /// find an item
 /// </summary>
 /// <returns>ItemCentralHomePage</returns>
 public ItemCentralHomePage FindAnItem()
 {
     //this.Parent.Header.SelectWelcomeMessage(); //stop hover over menu
     this.Utilities.FocusOnMainContentArea();
     FindItem.Click();
     return(new ItemCentralHomePage());
 }
Пример #2
0
        private void countValueChange(object sender, PropertyChangedEventArgs e)
        {
            IntSpinnerControl updown = sender as IntSpinnerControl;

            if (updown == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(updown);

            if (dgrow == null)
            {
                return;
            }

            WriteoffDetailsHelper writeoffDetailHelper = (WriteoffDetailsHelper)dgrow.Item;

            if (writeoffDetailHelper == null)
            {
                return;
            }

            writeoffDetailHelper.DetailsCount = (int)updown.Value;
        }
Пример #3
0
        /// <summary>
        /// Render a list of findItems (Works for both Find in Open documents and Find in Files)
        /// </summary>
        /// <param name="findItems"></param>
        public void Render(FindList findItems)
        {
            _findText   = findItems.Find;
            _findLength = _findText.Length;
            TreeFind.BeginUpdate();
            TreeFind.Nodes.Clear();
            try
            {
                FindItem lastItem   = null;
                TreeNode parentNode = null;
                foreach (FindItem item in findItems.Items)
                {
                    if (lastItem == null || lastItem.FileName != item.FileName || lastItem.Document != item.Document)
                    {
                        parentNode = new TreeNode(item.Name);
                        TreeFind.Nodes.Add(parentNode);
                    }

                    TreeNode node = new TreeNode(item.Text);
                    node.Tag = item;

                    parentNode.Nodes.Add(node);
                    lastItem = item;
                }


                // Expand all results.
                TreeFind.ExpandAll();
            }
            catch { }
            TreeFind.EndUpdate();
        }
Пример #4
0
        private void removeRecord(object sender, System.Windows.RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(button);

            if (dgrow == null)
            {
                return;
            }

            WriteoffDetailsHelper writeoffDetailHelper = (WriteoffDetailsHelper)dgrow.Item;

            if (writeoffDetailHelper == null)
            {
                return;
            }

            wodh_collection.remove(writeoffDetailHelper);
        }
        private void rowDown(object sender, RoutedEventArgs e)
        {
            Button downButton = sender as Button;

            if (downButton == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(downButton);

            if (dgrow == null)
            {
                return;
            }

            Details detail = (Details)dgrow.Item;

            if (detail == null)
            {
                return;
            }

            if (!detail.down())
            {
                MessageBox.Show("При выполнении запроса произошли ошибки!\nПодробнее см. в логе ошибок.");
            }
        }
        private void rowUp(object sender, RoutedEventArgs e)
        {
            Button upButton = sender as Button;

            if (upButton == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(upButton);

            if (dgrow == null)
            {
                return;
            }

            Oven oven = (Oven)dgrow.Item;

            if (oven == null)
            {
                return;
            }

            if (!oven.up())
            {
                MessageBox.Show("При выполнении запроса произошли ошибки!\nПодробнее см. в логе ошибок.");
            }
        }
Пример #7
0
        private void cbxWeekDay_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            System.Windows.Controls.ComboBox comboBox = sender as System.Windows.Controls.ComboBox;
            if (comboBox == null)
            {
                return;
            }
            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            ReportsSetting reportsSetting = (ReportsSetting)dgrow.Item;

            if (reportsSetting == null)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }
            if (reportsSetting.Period == comboBox.SelectedValue.ToString())
            {
                return;
            }

            reportsSetting.Day = Int32.Parse(comboBox.SelectedValue.ToString());

            reportsSetting.Time = "";
        }
Пример #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
            if (button == null)
            {
                return;
            }
            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(button);

            if (dgrow == null)
            {
                return;
            }

            ReportsSetting reportsSetting = (ReportsSetting)dgrow.Item;

            if (reportsSetting == null)
            {
                return;
            }

            var dlg = new System.Windows.Forms.FolderBrowserDialog();

            System.Windows.Forms.DialogResult result = dlg.ShowDialog(this.GetIWin32Window());
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                reportsSetting.ReportPath = dlg.SelectedPath;
                //reportsSetting.save();
            }
        }
Пример #9
0
        private void ovenSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox == null)
            {
                return;
            }
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            WriteoffDetailsHelper writeoffDetailHelper = (WriteoffDetailsHelper)dgrow.Item;

            if (writeoffDetailHelper == null)
            {
                return;
            }

            writeoffDetailHelper.IdOven       = (int)comboBox.SelectedValue;
            writeoffDetailHelper.IdDetails    = 0;
            writeoffDetailHelper.DetailsCount = 0;
        }
Пример #10
0
    public static Task CreateFindItem(Field.Tile task_giver, int reward_exp, int reward_gold, int reward_score)
    {
        FindItem task = new FindItem(task_giver, reward_exp, reward_gold, reward_score);

        if (!task.item.Spawn(GlobalDataHolder.field.random_no_item_road))
        {
            return(null);
        }
        return(task);
    }
        private void findItemButton_Click(object sender, EventArgs e)
        {
            FindItem fi = new FindItem();

            if (fi.ShowDialog() == DialogResult.OK)
            {
                // FindItem form uses ListView to list all of the NPC's that are in `item_template` table. When FindItem form loads, it should load all of the item's currently in that table.
                // ListView uses 2 columns (Item ID, Item NAME). So once user clicks on a desired Item from the list, this dialog here should return that value to the itemEntryIntegerInput
            }
        }
Пример #12
0
        /// <summary>
        /// Returns 'true' if item was found in cache and processed.
        /// </summary>
        public bool Find(FindItem findFunction, params object[] list)
        {
            foreach (var item in _list)
            {
                if (findFunction(item, list))
                {
                    Add(item);
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        private void detailsSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox == null)
            {
                return;
            }
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            WriteoffDetailsHelper writeoffDetailHelper = (WriteoffDetailsHelper)dgrow.Item;

            if (writeoffDetailHelper == null)
            {
                return;
            }

            writeoffDetailHelper.IdDetails    = (int)comboBox.SelectedValue;
            writeoffDetailHelper.DetailsCount = (writeoffDetailHelper.Detail.CurrentCount > 0) ? 1 : 0;


            int notFillRowCount = WriteoffDetailsHelperCollection.instance()
                                  .Collection.Where(x => x.IdDetails == 0).Count();

            if (writeoffDetailHelper.IdDetails != 0 && notFillRowCount == 0)
            {
                WriteoffDetailsHelper writeoffDetailsHelper = new WriteoffDetailsHelper();
                wodh_collection.add(writeoffDetailsHelper);
            }
        }
Пример #14
0
        public static void Practice(Player player, Room room, string skillToPractice)
        {
            var foundTrainer = FindItem.Trainer(room.mobs);

            if (foundTrainer == null)
            {
                HubContext.Instance.SendToClient("There is no one here that can train you.", player.HubGuid);
                return;
            }

            if (skillToPractice == string.Empty)
            {
                ShowSkills(player);
            }
            else
            {
                PracticeSkill(player, foundTrainer, skillToPractice);
            }
        }
Пример #15
0
        private void detailsSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;

            if (comboBox == null)
            {
                return;
            }
            if (comboBox.SelectedIndex == -1)
            {
                return;
            }
            if (comboBox.SelectedValue == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(comboBox);

            if (dgrow == null)
            {
                return;
            }

            SupplyDetailsHelper supplyDetailHelper = (SupplyDetailsHelper)dgrow.Item;

            if (supplyDetailHelper == null)
            {
                return;
            }

            supplyDetailHelper.IdDetails = (int)comboBox.SelectedValue;

            int notFillRowCount = SupplyDetailsHelperCollection.instance()
                                  .Collection.Where(x => x.IdDetails == 0).Count();

            if (supplyDetailHelper.IdDetails != 0 && notFillRowCount == 0)
            {
                SupplyDetailsHelper supplyDetails = new SupplyDetailsHelper();
                sdh_collection.add(supplyDetails);
            }
        }
Пример #16
0
 void CheckItemQuest()
 {
     foreach (Quest quest in QuestManager.questManager.currentQuests)
     {
         if (quest.questType == Quest.QuestType.FIND_ITEM)
         {
             FindItem itemQuest = (FindItem)quest;
             foreach (KeyValuePair <Item, int> keypair in Inventory.inventory.GetItems())
             {
                 if (keypair.Key == itemQuest.itemRequired && itemQuest.questProgress == Quest.QuestProgress.CURRENT)
                 {
                     itemQuest.numberHeld += keypair.Value;
                     if (itemQuest.numberHeld == itemQuest.numberNeeded)
                     {
                         CompleteQuest(itemQuest);
                     }
                 }
             }
         }
     }
 }
Пример #17
0
 /// <summary>
 /// Bring the document into focus and set the position of the cursor to match the selected
 /// position of the found text.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TreeFind_DoubleClick(object sender, EventArgs e)
 {
     try
     {
         TreeNode node = TreeFind.SelectedNode;
         if (node != null)
         {
             FindItem find = (FindItem)node.Tag;
             if (find != null)
             {
                 if (find.Document != null)
                 {
                     find.Document.BringToFront();
                     find.Document.SetSel(find.StartPos, find.EndPos, true);
                     find.Document.FocusEditor();
                 }
             }
         }
     }
     catch { }
 }
Пример #18
0
        private int getRealCol(FindItem item)
        {
            int col = 0;

            for (int i = 0; i < item.ColStart; i++)
            {
                if (item.Text[i] == '\t')
                {
                    col += item.TabWidth;
                }
                else
                {
                    col++;
                }
                if (col >= item.ColStart + 1)
                {
                    return(i);
                }
            }
            return(item.ColStart);
        }
Пример #19
0
        public async Task <VerityResult> ConfirmOrder(List <OrderViewModel> model)
        {
            VerityResult result    = new VerityResult();
            List <Order> modellist = new List <Order>();

            foreach (var OrderItem in from item in model
                     let FindItem = _orderService.FindBy(x => x.OrderId == item.OrderId)
                                    where FindItem.Any()
                                    let OrderItem = FindItem.FirstOrDefault()
                                                    select OrderItem)
            {
                OrderItem.Status = 1;
                modellist.Add(OrderItem);
            }

            if (modellist.Any())
            {
                _orderService.UpdateMultiple(modellist);
            }

            return(await Task.Run(() => result));
        }
Пример #20
0
        /// <summary>
        /// Draw formatted text to the treeview with the search string highlighted in red.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="item"></param>
        /// <param name="rect"></param>
        /// <param name="selected"></param>
        private void WriteText(Graphics graphics, FindItem item, Rectangle rect, bool selected)
        {
            try
            {
                int colStart = getRealCol(item);
                // Get the string up to the find text
                string startString = item.Text.Substring(0, colStart);

                // Get the string after the find text
                string endString = item.Text.Substring(colStart + _findLength);


                using (Font fontNormal = new Font("Courier New", 10, FontStyle.Regular))
                {
                    using (Font fontResult = new Font("Courier New", 10, FontStyle.Bold))
                    {
                        graphics.DrawString(startString, fontNormal, (selected ? Brushes.White : Brushes.Black), rect);

                        // Modify the rect to place to the new place
                        SizeF dif = graphics.MeasureString(startString, fontNormal);

                        rect.X += (int)Math.Floor(dif.Width);

                        graphics.DrawString(item.Text.Substring(colStart, _findLength), fontResult, Brushes.Red, rect);

                        dif = graphics.MeasureString(_findText, fontNormal);

                        rect.X += (int)Math.Floor(dif.Width);

                        graphics.DrawString(endString, fontNormal, (selected ? Brushes.White : Brushes.Black), rect);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
            }
        }
        //Изменение наименования комплектации, устанавливает статус "Не сохранено"
        void DlcComplectationItem_TextChanged(object sender, TextChangedEventArgs e)
        {
            StangradCRM.Controls.DownListControl downListControl
                = sender as StangradCRM.Controls.DownListControl;

            if (downListControl == null)
            {
                return;
            }

            DataGridRow row = FindItem.FindParentItem <DataGridRow>(downListControl);

            if (row == null)
            {
                return;
            }

            Complectation complectation = (Complectation)row.Item;

            if (complectation == null)
            {
                return;
            }

            ComplectationItem citem = ComplectationItemViewModel.instance()
                                      .getByName(downListControl.Text);

            if (citem != null)
            {
                complectation.Id_complectation_item = citem.Id;
            }
            else
            {
                complectation.Id_complectation_item    = 0;
                complectation.NewComplectationItemName = downListControl.Text;
            }
            complectation.IsSaved = false;
        }
Пример #22
0
        private void tbxTime_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TimePicker timePicker = sender as TimePicker;

            if (timePicker == null)
            {
                return;
            }
            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(timePicker);

            if (dgrow == null)
            {
                return;
            }

            ReportsSetting reportsSetting = (ReportsSetting)dgrow.Item;

            if (reportsSetting == null)
            {
                return;
            }
            reportsSetting.Time = timePicker.Text;
        }
        //Обработка изменения количества комплектаций (в каждой строке)
        void DudCount_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            DecimalUpDown decimalUpDown = sender as DecimalUpDown;

            if (decimalUpDown == null)
            {
                return;
            }

            DataGridRow row = FindItem.FindParentItem <DataGridRow>(decimalUpDown);

            if (row == null)
            {
                return;
            }

            Complectation complectation = (Complectation)row.Item;

            if (complectation == null)
            {
                return;
            }
            try
            {
                if (complectation.Complectation_count == (int)decimalUpDown.Value)
                {
                    complectation.IsSaved = true;
                    return;
                }
            }
            catch
            {
                complectation.Complectation_count = 0;
            }
            complectation.IsSaved             = false;
            complectation.Complectation_count = (int)decimalUpDown.Value;
        }
Пример #24
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
            if (button == null)
            {
                return;
            }
            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(button);

            if (dgrow == null)
            {
                return;
            }

            ReportsSetting reportsSetting = (ReportsSetting)dgrow.Item;

            if (reportsSetting == null)
            {
                return;
            }
            if (!reportsSetting.save())
            {
                System.Windows.MessageBox.Show("Не удалось сохранить настройку отчета. Подробности см. в логе ошибок!");
            }
            else
            {
                if (reportsSetting.NextDateCreated != null)
                {
                    System.Windows.MessageBox.Show("Настройка выгрузки сохранена.\nСледующая дата выгрузки " + ((DateTime)reportsSetting.NextDateCreated).ToString());
                }
                else
                {
                    System.Windows.MessageBox.Show("Настройка выгрузки сохранена.\nСледующая дата выгрузки - не установлено.");
                }
            }
        }
        //Выбор существующего наименования из выпадающего списка
        void DlcComplectationItem_OnSelect(object sender, StangradCRM.Controls.SelectionChanged e)
        {
            StangradCRM.Controls.DownListControl downList
                = sender as StangradCRM.Controls.DownListControl;
            if (downList == null)
            {
                return;
            }

            DataGridRow row = FindItem.FindParentItem <DataGridRow>(downList);

            if (row == null)
            {
                return;
            }

            Complectation complectation = (Complectation)row.Item;

            if (complectation == null)
            {
                return;
            }

            if (e.Value != null)
            {
                int id_complectation_item = (int)e.Value;
                if (complectation.Id_complectation_item == id_complectation_item)
                {
                    complectation.IsSaved = true;
                    return;
                }
                ComplectationItem item = ComplectationItemViewModel.instance().getById(id_complectation_item);
                complectation.Id_complectation_item = id_complectation_item;
                complectation.IsSaved = false;
            }
        }
        void RbnSelected_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = sender as RadioButton;

            if (radioButton == null)
            {
                return;
            }

            DataGridRow dgrow = FindItem.FindParentItem <DataGridRow>(radioButton);

            if (dgrow == null)
            {
                return;
            }

            Equipment equipment = (Equipment)dgrow.Item;

            if (equipment == null)
            {
                return;
            }
            equipment.IsSelected = true;
        }
Пример #27
0
        /// <summary>
        /// Wears an item
        /// </summary>
        /// <param name="player">The Player</param>
        /// <param name="itemToWear">Item to wear</param>
        public static void WearItem(Player player, string itemToWear, bool wield = false)
        {
            var room = Cache.getRoom(player);

            if (string.IsNullOrEmpty(itemToWear))
            {
                HubContext.SendToClient("Wear what?", player.HubGuid);
                return;
            }

            var oldPlayer = player;

            if (!itemToWear.Equals("all", StringComparison.CurrentCultureIgnoreCase))
            {
                var    findObject = Events.FindNth.Findnth(itemToWear);
                int    nth        = findObject.Key;
                string itemToFind = findObject.Value;

                var foundItem = FindItem.Item(player.Inventory, nth, itemToFind, Item.ItemLocation.Inventory);
                // player.Inventory.Find(i => i.name.ToLower().Contains(itemToWear.ToLower()));

                if (foundItem == null)
                {
                    if (wield)
                    {
                        HubContext.SendToClient("You do not have that item to wield.", player.HubGuid);
                        return;
                    }

                    HubContext.SendToClient("You do not have that item to wear.", player.HubGuid);
                    return;
                }



                foundItem.location = Item.ItemLocation.Worn;
                var slot = Enum.GetName(typeof(Item.EqSlot), foundItem.slot);

                //TODO: WTF is this?
                var eqLocation = player.Equipment.GetType().GetProperty(slot);

                if (slot == null)
                {
                    return;
                } // Log error? What the hell is eqLocation?

                var hasValue = eqLocation.GetValue(player.Equipment);

                if (hasValue.ToString() != "Nothing")
                {
                    RemoveItem(player, hasValue.ToString(), true);
                }

                eqLocation.SetValue(player.Equipment, foundItem.name);

                if (foundItem.ArmorRating != null)
                {
                    player.ArmorRating += foundItem.ArmorRating.Armour;
                }

                if (!wield || !slot.Equals(Item.EqSlot.Wielded.ToString()))
                {
                    HubContext.SendToClient("You wear " + foundItem.name, player.HubGuid);

                    var    result  = AvsAnLib.AvsAn.Query(foundItem.name);
                    string article = result.Article;

                    foreach (var character in room.players)
                    {
                        if (player != character)
                        {
                            var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wears {article} {foundItem.name}";

                            HubContext.SendToClient(roomMessage, character.HubGuid);
                        }
                    }

                    //Wear event

                    CheckEvent.FindEvent(CheckEvent.EventType.Wear, player, foundItem.name);
                }
                else
                {
                    HubContext.SendToClient("You wield " + foundItem.name, player.HubGuid);

                    var    result  = AvsAnLib.AvsAn.Query(foundItem.name);
                    string article = result.Article;

                    foreach (var character in room.players)
                    {
                        if (player != character)
                        {
                            var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wields {article} {foundItem.name}";

                            HubContext.SendToClient(roomMessage, character.HubGuid);
                        }
                    }
                }
                Score.UpdateUiInventory(player);
                Score.ReturnScoreUI(player);
            }
            else
            {
                var listOfItemsWorn = string.Empty;
                foreach (var item in player.Inventory.Where(x => x.location.Equals(Item.ItemLocation.Inventory)))
                {
                    if (item.location == Item.ItemLocation.Inventory && item.equipable == true)
                    {
                        var slot = Enum.GetName(typeof(Item.EqSlot), item.slot);

                        //TODO: WTF is this?
                        if (slot != null)
                        {
                            var eqLocation = player.Equipment.GetType().GetProperty(slot);


                            if (eqLocation != null)
                            {
                                var hasValue = eqLocation.GetValue(player.Equipment);

                                if (hasValue.ToString() != "Nothing")
                                {
                                    RemoveItem(player, hasValue.ToString(), true);
                                }
                            }
                            item.location = Item.ItemLocation.Worn;
                            eqLocation.SetValue(player.Equipment, item.name);

                            if (item.ArmorRating != null)
                            {
                                player.ArmorRating += item.ArmorRating.Armour;
                            }


                            listOfItemsWorn += $" {item.name}";


                            if (!wield || !slot.Equals("wield", StringComparison.CurrentCultureIgnoreCase))
                            {
                                var    result  = AvsAnLib.AvsAn.Query(item.name);
                                string article = result.Article;


                                HubContext.SendToClient("You wear " + article + item.name, player.HubGuid);


                                foreach (var character in room.players)
                                {
                                    if (player != character)
                                    {
                                        var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wears {article} {item.name}";

                                        HubContext.SendToClient(roomMessage, character.HubGuid);
                                    }
                                }
                            }
                            else
                            {
                                var    result  = AvsAnLib.AvsAn.Query(item.name);
                                string article = result.Article;

                                HubContext.SendToClient("You wield " + article + item.name, player.HubGuid);


                                foreach (var character in room.players)
                                {
                                    if (player != character)
                                    {
                                        var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} wields {article} {item.name}";

                                        HubContext.SendToClient(roomMessage, character.HubGuid);
                                    }
                                }
                            }
                        }
                    }
                }

                CheckEvent.FindEvent(CheckEvent.EventType.Wear, player, listOfItemsWorn);
            }
            Score.UpdateUiInventory(player);
            Score.ReturnScoreUI(player);
            Cache.updatePlayer(player, oldPlayer);
        }
Пример #28
0
        public static void StarContinualLight(Player player, Room room, string commandOptions = "")
        {
            //Check if player has spell
            var hasSpell = Skill.CheckPlayerHasSkill(player, ContinualLightAb().Name);

            if (hasSpell == false)
            {
                HubContext.Instance.SendToClient("You don't know that spell.", player.HubGuid);
                return;
            }

            var canDoSkill = Skill.CanDoSkill(player);

            if (!canDoSkill)
            {
                return;
            }

            #region refactor

            string[] options      = commandOptions.Split(' ');
            int      nth          = -1;
            string   getNth       = string.Empty;
            string   objectToFind = String.Empty;


            if (options.Length == 3)
            {
                objectToFind = options[2];

                if (objectToFind.IndexOf('.') != -1)
                {
                    getNth = objectToFind.Substring(0, objectToFind.IndexOf('.'));
                    int.TryParse(getNth, out nth);
                }
            }
            else if (options.Length > 3)
            {
                objectToFind = options[2];

                if (objectToFind.IndexOf('.') != -1)
                {
                    getNth = objectToFind.Substring(0, objectToFind.IndexOf('.'));
                    int.TryParse(getNth, out nth);
                }

                _color = options[3];
            }

            #endregion

            if (nth == 0)
            {
                nth = -1;
            }


            _target = FindItem.Item(player.Inventory, nth, objectToFind, Item.Item.ItemLocation.Inventory);

            if (_target == null && options.Length == 3)
            {
                _color = options[2];
            }


            if (ReturnColor(_color) == null)
            {
                HubContext.Instance.SendToClient($"{_color} is not valid, you can choose from: Blue, Red, Green, Yellow, Purple, Orange and White", player.HubGuid);

                return;
            }

            if (!_taskRunnning && _target != null)
            {
                if (player.ManaPoints < ContinualLightAb().ManaCost)
                {
                    HubContext.Instance.SendToClient("You clasp your hands together attempting to draw energy between your hands but fail", player.HubGuid);

                    return;
                }

                //TODO REfactor

                player.ManaPoints -= ContinualLightAb().ManaCost;

                Score.UpdateUiPrompt(player);

                if (_target.itemFlags == null)
                {
                    _target.itemFlags = new List <Item.Item.ItemFlags>();
                }

                if (_target.itemFlags.Contains(Item.Item.ItemFlags.glow))
                {
                    HubContext.Instance.SendToClient("This item is already illuminated", player.HubGuid);
                    return;
                }


                var    result  = AvsAnLib.AvsAn.Query(_target.name);
                string article = result.Article;


                HubContext.Instance.SendToClient($"You grasp {article} {_target.name} between your hands which starts to shimmer a slight {_color} colour", player.HubGuid);



                foreach (var character in room.players)
                {
                    if (character != player)
                    {
                        var hisOrHer    = Helpers.ReturnHisOrHers(player, character);
                        var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} grasps {article} {_target.name} between {hisOrHer} hands which starts to shimmer a slight {_color} colour";

                        HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                    }
                }



                Task.Run(() => DoContinualLight(player, room));
            }
            else
            {
                if (_target == null)
                {
                    if (player.ManaPoints < ContinualLightAb().ManaCost)
                    {
                        HubContext.Instance.SendToClient("You attempt to draw energy but fail", player.HubGuid);

                        return;
                    }

                    //TODO REfactor
                    player.ManaPoints -= ContinualLightAb().ManaCost;

                    Score.UpdateUiPrompt(player);

                    HubContext.Instance.SendToClient($"You clasp your hands together forming a bright {_color} ball between them", player.HubGuid);

                    foreach (var character in room.players)
                    {
                        if (character != player)
                        {
                            var roomMessage = $"{ Helpers.ReturnName(player, character, string.Empty)} 's hands start to glow as they begin chanting the Continual light spell";

                            HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                        }
                    }

                    Task.Run(() => DoContinualLight(player, room));
                }
            }
        }
Пример #29
0
        public static void DoLockPick(IHubContext context, PlayerSetup.Player player, Room room, string item)
        {
            //Check if player has spell
            var hasSkill = Skill.CheckPlayerHasSkill(player, LockPickAb().Name);

            if (hasSkill == false)
            {
                context.SendToClient("You don't know that skill.", player.HubGuid);
                return;
            }

            var canDoSkill = Skill.CanDoSkill(player);

            if (!canDoSkill)
            {
                return;
            }

            if (string.IsNullOrEmpty(item))
            {
                context.SendToClient("You need to specify an item.", player.HubGuid);
                return;
            }

            var hasItem = FindItem.Item(room.items, -1, item, Item.Item.ItemLocation.Room);


            if (hasItem == null)
            {
                context.SendToClient("Nothing here by that name.", player.HubGuid);
                return;
            }


            if (!hasItem.locked)
            {
                context.SendToClient($"{Helpers.ReturnName(null, null, hasItem.name).ToLower()} is already unlocked.", player.HubGuid);
                return;
            }


            var chanceOfSuccess = Helpers.Rand(LockPickDifficulty(hasItem.LockPick), 100);
            var skill           = player.Skills.FirstOrDefault(x => x.Name.Equals("Lock Pick"));

            var skillProf = skill.Proficiency;

            if (skillProf >= chanceOfSuccess)
            {
                HubContext.Instance.SendToClient("*CLICK!*", player.HubGuid);

                //Itme stats
                HubContext.Instance.SendToClient($"You unlock {Helpers.ReturnName(null, null, hasItem.name).ToLower()}", player.HubGuid);

                hasItem.locked = false;

                Score.ReturnScoreUI(player);
            }
            else
            {
                //something random
                HubContext.Instance.SendToClient($"You fail to unlock {Helpers.ReturnName(null, null, hasItem.name).ToLower().ToLower()}.", player.HubGuid);

                Score.ReturnScoreUI(player);
            }
        }
 public ItemCentralHomePage FindAnItem()
 {
     Find();
     FindItem.Wait(3).Click();
     return(new ItemCentralHomePage());
 }