Пример #1
0
        private Task <ChartDataSource> OnInit(int dsCount, int daCount)
        {
            var ds = new ChartDataSource();

            ds.Options.XAxes.Add(new ChartAxes()
            {
                LabelString = "天数"
            });
            ds.Options.YAxes.Add(new ChartAxes()
            {
                LabelString = "数值"
            });

            ds.Labels = Enumerable.Range(1, daCount).Select(i => i.ToString());

            for (var index = 0; index < dsCount; index++)
            {
                ds.Data.Add(new ChartDataset()
                {
                    Label = $"数据集 {index}",
                    Data  = Enumerable.Range(1, daCount).Select(i => Randomer.Next(20, 37)).Cast <object>()
                });
            }
            return(Task.FromResult(ds));
        }
 private void Type_Like_Human(IWebElement element, string str)
 {
     foreach (char c in str)
     {
         element.SendKeys(c.ToString());
         Thread.Sleep(Randomer.Next(150, 450));
     }
 }
Пример #3
0
        public List <LearningSetItem> GetItemsForKanji(Kanji kanji)
        {
            List <LearningSetItem> itemsForKanji = items.Values.Where(i => i.ContainsKanjiOrReading(kanji.kanji, kanji.reading, false)).ToList();

            if (itemsForKanji.Count > 5)
            {
                itemsForKanji = Randomer.FromList(itemsForKanji, 5);
            }
            return(itemsForKanji);
        }
Пример #4
0
 void OnEnable()
 {
     if (main != null)
     {
         Destroy(this);
     }
     else
     {
         main = this;
     }
 }
Пример #5
0
    public List <LearningSetItem> GetItemsForSentence(ExampleSentence sentence)
    {
        List <string>          kanji = sentence.nouns.Union(sentence.conjugations.Select(c => GetDictionaryFormForConjugation(c))).ToList();
        List <LearningSetItem> items = extendedSet.GetItemsInKanjiList(kanji);

        if (items.Count > 5)
        {
            items = Randomer.FromList(items, 5);
        }
        return(items);
    }
 public void Start()
 {
     if (KeepType.Instance.Difficulty == "hard")
     {
         agent = new MCTS(pokemonRenderer);
     }
     else
     {
         agent = new Randomer(pokemonRenderer);
     }
 }
Пример #7
0
    private Task <ChartDataSource> OnInit()
    {
        var ds = new ChartDataSource();

        ds.Options.Title = "Pie 饼图";
        ds.Labels        = Utility.Colors.Take(PieDataCount);
        for (var index = 0; index < PieDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Label = $"数据集 {index}",
                Data  = Enumerable.Range(1, PieDataCount).Select(i => Randomer.Next(20, 37)).Cast <object>()
            });
        }
        return(Task.FromResult(ds));
    }
Пример #8
0
    public List <ExampleSentence> GetSentencesForItem(LearningSetItem item)
    {
        string kanji = item.FirstKanji();

        if (kanji == null)
        {
            kanji = item.FirstReading();                 // in case of kana only, e.g. suru, coffee
        }
        // sentences where the nouns array contains the kanji, or the conjugations array contains a conjugated form of the kanji
        // jumping through a hoop backwards!
        List <ExampleSentence> examples = sentences.Where(s => s.nouns.Contains(kanji) ||
                                                          s.conjugations.Where(c => GetDictionaryFormForConjugation(c) == kanji).Count() > 0).ToList();

        if (examples.Count > 5)
        {
            examples = Randomer.FromList(examples, 5);
        }
        return(examples);
    }
Пример #9
0
    private Task <ChartDataSource> OnInit(bool stacked)
    {
        var ds = new ChartDataSource();

        ds.Options.Title     = "Bar 柱状图";
        ds.Options.X.Title   = "天数";
        ds.Options.Y.Title   = "数值";
        ds.Options.X.Stacked = stacked;
        ds.Options.Y.Stacked = stacked;
        ds.Labels            = Enumerable.Range(1, BarDataCount).Select(i => i.ToString());
        for (var index = 0; index < BarDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Label = $"数据集 {index}",
                Data  = Enumerable.Range(1, BarDataCount).Select(i => Randomer.Next(20, 37)).Cast <object>()
            });
        }
        return(Task.FromResult(ds));
    }
Пример #10
0
        private Task <ChartDataSource> OnBubbleInit(int dsCount, int daCount)
        {
            var ds = new ChartDataSource();

            ds.Labels = Enumerable.Range(1, daCount).Select(i => i.ToString());

            for (var index = 0; index < dsCount; index++)
            {
                ds.Data.Add(new ChartDataset()
                {
                    Label = $"数据集 {index}",
                    Data  = Enumerable.Range(1, daCount).Select(i => new
                    {
                        x = Randomer.Next(10, 40),
                        y = Randomer.Next(10, 40),
                        r = Randomer.Next(1, 20)
                    })
                });
            }
            return(Task.FromResult(ds));
        }
Пример #11
0
        public static int CalNormalDamage(BattleCharacter attack)
        {
            float damage = Randomer.RandomMinAndMax(
                attack[HeroPropertyType.DamageMin].FinalValue,
                attack[HeroPropertyType.DamageMax].FinalValue);

            switch (attack.Category)
            {
            case HeroCategory.Agility:
                damage += attack[HeroPropertyType.Agility].FinalValue;
                break;

            case HeroCategory.Force:
                damage += attack[HeroPropertyType.Force].FinalValue;
                break;

            case HeroCategory.Knowledge:
                damage += attack[HeroPropertyType.Knowledge].FinalValue;
                break;
            }
            return((int)damage);
        }
Пример #12
0
    private Task <ChartDataSource> OnInit()
    {
        var ds = new ChartDataSource
        {
            Labels = Enumerable.Range(1, BubbleDataCount).Select(i => i.ToString())
        };

        ds.Options.Title = "Bubble 气泡图";

        for (var index = 0; index < BubbleDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Label = $"数据集 {index}",
                Data  = Enumerable.Range(1, BubbleDataCount).Select(i => new
                {
                    x = Randomer.Next(10, 40),
                    y = Randomer.Next(10, 40),
                    r = Randomer.Next(1, 20)
                })
            });
        }
        return(Task.FromResult(ds));
    }
Пример #13
0
 public void SetWork(IPart obj, Worker[] builders)
 {
     builders[Randomer.Next(builders.Length)].AddSlice(obj);
 }
Пример #14
0
        private void SecretStart(string choosedGame)
        {
            List <string> links = new List <string>();

            if (choosedGame == "Metro 2033")
            {
                links = Metro33Links.Links;
            }
            else
            {
                links = VampLegendLinks.Links;
            }
            if (links.Count == 0)
            {
                MessageBox.Show("Ошибка! Не найдены ссылки на группы", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "GG", LogMessage = "Подключение прокси...", UserName = String.Empty
            });

            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Environment.CurrentDirectory);

            service.HideCommandPromptWindow = true;

            FirefoxProfile profile = new FirefoxProfile(Environment.CurrentDirectory + $@"\Fires\fireuser0");
            FirefoxOptions opts    = new FirefoxOptions();

            opts.Profile = profile;
            opts.AddArgument("--headless");

            FirefoxDriver drv = new FirefoxDriver(service, opts);

            drv.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

            try
            {
                drv.Navigate().GoToUrl("https://vk.com/login?to=aW0%2FYWN0PQ--&u=2");
            }
            catch
            {
                drv.Navigate().GoToUrl("https://vk.com/login?to=aW0%2FYWN0PQ--&u=2");
            }

            string[] logPass = _userClass.GetUsers[0].Split(':');
            #region LOGIN
            drv.FindElementByXPath("//*[@id=\"email\"]").SendKeys(logPass[0]);
            drv.FindElementByXPath("//*[@id=\"pass\"]").SendKeys(logPass[1]);
            drv.FindElementByXPath("//*[@id=\"login_button\"]").Click();
            #endregion
            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "GG", LogMessage = "Прокси подключено!", UserName = String.Empty
            });

            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "GG", LogMessage = $"Сбор аккаунтов...", UserName = String.Empty
            });
            int addedUsersCount = 0;

            List <string> linksIds = new List <string>();
            foreach (var group in links)
            {
                List <IWebElement> elems = new List <IWebElement>();
                Thread.Sleep(1500);
                drv.Navigate().GoToUrl(group);
                Thread.Sleep(1000);
                try
                {
                    drv.FindElementByXPath("//*[@id=\"group_followers\"]/a/div/span[1]").Click();
                }
                catch
                {
                    try { drv.FindElementByXPath("//*[@id=\"public_followers\"]/a/div/span[2]").Click(); }
                    catch { continue; }
                }

                foreach (IWebElement item in drv.FindElements(By.ClassName("fans_fan_lnk")))
                {
                    elems.Add(item);
                    if (elems.Count == 100)
                    {
                        break;
                    }
                }

                foreach (IWebElement link in elems)
                {
                    if (!_friendList.IsFriendExist(link.Text))
                    {
                        linksIds.Add(link.GetAttribute("href"));
                        string friend = link.Text;
                        friend = friend.Replace("\r\n", " ");
                        _savedNames.Add(friend);
                        addedUsersCount++;
                    }
                }
            }
            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "GG", LogMessage = $"Всего собрано: {addedUsersCount} аккаунтов", UserName = String.Empty
            });

            for (int i = 0; i < 400; i++)
            {
                _friendLinks.Add(linksIds[Randomer.Next(0, linksIds.Count)]);
            }
            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "GG", LogMessage = $"Выбрано 400 случайных аккаунтов", UserName = String.Empty
            });

            opts = null;
            drv.Dispose();
            drv.Quit();
        }
Пример #15
0
 public Account()
 {
     Bank.QuantityOfAccounts++;
     accountNumber = Bank.QuantityOfAccounts;
     interestRate  = (decimal)Randomer.NextDouble(1, 5) / 100;
 }
Пример #16
0
    private Task <ChartDataSource> OnInit(float tension, bool hasNull)
    {
        var ds = new ChartDataSource();

        ds.Options.Title   = "Line 折线图";
        ds.Options.X.Title = "天数";
        ds.Options.Y.Title = "数值";
        ds.Labels          = Enumerable.Range(1, LineDataCount).Select(i => i.ToString());
        for (var index = 0; index < LineDatasetCount; index++)
        {
            ds.Data.Add(new ChartDataset()
            {
                Tension = tension,
                Label   = $"数据集 {index}",
                Data    = Enumerable.Range(1, LineDataCount).Select((i, index) => (index == 2 && hasNull) ? null ! : (object)Randomer.Next(20, 37))
            });
Пример #17
0
 private void Awake()
 {
     Instance = this;
 }
Пример #18
0
        public bool StartAdding(string choosedGame, string addMessage)
        {
            SecretStart(choosedGame);

            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "AF", LogMessage = "Инициализация...", UserName = String.Empty
            });

            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Environment.CurrentDirectory);

            service.HideCommandPromptWindow = true;

            decimal dictSwitch = _userClass.GetUsers.Count / 10; // 10 - количество firefox профилей

            dictSwitch = Math.Floor(dictSwitch);

            int      dictPos       = 0;
            int      tempCount     = 0;
            int      tempDictUsing = 0;
            int      hrefsListed   = 0;
            bool     checkWhile    = true;
            DateTime date          = new DateTime();

            while (tempCount < 200 && hrefsListed < _friendLinks.Count)
            {
                foreach (var user in _userClass.GetUsers)
                {
                    if (tempDictUsing % dictSwitch == 0 && tempDictUsing != 0)
                    {
                        dictPos++;
                    }

                    FirefoxProfile profile = new FirefoxProfile(Environment.CurrentDirectory + $@"\Fires\fireuser{dictPos}");
                    _options         = new FirefoxOptions();
                    _options.Profile = profile;
                    _options.AddArgument("--headless");
                    string[] logPass = user.Split(':');

                    _driver = new FirefoxDriver(service, _options);
                    _logger.Invoke(LogIO.path, new Log {
                        Date = DateTime.Now, Method = "AF", LogMessage = "Открытие драйвера", UserName = logPass[0]
                    });

                    _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
                    try
                    {
                        _driver.Navigate().GoToUrl("https://vk.com/login?to=aW0%2FYWN0PQ--&u=2");
                    }
                    catch { }
                    _driver.Navigate().GoToUrl("https://vk.com/login?to=aW0%2FYWN0PQ--&u=2");

                    #region LOGIN
                    _driver.FindElementByXPath("//*[@id=\"email\"]").SendKeys(logPass[0]);
                    _driver.FindElementByXPath("//*[@id=\"pass\"]").SendKeys(logPass[1]);
                    _driver.FindElementByXPath("//*[@id=\"login_button\"]").Click();
                    #endregion


                    if (IsRecaptchaExist())
                    {
                        tempDictUsing++;
                        _logger.Invoke(LogIO.path, new Log {
                            Date = DateTime.Now, Method = "AF", LogMessage = "Ошибка! Найдена рекапча... Идет решение проблемы...", UserName = logPass[0]
                        });
                        Thread.Sleep(400000);
                        _driver.Quit();
                        continue;
                    }
                    _logger.Invoke(LogIO.path, new Log {
                        Date = DateTime.Now, Method = "AF", LogMessage = "Пользователь успешно залогинен", UserName = logPass[0]
                    });
                    #region ADD_FRIEND
                    List <string> localFriends = new List <string>();
                    bool          check        = true;
                    _logger.Invoke(LogIO.path, new Log {
                        Date = DateTime.Now, Method = "AF", LogMessage = "Добавление друзей...", UserName = logPass[0]
                    });
                    if (DateTime.Now.Hour - date.Hour == 1)
                    {
                        _logger.Invoke(LogIO.path, new Log {
                            Date = DateTime.Now, Method = "AF", LogMessage = $"Добавлено друзей: {tempCount} за время работы", UserName = String.Empty
                        });
                        date = DateTime.Now;
                    }
                    int addedUsersCount = 0;
                    for (int i = hrefsListed; i < _friendLinks.Count; i++)
                    {
                        if (!_friendList.IsFriendExist(_savedNames[i]))
                        {
                            _driver.Navigate().GoToUrl(_friendLinks[i]); //second user no enabling
                            try
                            {
                                _driver.FindElementByXPath("//*[@id=\"friend_status\"]/div[1]/button").Click();

                                if (IsRecaptchaExist())
                                {
                                    break;
                                }
                                hrefsListed++;
                                addedUsersCount++;
                                _driver.FindElementByClassName("page_actions_dd_label").Click();
                                _driver.FindElementByXPath("//*[@id=\"page_actions_wrap\"]/div[2]/a[2]").Click();
                                _driver.FindElementById("preq_input").SendKeys(addMessage);
                                _driver.FindElementByClassName("flat_button").Click();

                                localFriends.Add(_savedNames[i]);
                                tempCount++;
                            }
                            catch { }
                            if (hrefsListed == _friendLinks.Count)
                            {
                                check = false;
                                break;
                            }
                        }
                        else
                        {
                            hrefsListed++;
                        }
                    }
                    #endregion
                    if (localFriends.Count > 0)
                    {
                        _friendList.AddFriendsToFile(logPass[0], choosedGame, localFriends);
                    }
                    tempDictUsing++;
                    _options = null;
                    _driver.Dispose();
                    _driver.Quit();
                    Process[] proc = Process.GetProcessesByName("geckodriver");
                    foreach (var item in proc)
                    {
                        item.Kill();
                    }
                    Thread.Sleep(Randomer.Next(120000 * 10 / _userClass.GetUsers.Count, 180000 * 10 / _userClass.GetUsers.Count) * addedUsersCount);

                    if (!check)
                    {
                        checkWhile = false;
                        break;
                    }
                }
                if (!checkWhile)
                {
                    break;
                }
                dictPos       = 0;
                tempDictUsing = 0;
            }
            _logger.Invoke(LogIO.path, new Log {
                Date = DateTime.Now, Method = "AF", LogMessage = $"Заявки успешно отосланы! Общее количество разосланных заявок: {tempCount}", UserName = String.Empty
            });
            return(true);
        }