Exemplo n.º 1
0
    private void ClickBtnGetToDo(Transform btnGet, int cellIndex)
    {
        RawInfo rawInfo = this.rawInfoList.get_Item(cellIndex);
        int     acId    = rawInfo.acId;

        if (!Activity7DayManager.Instance.activityInfos.ContainsKey(acId))
        {
            DialogBoxUIViewModel.Instance.ShowAsConfirm(GameDataUtils.GetChineseContent(513193, false), GameDataUtils.GetChineseContent(513194, false), delegate
            {
                UIManagerControl.Instance.HideUI("OperateActivityUI");
                UIStackManager.Instance.PopUIPrevious(UIType.FullScreen);
            }, GameDataUtils.GetNoticeText(102), "button_orange_1", null);
            return;
        }
        ActivityItemInfo activityItemInfo = Activity7DayManager.Instance.activityInfos.get_Item(acId);
        bool             canGetFlag       = activityItemInfo.canGetFlag;

        if (!activityItemInfo.hasGetPrize)
        {
            if (canGetFlag)
            {
                if (BackpackManager.Instance.ShowBackpackFull())
                {
                    return;
                }
                Activity7DayManager.Instance.SendGetActivityItemPrizeReq(2, acId);
            }
            else
            {
                SourceReferenceUI.GoTo((int)rawInfo.servletId);
            }
        }
    }
Exemplo n.º 2
0
    private void SetBtnGet(Transform btnGet, int cellIndex)
    {
        RawInfo          rawInfo          = this.rawInfoList.get_Item(cellIndex);
        ActivityItemInfo activityItemInfo = Activity7DayManager.Instance.activityInfos.get_Item(rawInfo.acId);

        if (activityItemInfo == null)
        {
            return;
        }
        if (activityItemInfo.hasGetPrize)
        {
            btnGet.get_gameObject().SetActive(false);
            btnGet.GetComponent <Button>().set_enabled(false);
            btnGet.get_parent().FindChild("imgFinish").get_gameObject().SetActive(true);
        }
        else
        {
            btnGet.get_gameObject().SetActive(true);
            btnGet.GetComponent <Button>().set_enabled(true);
            if (activityItemInfo.canGetFlag)
            {
                ResourceManager.SetSprite(btnGet.GetComponent <Image>(), ResourceManager.GetIconSprite("button_yellow_1"));
                btnGet.FindChild("Text").GetComponent <Text>().set_text(GameDataUtils.GetChineseContent(513203, false));
            }
            else if (rawInfo.servletId == -1L)
            {
                btnGet.get_gameObject().SetActive(false);
            }
            else
            {
                ResourceManager.SetSprite(btnGet.GetComponent <Image>(), ResourceManager.GetIconSprite("button_orange_1"));
                btnGet.FindChild("Text").GetComponent <Text>().set_text(GameDataUtils.GetChineseContent(513202, false));
            }
        }
    }
Exemplo n.º 3
0
    public List <RawInfo> GetRawInfoList(int openDay = 0, int type = 0, bool isSort = false)
    {
        List <RawInfo> list = new List <RawInfo>();

        using (Dictionary <int, ActivityItemInfo> .Enumerator enumerator = this.activityInfos.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                KeyValuePair <int, ActivityItemInfo> current = enumerator.get_Current();
                RawInfo rawInfo = current.get_Value().rawInfo;
                if (rawInfo != null && (type == 0 || rawInfo.tab == (Tab.TAB)type) && (openDay == 0 || rawInfo.startDay == openDay))
                {
                    list.Add(rawInfo);
                }
            }
        }
        if (isSort)
        {
            list.Sort(delegate(RawInfo node1, RawInfo node2)
            {
                ActivityItemInfo activityItemInfo  = this.activityInfos.get_Item(node1.acId);
                ActivityItemInfo activityItemInfo2 = this.activityInfos.get_Item(node2.acId);
                if (activityItemInfo.canGetFlag != activityItemInfo2.canGetFlag)
                {
                    return(activityItemInfo2.canGetFlag.CompareTo(activityItemInfo.canGetFlag));
                }
                return(node1.acId.CompareTo(node2.acId));
            });
        }
        return(list);
    }
Exemplo n.º 4
0
        //We are trying to split name and country
        static Pair tryGetNameAndCountry(string partname, DemoNames names)
        {
            var country = "";

            if (names != null && (partname == names.dfName || partname == names.uName || partname == names.oName))
            {
                //name can contains dots so if username from parameters equals part in brackets, no country here
                return(new Pair(partname, country));
            }
            int i = partname.LastIndexOf('.');

            if (i < 0)
            {
                i = partname.LastIndexOf(',');
            }
            if (i > 0 && i + 1 < partname.Length)
            {
                country = partname.Substring(i + 1, partname.Length - i - 1).Trim();
                country = RawInfo.removeColors(country);
                if (country.Where(c => char.IsNumber(c)).Count() == 0)
                {
                    return(new Pair(partname.Substring(0, i), country));
                }
            }
            return(new Pair(partname, ""));
        }
Exemplo n.º 5
0
        //Trying to get time from part of demo filename.
        static TimeSpan?tryGetTimeFromBrackets(string partname)
        {
            var parts = partname.Split("-".ToArray());

            if (parts.Length < 2 || parts.Length > 3)
            {
                parts = partname.Split(".".ToArray());
                if (parts.Length < 2 || parts.Length > 3)
                {
                    return(null);
                }
            }
            foreach (string part in parts)
            {
                if (part.Length == 0)
                {
                    return(null);
                }
                foreach (char c in part)
                {
                    if (!char.IsDigit(c))
                    {
                        return(null);
                    }
                }
            }
            return(RawInfo.getTimeSpan(partname));
        }
Exemplo n.º 6
0
    private void SetOneCell(int cellIndex, RawInfo rawInfo)
    {
        GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("Activity7DayCell");

        instantiate2Prefab.get_transform().SetParent(this.scroll, false);
        instantiate2Prefab.get_gameObject().SetActive(true);
        instantiate2Prefab.set_name(cellIndex.ToString());
        Transform btnGet = instantiate2Prefab.get_transform().FindChild("btnGet");

        btnGet.GetComponent <Button>().get_onClick().RemoveAllListeners();
        btnGet.GetComponent <Button>().get_onClick().AddListener(delegate
        {
            this.OnClickBtnGet(btnGet.get_gameObject());
        });
        this.SetBtnGet(btnGet, cellIndex);
        Transform  transform  = instantiate2Prefab.get_transform().FindChild("north").FindChild("txtCondition");
        string     text       = GameDataUtils.GetChineseContent((int)rawInfo.chineseId, false);
        List <int> needParams = rawInfo.needParams;

        if (rawInfo.tab == Tab.TAB.PlayPass)
        {
            if (rawInfo.subTab == SubTab.ST.EliteDungeon)
            {
                JingYingFuBenPeiZhi jingYingFuBenPeiZhi = DataReader <JingYingFuBenPeiZhi> .Get(needParams.get_Item(0));

                if (jingYingFuBenPeiZhi != null)
                {
                    JJingYingFuBenQuYu jJingYingFuBenQuYu = DataReader <JJingYingFuBenQuYu> .Get(jingYingFuBenPeiZhi.map);

                    string chineseContent = GameDataUtils.GetChineseContent(jingYingFuBenPeiZhi.bossName, false);
                    text = string.Format(text, chineseContent);
                }
            }
        }
        else
        {
            string[] array = new string[needParams.get_Count()];
            for (int i = 0; i < needParams.get_Count(); i++)
            {
                int grade = needParams.get_Item(i);
                if (i == 1 && rawInfo.subTab == SubTab.ST.PetUpStage)
                {
                    array[i] = this.GetPetGrade(grade);
                }
                else
                {
                    array[i] = grade.ToString();
                }
            }
            text = string.Format(text, array);
        }
        transform.GetComponent <Text>().set_text(text);
        ItemInfo1 rewardItem = rawInfo.rewardItem;
        Transform parent     = instantiate2Prefab.get_transform().FindChild("imgGrid");

        if (rewardItem != null)
        {
            ItemShow.ShowItem(parent, rewardItem.itemId, (long)rewardItem.count, false, UINodesManager.T2RootOfSpecial, 2001);
        }
    }
Exemplo n.º 7
0
        public string fName  = null;        //name from the filename

        public void setNamesByPlayerInfo(Dictionary <string, string> playerInfo)
        {
            if (playerInfo != null)
            {
                dfName = Ext.GetOrNull(playerInfo, "df_name");
                uName  = normalizeName(RawInfo.removeColors(Ext.GetOrNull(playerInfo, "name")));
            }
        }
Exemplo n.º 8
0
 private void WriteTable(DataTable dt1, DataTable dt2, RawInfo existInfo)
 {
     dgvArrange.DataSource   = dt1;
     dgvStatistic.DataSource = dt2;
     CorrectTwoDgv();
     this.rawInfo = existInfo;
     StatusChange(Status.QueryFinished);
 }
Exemplo n.º 9
0
        private double GetSizeInStack()
        {
            if (!string.IsNullOrEmpty(RawInfo) && RawInfo != "empty_string")
            {
                int begin  = RawInfo.IndexOf("Stack Size: ") + 12;
                int length = RawInfo.IndexOf("/") - begin;

                return(Convert.ToDouble(RawInfo.Substring(begin, length)));
            }
            return(0);
        }
Exemplo n.º 10
0
        private int GetStackSize()
        {
            if (!RawInfo.Contains("Stack Size:"))
            {
                return(1);
            }

            int res = Convert.ToInt32(Regex.Match(RawInfo, @"Stack Size: [0-9.]+/([0-9.]+)").Groups[1].Value);

            return(res);
        }
Exemplo n.º 11
0
 public void setConsoleName(string onlineName, bool isOnline)
 {
     if (isOnline)
     {
         oName = normalizeName(RawInfo.removeColors(onlineName));
     }
     else
     {
         cName = normalizeName(RawInfo.removeColors(onlineName));
     }
 }
Exemplo n.º 12
0
        public IEnumerable <Output> post(RawInfo rawInfo)
        {
            ConnectionAudit connection = new ConnectionAudit();

            rawInfo.Date = DateTime.Now;
            connection.insertAudit(rawInfo);

            CalculateTravels calculateTravels = new CalculateTravels();


            return(calculateTravels.calculate(rawInfo));
        }
Exemplo n.º 13
0
        public void PostTest()
        {
            var     controller = new TransformController();
            RawInfo rawInfo    = new RawInfo {
                Name = "Anita", Value = 123.45M
            };
            var      response  = controller.Post(rawInfo);
            Response converted = response.Data as Response;

            Assert.IsTrue(converted.ConvertedInfoValues.ConvertedValue.Equals("ONE HUNDRED AND TWENTY-THREE DOLLARS AND FORTY-FIVE CENTS"));
            Assert.IsTrue(converted.ConvertedInfoValues.Name.Equals(rawInfo.Name));
            Assert.IsNotNull(response.Data);
        }
Exemplo n.º 14
0
        public void calculateConstrainsWorkDaystLessThanZeroTest()
        {
            // Arrange
            RawInfo rawInfo = new RawInfo();

            rawInfo.WorkDays = 0;


            CalculateTravels calculateTravels = new CalculateTravels();
            List <Output>    output           = calculateTravels.calculate(rawInfo);

            Assert.AreEqual(0, output.Count);
        }
Exemplo n.º 15
0
        public void calculateConstrainsWorkDaysGreaterThanFiveHundredTest()
        {
            // Arrange
            RawInfo rawInfo = new RawInfo();

            rawInfo.WorkDays = 501;


            CalculateTravels calculateTravels = new CalculateTravels();
            List <Output>    output           = calculateTravels.calculate(rawInfo);

            Assert.AreEqual(0, output.Count);
        }
Exemplo n.º 16
0
    public bool GetDayRedPoint(int dayNum)
    {
        List <RawInfo> rawInfoList = this.GetRawInfoList(dayNum, 0, false);

        for (int i = 0; i < rawInfoList.get_Count(); i++)
        {
            RawInfo          rawInfo          = rawInfoList.get_Item(i);
            ActivityItemInfo activityItemInfo = this.activityInfos.get_Item(rawInfo.acId);
            if (activityItemInfo.canGetFlag)
            {
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 17
0
        private Price GetPrice()
        {
            Price price = new Price();

            if (!RawInfo.Contains("Note: ~price") && !RawInfo.Contains("Note: ~b/o"))
            {
                return(new Price());
            }

            if (Regex.IsMatch(RawInfo, "~b/o [0-9.]+/[0-9.]+"))
            {
                price.Cost           = Convert.ToDouble(Regex.Replace(RawInfo, @"([\w\s\W\n]+Note: ~b/o )|(/+[\w\s\W]*)|([^0-9.])", ""));
                price.ForNumberItems = Convert.ToInt32(Regex.Replace(RawInfo, @"([\w\s\W]+/)|([^0-9.])", ""));
                price.CurrencyType   = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", ""));
            }
            else if (Regex.IsMatch(RawInfo, @"~b/o +[0-9.]+\s\D*"))
            {
                price.Cost           = Convert.ToDouble(Regex.Replace(RawInfo, @"[\w\W]*~b/o |[^0-9.]*", "").Replace('.', ','));
                price.ForNumberItems = GetStackSize();
                price.CurrencyType   = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", ""));
            }
            else if (Regex.IsMatch(RawInfo, "~price [0-9.]+/[0-9.]+"))
            {
                price.Cost           = Convert.ToDouble(Regex.Replace(RawInfo, @"([\w\s\W\n]+Note: ~price )|(/+[\w\s\W]*)|([^0-9.])", ""));
                price.ForNumberItems = Convert.ToInt32(Regex.Replace(RawInfo, @"([\w\s\W]+/)|([^0-9.])", ""));
                price.CurrencyType   = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", ""));
            }
            else if (Regex.IsMatch(RawInfo, @"~price +[0-9.]+\s\D*"))
            {
                price.Cost           = Convert.ToDouble(Regex.Replace(RawInfo, @"[\w\W]*~price |[^0-9.]*", "").Replace('.', ','));
                price.ForNumberItems = GetStackSize();
                price.CurrencyType   = PoECurrencyManager.Instance.Currencies.GetCurrencyByName(Regex.Replace(RawInfo, @"[\w\s\W]+\d+\s|\n", ""));
            }

            if (!price.IsSet)
            {
                return(new Price());
            }
            else
            {
                return(price);
            }
        }
Exemplo n.º 18
0
 public bool GetRedPoint()
 {
     using (Dictionary <int, ActivityItemInfo> .Enumerator enumerator = this.activityInfos.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             KeyValuePair <int, ActivityItemInfo> current = enumerator.get_Current();
             if (current.get_Value().canGetFlag)
             {
                 RawInfo rawInfo = current.get_Value().rawInfo;
                 if (rawInfo != null && rawInfo.startDay <= this.startDay)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 19
0
        public void insertAudit(RawInfo rawinfo)
        {
            _con = new SqlConnection("Data Source=(localdb)\\ProjectsV13;database=Moving;Integrated Security=True");
            _con.Open();
            string insertQuery = "USE [Moving] INSERT INTO [dbo].[Audit] VALUES(" + rawinfo.Identification + ",'" + rawinfo.Date.ToLocalTime() + "')";

            _cmd = new SqlCommand(insertQuery, _con);
            try
            {
                _cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                _con.Close();
            }
            finally
            {
                _con.Close();
            }
        }
Exemplo n.º 20
0
        public void calculateConstrainsElementsValuesGreaterThanFiveHundredTest()
        {
            // Arrange
            // Arrange
            RawInfo rawInfo = new RawInfo();

            rawInfo.WorkDays     = 1;
            rawInfo.ElementValue = new List <int>();
            rawInfo.ElementValue.Add(4);

            rawInfo.ElementValue.Add(130);
            rawInfo.ElementValue.Add(30);
            rawInfo.ElementValue.Add(1);
            rawInfo.ElementValue.Add(1);


            CalculateTravels calculateTravels = new CalculateTravels();
            List <Output>    output           = calculateTravels.calculate(rawInfo);

            Assert.AreEqual("Case #1: 0", output[0].CaseDay + ": " + output[0].NumberMaxTravels);
        }
Exemplo n.º 21
0
        public JsonResult Post([FromBody] RawInfo value)
        {
            try
            {
                var conveterInfo = new ConvertedInfo {
                    Name = value.Name, ConvertedValue = value.Value.ToString()
                };

                decimal valueOfDecimal;
                if (Decimal.TryParse(value.Value.ToString(), out valueOfDecimal))

                {
                    conveterInfo.ConvertedValue = Utilities.Converter.NumberToWords(value.Value).ToUpper();
                    return(new JsonResult
                    {
                        Data = new Response {
                            Status = "success", Code = HttpStatusCode.OK.ToString(), ConvertedInfoValues = conveterInfo
                        }
                    });
                }


                else
                {
                    return new JsonResult {
                               Data = new Response {
                                   Status = "error", Code = HttpStatusCode.BadRequest.ToString(), ConvertedInfoValues = null, Error = "The value cannot be converted to a decimal"
                               }
                    }
                };
            }
            catch (Exception e)
            {
                return(new JsonResult {
                    Data = new Response {
                        Code = HttpStatusCode.BadRequest.ToString(), ConvertedInfoValues = null, Error = e.InnerException.ToString()
                    }
                });
            }
        }
Exemplo n.º 22
0
    public void RefreshBtnPages(int day)
    {
        this.tabList.Clear();
        this.pageTab = -1;
        List <RawInfo>             list       = Activity7DayManager.Instance.GetRawInfoList(day, 0, false);
        Dictionary <Tab.TAB, bool> dictionary = new Dictionary <Tab.TAB, bool>();

        for (int i = 0; i < list.get_Count(); i++)
        {
            RawInfo rawInfo = list.get_Item(i);
            dictionary.set_Item(rawInfo.tab, true);
        }
        using (Dictionary <Tab.TAB, bool> .Enumerator enumerator = dictionary.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                KeyValuePair <Tab.TAB, bool> current = enumerator.get_Current();
                this.tabList.Add(current.get_Key());
            }
        }
        this.tabList.Sort((Tab.TAB a, Tab.TAB b) => a.CompareTo(b));
        for (int j = 0; j < this.btnPages.Length; j++)
        {
            GameObject gameObject = this.btnPages[j].get_gameObject();
            if (j < this.tabList.get_Count())
            {
                Tab.TAB tAB = this.tabList.get_Item(j);
                gameObject.SetActive(true);
                gameObject.get_transform().FindChild("Text").GetComponent <Text>().set_text(GameDataUtils.GetChineseContent(this.strTypeName.get_Item(tAB), false));
            }
            else
            {
                gameObject.SetActive(false);
            }
        }
        if (this.tabList.get_Count() > 0)
        {
            this.pageTab = 0;
        }
    }
Exemplo n.º 23
0
        //Normalization of demo filenames in case they broken by discord or net
        static string getNormalizedFileName(FileInfo file)
        {
            string filename = file.Name;

            //rm_n2%5Bmdf.vq3%5D00.33.984%28h%40des.CountryHere%29.dm_68
            if (filename.Contains("%"))
            {
                filename = Uri.UnescapeDataString(filename);
            }

            string filenameNoExt = filename.Substring(0, filename.Length - file.Extension.Length);

            if (filenameNoExt.ToLowerInvariant().Contains(" — копия"))
            {
                filenameNoExt = Regex.Replace(filenameNoExt, "( — [к|К]опия( \\(\\d+\\))?)+", "");
            }
            if (filenameNoExt.ToLowerInvariant().Contains(" — copy"))
            {
                filenameNoExt = Regex.Replace(filenameNoExt, "( — [c|C]opy( \\(\\d+\\))?)+", "");
            }
            if (filenameNoExt.Contains("^"))
            {
                filenameNoExt = RawInfo.removeColors(filenameNoExt);
            }

            Match match;

            if (!Ext.ContainsAny(filenameNoExt, "(", ")"))
            {
                if (Ext.CountOf(filenameNoExt, '_') >= 2)
                {
                    //tamb10_df.vq3_00.11.304_nL_HaZarD.Russia_
                    if (Ext.CountOf(filenameNoExt, '_') >= 4)
                    {
                        match = Regex.Match(filenameNoExt, "([.][vV][qQ][3]|[.][cC][pP][mM]).*[_](\\d+[.]\\d{2}[.]\\d{3}|\\d{1,2}[.]\\d{3})");
                        if (match.Success && match.Groups.Count == 3)
                        {
                            try {
                                //group 0 = .vq3_00.11.304
                                //group 1 = .vq3
                                //group 2 = 00.11.304
                                var indexBracket1 = filenameNoExt.Substring(0, match.Index).LastIndexOf('_');
                                var indexBracket2 = match.Groups[2].Index - 1;
                                var indexBracket3 = match.Groups[2].Index + match.Groups[2].Length;
                                var indexBracket4 = filenameNoExt.Length - 1;

                                var chars = filenameNoExt.ToCharArray();
                                chars[indexBracket1] = '[';
                                chars[indexBracket2] = ']';
                                chars[indexBracket3] = '(';
                                chars[indexBracket4] = ')';

                                return(new string(chars) + file.Extension.ToLowerInvariant());
                            } catch (Exception ex) {
                            }
                        }
                    }

                    //runmikrob-4[df.vq3]00.14.488_JL.Ua_.dm_68
                    match = Regex.Match(filenameNoExt, "^.+[\\[].+[\\]](\\d+[.]\\d{2}[.]\\d{3}|\\d{1,2}[.]\\d{3})[_].+[_]$");
                    if (match.Success)
                    {
                        //group 0 = runmikrob-4[df.vq3]00.14.488_JL.Ua_
                        //group 1 = 00.14.488

                        var indexBracket1 = match.Groups[1].Index + match.Groups[1].Length;
                        var indexBracket2 = filenameNoExt.Length - 1;

                        var chars = filenameNoExt.ToCharArray();
                        chars[indexBracket1] = '(';
                        chars[indexBracket2] = ')';
                        return(new string(chars) + file.Extension.ToLowerInvariant());
                    }
                }

                //dfcomp009_3.792_VipeR_Russia.dm_68
                //dmp02a_jinx_13.880_t0t3r_germany.dm_68
                //fdcj2_3.408_[kzii]f_china.dm_66
                if (Ext.CountOf(filenameNoExt, '_') >= 3)
                {
                    match = Regex.Match(filenameNoExt, ".*[_](\\d+[.]\\d{2}[.]\\d{3}|\\d{1,2}[.]\\d{3})[_]");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        try {
                            //group 0 = dfcomp009_3.792_
                            //group 1 = 3.792
                            var mapnametime   = match.Groups[0].Value.Substring(0, match.Groups[0].Value.Length - 1);
                            var playerCountry = filenameNoExt.Substring(match.Groups[0].Length);
                            var split         = playerCountry.LastIndexOf('_');
                            if (split > 0)
                            {
                                var pa = playerCountry.ToCharArray();
                                pa[split]     = '.';
                                playerCountry = new string(pa);
                            }
                            return(mapnametime + "(" + playerCountry + ")" + file.Extension.ToLowerInvariant());
                        } catch (Exception ex) {
                        }
                    }
                }

                //r7-falkydf.cpm00.09.960xas.China.dm_68
                int index = Math.Max(filenameNoExt.IndexOf(".cpm"), filenameNoExt.IndexOf(".vq3"));
                if (index > 0)
                {
                    try {
                        int    i1      = filenameNoExt[index - 3] == 'm' ? index - 3 : index - 2;
                        int    i2      = filenameNoExt[index + 4] == '.' ? index + 6 : index + 4;
                        int    i3      = i2 + 9;
                        string mapname = filenameNoExt.Substring(0, i1);
                        string physic  = filenameNoExt.Substring(i1, i2 - i1);
                        string time    = filenameNoExt.Substring(i2, i3 - i2);
                        string name    = filenameNoExt.Substring(i3);
                        if (isDigits(time[0], time[1], time[3], time[4], time[7], time[8]))
                        {
                            return(string.Format("{0}[{1}]{2}({3}){4}", mapname, physic, time, name, file.Extension));
                        }
                    } catch (Exception ex) {
                    }
                }
            }

            //DraeliPowa1-[VQ3]-{InT33!Stormer}-{01.09.560}-[Russia].dm_68
            match = Regex.Match(filenameNoExt, "^.*-[[].{3,}]-{(.*)}-{(\\d+[.]\\d{2}[.]\\d{3}|\\d{1,2}[.]\\d{3})}-[[](.*)[]]$");
            if (match.Success && match.Groups.Count == 4)
            {
                //group 0 = DraeliPowa1-[VQ3]-{InT33!Stormer}-{01.09.560}-[Russia]
                //group 1 = InT33!Stormer
                //group 2 = 01.09.560
                //group 3 = Russia
                var p1 = filenameNoExt.Substring(0, match.Groups[1].Index - 2);
                return(p1 + match.Groups[2].Value + "(" + match.Groups[1].Value + "." + match.Groups[3].Value + ")" + file.Extension.ToLowerInvariant());
            }

            return(filename);
        }
Exemplo n.º 24
0
        //We get the filled demo from the full raw information pulled from the demo
        public static Demo GetDemoFromRawInfo(RawInfo raw)
        {
            var file = new FileInfo(raw.demoPath);

            var frConfig = raw.getFriendlyInfo();

            Demo demo = new Demo();

            demo.rawInfo = raw;

            //file
            demo.file = file;
            if (frConfig.Count == 0 || !frConfig.ContainsKey(RawInfo.keyClient))
            {
                demo.hasError = true;
                demo.isBroken = true;
                return(demo);
            }

            //config names
            var names = new DemoNames();

            names.setNamesByPlayerInfo(Ext.GetOrNull(frConfig, RawInfo.keyPlayer));

            //time from triggers
            if (raw.fin.HasValue)
            {
                demo.time        = TimeSpan.FromMilliseconds(raw.fin.Value.Value.time);
                demo.hasTr       = raw.fin.Value.Key > 1;
                demo.triggerTime = true;
            }

            var timestrings = raw.timeStrings;

            var fastestTimeString = getFastestTimeStringInfo(timestrings, names);

            if (demo.time.TotalMilliseconds > 0)
            {
                var date = timestrings.LastOrDefault(x => x.recordDate != null);
                demo.recordTime = date?.recordDate;
            }
            else
            {
                //time from commands
                if (fastestTimeString != null)
                {
                    demo.time       = fastestTimeString.time;
                    demo.recordTime = fastestTimeString.recordDate;

                    var user = raw.getPlayerInfoByPlayerName(fastestTimeString.oName);
                    if (user != null)
                    {
                        names.setNamesByPlayerInfo(user);
                    }
                }
            }
            if (fastestTimeString != null)
            {
                names.setOnlineName(fastestTimeString.oName);
            }

            var filename       = demo.normalizedFileName;
            var countryAndName = getNameAndCountry(filename);

            if (Ext.ContainsAny(countryAndName, tasTriggers))
            {
                demo.isTas = true;
                foreach (string tasFlag in tasTriggers)
                {
                    countryAndName = removeSubstr(countryAndName, tasFlag);
                }
            }
            var countryNameParsed = tryGetNameAndCountry(countryAndName, names);

            //fle name
            names.setBracketsName(countryNameParsed.Key);   //name from the filename

            demo.playerName = names.chooseNormalName();

            //demo has not info about country, so take it from filename
            demo.country = countryNameParsed.Value;

            //at least some time (from name of demo)
            if (demo.time.TotalMilliseconds > 0)
            {
                demo.rawTime = true;
            }
            else
            {
                var demoNameTime = tryGetTimeFromFileName(filename);
                if (demoNameTime != null)
                {
                    demo.time = demoNameTime.Value;
                }
            }

            //Map
            var mapInfo = raw.rawConfig.ContainsKey(Q3Const.Q3_DEMO_CFG_FIELD_MAP) ? raw.rawConfig[Q3Const.Q3_DEMO_CFG_FIELD_MAP] : "";
            var mapName = Ext.GetOrNull(frConfig[RawInfo.keyClient], "mapname");

            //If in mapInfo the name of the same map is written, then we take the name from there
            if (mapName.ToLowerInvariant().Equals(mapInfo.ToLowerInvariant()))
            {
                demo.mapName = mapInfo;
            }
            else
            {
                demo.mapName = mapName.ToLowerInvariant();
            }

            //tas
            var modPhysic = getModPhysic(filename);

            if (modPhysic != null && Ext.ContainsAny(modPhysic, tasTriggers))
            {
                demo.isTas = true;
            }

            //Gametype
            var gInfo = raw.gameInfo;

            if (gInfo.isDefrag)
            {
                if (!string.IsNullOrEmpty(gInfo.modType))
                {
                    demo.modphysic = string.Format("{0}.{1}.{2}", gInfo.gameTypeShort, gInfo.gameplayTypeShort, gInfo.modType);
                }
                else
                {
                    demo.modphysic = string.Format("{0}.{1}", gInfo.gameTypeShort, gInfo.gameplayTypeShort);
                }
            }
            else
            {
                demo.modphysic = string.Format("{0}.{1}", gInfo.gameNameShort, gInfo.gameTypeShort);
            }

            if (demo.hasTr)
            {
                demo.modphysic = string.Format("{0}.{1}", demo.modphysic, "tr");
            }
            if (demo.isTas)
            {
                demo.modphysic = string.Format("{0}.{1}", demo.modphysic, "tas");
            }

            //If demo has cheats, write it
            demo.validDict = checkValidity(demo.time.TotalMilliseconds > 0, demo.rawTime, gInfo);

            if (demo.triggerTime)
            {
                demo.userId = tryGetUserIdFromFileName(file);
            }
            return(demo);
        }
Exemplo n.º 25
0
        //Get the details of the demo from the file name
        public static Demo GetDemoFromFile(FileInfo file)
        {
            Demo demo = new Demo();

            demo.file = file;
            var filename = file.Name;

            demo.recordTime = demo.file.CreationTime;

            int index = Math.Max(filename.IndexOf(".cpm"), filename.IndexOf(".vq3"));

            if (index <= 0)
            {
                demo.hasError = true;
                return(demo);
            }
            int firstSquareIndex = filename.Substring(0, index).LastIndexOf('[');

            if (firstSquareIndex <= 0)
            {
                demo.hasError = true;
                return(demo);
            }
            string mapname = filename.Substring(0, firstSquareIndex);
            string others  = filename.Substring(firstSquareIndex);

            var sub = others.Split("[]()".ToArray());

            if (sub.Length >= 4)
            {
                //Map
                demo.mapName = mapname;

                //Physic
                demo.modphysic = sub[1];
                if (demo.modphysic.Length < 3)
                {
                    demo.hasError = true;
                }

                //Time
                demo.timeString = sub[2];
                var times = demo.timeString.Split('-', '.');
                try {
                    demo.time = RawInfo.getTimeSpan(demo.timeString);
                } catch (Exception) {
                    demo.hasError = true;
                }
                if (demo.time.TotalMilliseconds <= 0)
                {
                    demo.hasError = true;
                }

                //Name + country
                var countryName       = sub[3];
                var countryNameParsed = tryGetNameAndCountry(countryName, null);
                demo.playerName = countryNameParsed.Key;
                demo.country    = countryNameParsed.Value;

                var c1 = filename.LastIndexOf(')');
                var b1 = filename.LastIndexOf('{');
                var b2 = filename.LastIndexOf('}');
                if (b2 > b1 && b1 > c1 && c1 > 0)
                {
                    var vstr = filename.Substring(b1 + 1, b2 - b1 - 1);
                    var v    = vstr.Split('=');
                    if (v.Length > 1)
                    {
                        demo.validDict = new Dictionary <string, string>();
                        demo.validDict.Add(v[0], v[1]);
                    }
                }
            }
            else
            {
                demo.hasError = true;
            }
            return(demo);
        }
Exemplo n.º 26
0
        public void calculateTest()
        {
            // Arrange
            RawInfo rawInfo = new RawInfo();

            rawInfo.WorkDays     = 5;
            rawInfo.ElementValue = new List <int>();
            rawInfo.ElementValue.Add(4);

            rawInfo.ElementValue.Add(100);
            rawInfo.ElementValue.Add(30);
            rawInfo.ElementValue.Add(1);
            rawInfo.ElementValue.Add(1);

            rawInfo.ElementValue.Add(3);

            rawInfo.ElementValue.Add(20);
            rawInfo.ElementValue.Add(20);
            rawInfo.ElementValue.Add(20);

            rawInfo.ElementValue.Add(11);

            rawInfo.ElementValue.Add(1);
            rawInfo.ElementValue.Add(2);
            rawInfo.ElementValue.Add(3);
            rawInfo.ElementValue.Add(4);
            rawInfo.ElementValue.Add(5);
            rawInfo.ElementValue.Add(6);
            rawInfo.ElementValue.Add(7);
            rawInfo.ElementValue.Add(8);
            rawInfo.ElementValue.Add(9);
            rawInfo.ElementValue.Add(10);
            rawInfo.ElementValue.Add(11);

            rawInfo.ElementValue.Add(6);

            rawInfo.ElementValue.Add(9);
            rawInfo.ElementValue.Add(19);
            rawInfo.ElementValue.Add(29);
            rawInfo.ElementValue.Add(39);
            rawInfo.ElementValue.Add(49);
            rawInfo.ElementValue.Add(59);

            rawInfo.ElementValue.Add(10);

            rawInfo.ElementValue.Add(32);
            rawInfo.ElementValue.Add(56);
            rawInfo.ElementValue.Add(76);
            rawInfo.ElementValue.Add(8);
            rawInfo.ElementValue.Add(44);
            rawInfo.ElementValue.Add(60);
            rawInfo.ElementValue.Add(47);
            rawInfo.ElementValue.Add(85);
            rawInfo.ElementValue.Add(71);
            rawInfo.ElementValue.Add(91);



            CalculateTravels calculateTravels = new CalculateTravels();
            List <Output>    output           = calculateTravels.calculate(rawInfo);

            Assert.AreEqual(rawInfo.WorkDays, output.Count);
            Assert.AreEqual("Case #1: 2", output[0].CaseDay + ": " + output[0].NumberMaxTravels);
            Assert.AreEqual("Case #2: 1", output[1].CaseDay + ": " + output[1].NumberMaxTravels);
            Assert.AreEqual("Case #3: 2", output[2].CaseDay + ": " + output[2].NumberMaxTravels);
            Assert.AreEqual("Case #4: 3", output[3].CaseDay + ": " + output[3].NumberMaxTravels);
            Assert.AreEqual("Case #5: 5", output[4].CaseDay + ": " + output[4].NumberMaxTravels);
        }
Exemplo n.º 27
0
        private void tbtnIn_Click(object sender, EventArgs e)
        {
            bool reInSuccess = false;
            //生成子窗体,获取需要处理的表格信息以及学年,学期信息
            SubFormIn frmIn = new SubFormIn();

            frmIn.ShowDialog();
            if (frmIn.RInfo != null)
            {
                rawInfo     = frmIn.RInfo;
                reInSuccess = true;
            }
            frmIn.Dispose();
            //先尝试导入,导入不成功,不将状态转变
            //其他状态要重新转变到这个状态,到这儿肯定是需要导入,则启动导入程序
            if (rawInfo == null)
            {
                return;
            }
            //这个说明子窗体按了取消键
            if (!reInSuccess)
            {
                return;
            }
            //到这里说明真正进了窗体
            bool fileProblemFlag = false;
            bool exceptionFlag   = false;

            try
            {
                fileProblemFlag = !DataLayer.getDataFromFile(rawInfo.FilePath);
            }
            catch
            {
                exceptionFlag = true;
            }
            finally
            {
                if (fileProblemFlag)
                {
                    MessageBoxEx.Show("导入不成功,请关闭正在打开的Excel,或者尝试安装ACCESS数据库驱动", "错误");
                }
                else if (exceptionFlag)
                {
                    MessageBoxEx.Show("数据格式不符合要求", "错误");
                }
                else
                {
                    this.dgvArrange.DataSource   = DataLayer.DtRawTchArrange;
                    this.dgvStatistic.DataSource = DataLayer.DtRawStatistics;
                    try
                    {
                        CorrectTwoDgv();
                        //能走到这里说明窗体已经做好了计算准备,转变窗体的状态
                        StatusChange(Status.WaitToCalc);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxEx.Show(ex.Message);
                        this.dgvArrange.DataSource   = null;
                        this.dgvStatistic.DataSource = null;
                        StatusChange(Status.WaitToImport);
                    }
                }
            }
        }
Exemplo n.º 28
0
 public void setOnlineName(string onlineName)
 {
     oName = normalizeName(RawInfo.removeColors(onlineName));
 }
Exemplo n.º 29
0
        //Get the details of the demo from the file name
        public static Demo GetDemoFromFile(FileInfo file)
        {
            Demo demo = new Demo();

            demo.file = file;
            var filename = file.Name;

            demo.recordTime = demo.file.CreationTime;

            string fileNameNoExt = filename.Substring(0, filename.Length - file.Extension.Length);
            var    match         = Regex.Match(fileNameNoExt, "(.+)\\[(.+)\\](\\d+\\.\\d{2}\\.\\d{3})\\((.+)\\)(\\{(.+)\\})?(\\[(.+)\\])?");

            if (match.Success && match.Groups.Count >= 5)
            {
                //Map
                demo.mapName = match.Groups[1].Value;

                //Physic
                demo.modphysic = match.Groups[2].Value;
                var physic = demo.modphysic.ToLowerInvariant();
                int index  = Math.Max(physic.IndexOf(".cpm"), physic.IndexOf(".vq3"));
                if (index <= 0)
                {
                    demo.hasError = true;
                }
                if (physic.Length < 3)
                {
                    demo.hasError = true;
                }
                if (physic.Contains(".tr"))
                {
                    demo.hasTr = true;
                }

                //Time
                demo.timeString = match.Groups[3].Value;
                try {
                    demo.time = RawInfo.getTimeSpan(demo.timeString);
                } catch (Exception) {
                    demo.hasError = true;
                }
                if (demo.time.TotalMilliseconds <= 0)
                {
                    demo.hasError = true;
                }

                //Name + country
                var countryName       = match.Groups[4].Value;
                var countryNameParsed = tryGetNameAndCountry(countryName, null);
                demo.playerName = countryNameParsed.Key;
                demo.country    = countryNameParsed.Value;

                //Validity
                if (match.Groups.Count >= 7)
                {
                    var validString = match.Groups[6].Value;
                    var v           = validString.Split('=');
                    if (v.Length > 1)
                    {
                        demo.validDict = new Dictionary <string, string>();
                        demo.validDict.Add(v[0], v[1]);
                    }
                }

                //tas check
                if (filename.ToLowerInvariant().Contains("tool_assisted=true"))
                {
                    demo.isTas = true;
                }

                //userId
                if (match.Groups.Count >= 9)
                {
                    var idString = match.Groups[8].Value;
                    if (!string.IsNullOrEmpty(idString))
                    {
                        if (isDigits(idString.ToCharArray()))
                        {
                            long id = -1;
                            long.TryParse(idString, out id);
                            if (id >= 0)
                            {
                                demo.userId = id;
                            }
                        }
                        else
                        {
                            if (idString == "spect")
                            {
                                demo.isSpectator = true;
                            }
                        }
                    }
                }
            }
            else
            {
                demo.hasError = true;
            }
            return(demo);
        }
Exemplo n.º 30
0
        private string GetNameItem()
        {
            if (RawInfo.Contains("Rarity: Currency"))
            {
                var lines = RawInfo.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                return(lines[2]);
            }

            if (RawInfo.Contains("Map Tier:"))
            {
                if (RawInfo.Contains("Rarity: Rare"))
                {
                    var match = Regex.Match(RawInfo, @"Rarity: Rare\s([\w ']*)\s([\w ']*)");

                    if (!string.IsNullOrEmpty(match.Groups[2].Value))
                    {
                        return(match.Groups[2].Value.Replace(" Map", ""));
                    }
                    else
                    {
                        return(match.Groups[1].Value.Replace(" Map", ""));
                    }
                }

                if (RawInfo.Contains("Rarity: Normal"))
                {
                    return(Regex.Match(RawInfo, @"Rarity: Normal\s([\w ']*)").Groups[1].Value.Replace(" Map", ""));
                }

                if (RawInfo.Contains("Rarity: Unique"))
                {
                    var match = Regex.Match(RawInfo, @"Rarity: Unique\s([\w ']*)\s([\w ']*)");

                    if (!string.IsNullOrEmpty(match.Groups[2].Value))
                    {
                        return($"{match.Groups[1].Value} {match.Groups[2].Value}".Replace(" Map", ""));
                    }
                    else
                    {
                        return("Undefined item");
                    }
                }
            }

            if (RawInfo.Contains("Rarity: Divination Card"))
            {
                return(Regex.Match(RawInfo, @"Rarity: Divination Card\s([\w ']*)").Groups[1].Value);
            }

            //I think that it for predicate fragments
            if (!RawInfo.Contains("Requirements:"))
            {
                if (RawInfo.Contains("Rarity: Normal"))
                {
                    return(Regex.Match(RawInfo, @"Rarity: Normal\s([\w ']*)").Groups[1].Value);
                }
            }

            // Get Generic Name
            string[] infoParts = RawInfo.Split(new[] { "\n", "\r", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            string   itemName  = string.Empty;

            foreach (string line in infoParts)
            {
                if (line.Contains(":"))
                {
                    continue;
                }
                if (line.Contains("--------"))
                {
                    break;
                }
                itemName = $"{itemName} {line}";
            }
            return(itemName.Trim());
        }