コード例 #1
0
        /// <summary>
        /// Converts an object into its XML representation.
        /// </summary>
        /// <param name="writer">The System.Xml.XmlWriter stream to which the object is serialized.</param>
        public override void WriteXml(XmlWriter writer)
        {
            IEnumerable <string> valueList;

            writer.WriteAttributeString("Type", (Value?.GetType() ?? typeof(TPropertyType)).AssemblyQualifiedName);
            writer.WriteElementString("PropertyId", PropertyId);
            writer.WriteElementString("Operation", Operation.ToString("d"));
            if (Value != null)
            {
                if (ValueIsList(out valueList))
                {
                    writer.WriteStartElement("Values");
                    valueList.ToList().ForEach(x => writer.WriteElementString("Value", x));
                    writer.WriteEndElement();
                }
                else
                {
                    writer.WriteElementString("Value", Value.ToString());
                }
            }
            else
            {
                writer.WriteStartElement("Value");
                writer.WriteAttributeString("NULLED", true.ToString());
                writer.WriteEndElement();
            }
            writer.WriteElementString("Connector", Connector.ToString("d"));
            writer.WriteElementString("MatchType", MatchType.ToString("d"));
        }
コード例 #2
0
        bool MatchByIndex(Query q, MatchType t, object data)
        {
            if (etcMapper == null)
            {
                return(false);
            }

            // 字段是枚举, 需要将外部的枚举转为整形
            if (fieldType.IsEnum)
            {
                data = Convert.ToInt32(data);
            }

            unequalData ud;

            if (etcMapper.TryGetValue(data, out ud))
            {
                var typeList = ud.matchTypeList[(int)t];
                if (typeList == null)
                {
                    throw new Exception("Match type index not built: " + t.ToString());
                }

                AddListToResult(q, typeList);
                return(true);
            }


            return(false);
        }
コード例 #3
0
 protected override void WriteDisplayString(XmlWriter writer)
 {
     if (base.HasErrorInfo)
     {
         writer.WriteComment(ErrorInfo.Message);
         return;
     }
     if (base.HasWarningInfo)
     {
         writer.WriteComment(ErrorInfo.Message);
     }
     writer.WriteStartElement("add");
     if (!string.IsNullOrEmpty(Input))
     {
         writer.WriteAttributeString("input", Input);
     }
     if (!string.IsNullOrEmpty(Pattern))
     {
         writer.WriteAttributeString("pattern", Pattern);
     }
     if (MatchType != MatchType.Pattern)
     {
         writer.WriteAttributeString("matchType", MatchType.ToString());
     }
     if (!IgnoreCase)
     {
         writer.WriteAttributeString("ignoreCase", "false");
     }
     if (Negate)
     {
         writer.WriteAttributeString("negate", "true");
     }
 }
コード例 #4
0
        public static int GetTodaysMatches(MatchType mt)
        {
            var    api         = new APIService(Settings.MatchStatsAPIMatches);
            string jsonMatches = api.GetResponse();

            try
            {
                JObject        csgostatsMatches = JObject.Parse(jsonMatches);
                IList <JToken> results          = csgostatsMatches[mt.ToString().ToLower()].Children().ToList();

                // Serialize
                IList <CSGOStatsMatch> matches =
                    results.Select(result => JsonConvert.DeserializeObject <CSGOStatsMatch>(result.ToString())).ToList();

                foreach (CSGOStatsMatch m in matches)
                {
                    match matchEntity = DBService.GetOrCreateMatch(m.CSGOlid, m.Time, m.Team1, m.Team2, m.Winner);
                }
            }
            catch
            {
                return(0);
            }

            return(1);
        }
コード例 #5
0
        protected override string RequestUrl()
        {
            string sUrl = "/common/arenaDetails.asp?outputType=XML&actionType=view";

            if (ArenaId != 0)
            {
                sUrl += "&arenaID=" + ArenaId;
            }
            if (StatsType != ArenaDetailsRequest.StatsTypeEnum.MyArena)
            {
                sUrl += "&StatsType=" + StatsType.ToString();
            }
            if (MatchType != ArenaDetailsRequest.MatchTypeEnum.All)
            {
                sUrl += "&MatchType=" + MatchType.ToString();
            }
            if (FirstDate != DateTime.MinValue)
            {
                sUrl += "&FirstDate=" + FirstDate.ToString("yyyy-MM-dd HH:mm:ss");
            }
            if (LastDate != DateTime.MinValue)
            {
                sUrl += "&LastDate=" + LastDate.ToString("yyyy-MM-dd HH:mm:ss");
            }
            if (StatsLeagueID != 0)
            {
                sUrl += "&StatsLeagueID=" + StatsLeagueID;
            }

            return(sUrl);
        }
コード例 #6
0
    public IEnumerator getLeaderboard(int page, MatchType type, Action <List <LeaderboardScore> > successFunction, Action <string, JSONObject> errorFunction)
    {
        yield return(WaitUntilDeviceRegistered());

        Debug.Log("We are requesting things from the leaderboard");
        string     url  = APIBaseUrl + "leaderboard?page=" + page;
        JSONObject form = newAPIForm();

        form.AddField("type", type.ToString());
        yield return(WaitForRequest(url, form, (obj) => {
            Debug.Log("We made it here!");
            List <LeaderboardScore> scores = new List <LeaderboardScore>();
            JSONObject scorePiece = obj.GetField("data");
            foreach (JSONObject s in scorePiece.list)
            {
                int score = (int)s.GetField("score").n;
                MatchType retrType = MatchType.valueOf(s.GetField("match_type").str);
                string username = s.GetField("username").str;
                DateTime date = DateTime.ParseExact(s.GetField("uploaded_at").str, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                scores.Add(new LeaderboardScore(score, username, retrType, date));
            }
            if (successFunction != null)
            {
                successFunction(scores);
            }
        }, errorFunction));
    }
コード例 #7
0
    public IEnumerator submitScore(int score, MatchType type, Action successFunction, Action <string, JSONObject> errorFunction)
    {
        yield return(WaitUntilDeviceRegistered());

        Debug.Log("Submitting a score to the leaderboards.");
        string     url  = APIBaseUrl + "leaderboard/submit";
        JSONObject form = newAPIForm();

        form.AddField("score", score);
        form.AddField("match_type", type.ToString());
        yield return(WaitForRequest(url, form, (obj) => successFunction(), errorFunction));
    }
コード例 #8
0
        private void SelectDuplicates(MatchType mode)
        {
            foreach (DataGridViewRow row in dgvResult.Rows)
            {
                var matchType = row.Cells["colMatchType"].Value.ToString();
                if (matchType == "SEPARATOR")
                {
                    continue;
                }

                if (matchType == mode.ToString())
                {
                    row.Cells["colCheck"].Value = true;
                }
            }
        }
コード例 #9
0
        public override string ToString()
        {
            string str = Filename;

            if (MatchType != MatchType.ORIGINAL)
            {
                str += ", " + MatchType.ToString() + ", FilesCount: " + Items.Count + ", Match: " + Percentage.ToString("0.00") + "%";
            }
            else
            {
                str += ", Original";
            }
            if (NoMatches != null)
            {
                str += ", NoMatchCount: " + NoMatches.Count;
            }
            return(str);
        }
コード例 #10
0
        public string ToCacheEntry()
        {
            List <string> row = new List <string>();

            row.Add(Name);
            row.Add(IsFMSMatch.ToString());
            row.Add(Seconds.ToString());
            row.Add(StartTime.ToString());
            row.Add(Useless.ToString());

            if (IsFMSMatch)
            {
                row.Add(FMSFilledIn.ToString());
                row.Add(MatchType.ToString());
                row.Add(FMSMatchNum.ToString());
                row.Add(EventName);
            }
            return(string.Join(",", row));
        }
コード例 #11
0
        private bool TestForMatch(Nullable <DateTime> nullableStoreValue)
        {
            // If the store object doesn't have the property set, then the only
            // way it could match is if they asked for a not-equals test
            // (if the store object doesn't have a value, then it certainly doesn't match
            // whatever value they specified)
            if (!nullableStoreValue.HasValue)
            {
                return((_matchType == MatchType.NotEquals) ? true : false);
            }

            Debug.Assert(nullableStoreValue.HasValue);
            DateTime storeValue = nullableStoreValue.Value;

            switch (_matchType)
            {
            case MatchType.Equals:
                return(storeValue == _valueToMatch);

            case MatchType.NotEquals:
                return(storeValue != _valueToMatch);

            case MatchType.GreaterThan:
                return(storeValue > _valueToMatch);

            case MatchType.GreaterThanOrEquals:
                return(storeValue >= _valueToMatch);

            case MatchType.LessThan:
                return(storeValue < _valueToMatch);

            case MatchType.LessThanOrEquals:
                return(storeValue <= _valueToMatch);

            default:
                Debug.Fail("FindByDateMatcher.TestForMatch: Fell off end looking for matchType=" + _matchType.ToString());
                return(false);
            }
        }
コード例 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(MatchType.ToString() + ";" + IsDynamic.ToString());
 }
コード例 #13
0
ファイル: Match.cs プロジェクト: tuita520/unity-moba
    /// <summary>
    /// Find and join into a game.
    /// </summary>
    /// <param name="type"></param>
    /// <param name="r"></param>
    public bool Join(MatchType typ = MatchType.None, UDPPacket r = null)
    {
        if (r == null)
        {
            // if the user is not logged in or match type is none, restart
            if (!Account.IsLoggedIn())
            {
                Kill2Live.Restart();
                return(false);
            }
            Debug.Log("Finding a match for " + typ.ToString() + " ...");

            Event e = new Event
            {
                User = Account.GetUser(),
                M    = new Game
                {
                    Typ = typ,
                }
            };

            // request
            string j = JsonConvert.SerializeObject(e);
            UDP.Request(new UDPPacket
            {
                Service = UDPService.Match,
                Action  = UDPAction.Join,
                Request = j,
            });
            return(false);
        }
        else
        {
            if (r.Error != 0)
            {
                if (r.Error == (int)ServiceError.AlreadyJoined)
                {
                    // continue
                    // no return here because of this situation
                }
                else if (r.Error >= (int)ServiceError.MatchUnknown)
                {
                    UIMessageGlobal.Open(Language.v["joinfailed"],
                                         Language.v["joinfaileddesc"]);
                    Debug.LogWarning(r.ToString());
                    return(false);
                }
            }
            Debug.Log("Joining: " + r.Response);

            Event e = JsonConvert.DeserializeObject <Event>(r.Response);
            if (e.M.Typ == MatchType.None)
            {
                return(false);
            }
            activeEvent = e;

            if (e.M.Status == MatchStatus.Reserved) // still creating a match
            {
                if (!refreshing)
                {
                    refreshing = true;
                    InvokeRepeating("PlayersLoop", 0f, refresh);
                }
            }
            else
            {
                if (e.M.Status == MatchStatus.Ready ||
                    e.M.Status == MatchStatus.Play)
                {
                    Players();
                }
                else if (e.M.Status == MatchStatus.End ||
                         e.M.Status == MatchStatus.Released)
                {
                    activeEvent = null;
                    UIPlayers.Clear();
                    return(false);
                }
            }
            return(true);
        }
    }
コード例 #14
0
ファイル: Utils.cs プロジェクト: xXTedgeGimmerXx/FTN-Power
        public static double BR_Stats(this JObject PlayerStats, StatType statType, MatchType matchType, Platform platform, bool rankedStats = false)
        {
            var profileType = PlayerStats.Properties().ToList();
            var properties  = PlayerStats.Properties().ToList();

            if (rankedStats)
            {
                if (platform != Platform.all)
                {
                    properties = properties.Where(f => f.Name.StartsWith($"br_{statType}_") && f.Name.Contains($"_{platform}_") && (f.Name.Contains($"_default{matchType.ToString()}") || f.Name.Contains($"_deimos_{matchType.ToString()}"))).ToList();
                }
                else
                {
                    properties = properties.Where(f => f.Name.StartsWith($"br_{statType}_") && (f.Name.Contains($"_{Platform.gamepad}_") || f.Name.Contains($"_{Platform.keyboardmouse}_")) && (f.Name.Contains($"_default{matchType.ToString()}") || f.Name.Contains($"_deimos_{matchType.ToString()}"))).ToList();
                }
            }
            else
            {
                if (platform != Platform.all)
                {
                    properties = properties.Where(f => f.Name.StartsWith($"br_{statType}_") && f.Name.Contains($"_{platform}_") && !(f.Name.Contains($"_default{matchType.ToString()}") || f.Name.Contains($"_deimos_{matchType.ToString()}"))).ToList();
                }
                else
                {
                    properties = properties.Where(f => f.Name.StartsWith($"br_{statType}_") && (f.Name.Contains($"_{Platform.gamepad}_") || f.Name.Contains($"_{Platform.keyboardmouse}_")) && !(f.Name.Contains($"_default{matchType.ToString()}") || f.Name.Contains($"_deimos_{matchType.ToString()}"))).ToList();
                }
            }
            var total = 0;

            foreach (var property in properties)
            {
                var val = property.Value.Value <int>();
                total += val;
            }
            return(total);
        }
コード例 #15
0
        private void RenderSplashScreen()
        {
            if (!_AlreadyDrawn)
            {
                _AlreadyDrawn           = true;
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.CursorVisible   = false;
                Console.Title           = "Battle Snake";
                Console.SetWindowSize((GameEngine.Width * 2) + 50, GameEngine.Height + 1);
                Console.SetBufferSize((GameEngine.Width * 2) + 50, GameEngine.Height + 1);
                Console.SetWindowPosition(0, 0);
                Console.CursorVisible = false;
                Console.Clear();

                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("                          ██████╗  █████╗ ████████╗████████╗██╗     ███████╗    ███████╗███╗   ██╗ █████╗ ██╗  ██╗███████╗");
                Console.WriteLine("                          ██╔══██╗██╔══██╗╚══██╔══╝╚══██╔══╝██║     ██╔════╝    ██╔════╝████╗  ██║██╔══██╗██║ ██╔╝██╔════╝");
                Console.WriteLine("                          ██████╔╝███████║   ██║      ██║   ██║     █████╗      ███████╗██╔██╗ ██║███████║█████╔╝ █████╗  ");

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("                          ██╔══██╗██╔══██║   ██║      ██║   ██║     ██╔══╝      ╚════██║██║╚██╗██║██╔══██║██╔═██╗ ██╔══╝  ");
                Console.WriteLine("                          ██████╔╝██║  ██║   ██║      ██║   ███████╗███████╗    ███████║██║ ╚████║██║  ██║██║  ██╗███████╗");
                Console.WriteLine("                          ╚═════╝ ╚═╝  ╚═╝   ╚═╝      ╚═╝   ╚══════╝╚══════╝    ╚══════╝╚═╝  ╚═══╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝");

                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("");
                Console.WriteLine("                                                                an epic battle game");
                Console.WriteLine("");

                Console.WriteLine("                                                                    written by:");
                Console.WriteLine("");

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("                                 ██   █    ▄█    ▄▄▄▄▄    ▄  █ ██    ▄  █        ▄   ████▄     ▄   ▄█    ▄   ");
                Console.WriteLine("                                 █ █  █    ██   █     ▀▄ █   █ █ █  █   █         █  █   █      █  ██     █  ");
                Console.WriteLine("                                 █▄▄█ █    ██ ▄  ▀▀▀▀▄   ██▀▀█ █▄▄█ ██▀▀█     ██   █ █   █ █     █ ██ ██   █ ");
                Console.WriteLine("                                 █  █ ███▄ ▐█  ▀▄▄▄▄▀    █   █ █  █ █   █     █ █  █ ▀████  █    █ ▐█ █ █  █ ");
                Console.WriteLine("                                    █     ▀ ▐               █     █    █      █  █ █         █  █   ▐ █  █ █ ");
                Console.WriteLine("                                   █                       ▀     █    ▀       █   ██          █▐      █   ██ ");
                Console.WriteLine("                                  ▀                             ▀                             ▐              ");

                Console.WriteLine("");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("                                                             with snakes guided by you.");
                Console.WriteLine("");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(@"                             _______ _______ _______ _______ _______     _______ _______ _______ _______ _______   ");
                Console.WriteLine(@"                            |   _   |   _   |   _   |   _   |   _   |   |   _   |   _   |   _   |   _   |   _   |");
                Console.WriteLine(@"                            |.  1   |.  l   |.  1___|   1___|   1___|   |   1___|.  1   |.  1   |.  1___|.  1___|");
                Console.WriteLine(@"                            |.  ____|.  _   |.  __)_|____   |____   |   |____   |.  ____|.  _   |.  |___|.  __)_ ");
                Console.WriteLine(@"                            |:  |   |:  |   |:  1   |:  1   |:  1   |   |:  1   |:  |   |:  |   |:  1   |:  1   |");
                Console.WriteLine(@"                            |::.|   |::.|:. |::.. . |::.. . |::.. . |   |::.. . |::.|   |::.|:. |::.. . |::.. . |");
                Console.WriteLine(@"                            `---'   `--- ---`-------`-------`-------'   `-------`---'   `--- ---`-------`-------'");
                Console.WriteLine(@"                                         _______ _______     _______  _______ _______ ___ ______                 ");
                Console.WriteLine(@"                                        |       |   _   |   |   _   \|   _   |   _   |   |   _  \                ");
                Console.WriteLine(@"                                        |.|   | |.  |   |   |.  1   /|.  1___|.  |___|.  |.  |   |               ");
                Console.WriteLine(@"                                        `-|.  |-|.  |   |   |.  _   \|.  __)_|.  |   |.  |.  |   |               ");
                Console.WriteLine(@"                                          |:  | |:  1   |   |:  1    |:  1   |:  1   |:  |:  |   |               ");
                Console.WriteLine(@"                                          |::.| |::.. . |   |::.. .  |::.. . |::.. . |::.|::.|   |               ");
                Console.WriteLine(@"                                          `---' `-------'   `-------'`-------`-------`---`--- ---'               ");

                Console.WriteLine(@"");
            }

            Console.SetCursorPosition(1, 47);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("            Mode (M): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(_Mode.ToString());

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(" Battle (B): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(_MatchType.ToString());

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(" Speed (Up/Down): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(string.Format("{0}%", Convert.ToInt32(100.0 * (_Speed - _MinSpeed) / (_MaxSpeed - _MinSpeed))));

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(" Initial Size (S): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(_InitialSnakeLength);

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(" Growth Size (G): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(_GrowthFactor);

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(" Time Limit (T): ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(_TimeLimit > _MaxTimeLimit ? "Unlimited" : _TimeLimit.ToString());
            if (_TimeLimit == 1)
            {
                Console.WriteLine("min       ");
            }
            else if (_TimeLimit <= _MaxTimeLimit)
            {
                Console.WriteLine("mins      ");
            }

            //while on the splash screen, let the user set game conditions
            while (!_GameStarted)
            {
                KeyChecker();
                Thread.Sleep(1);
            }
        }