Beispiel #1
0
        private static void ParseMarkerProperyRules()
        {
            var allText = Properties.Resources.NewMarkersProperties;

            var lines = allText.Split(new char[] { '\n', });


            MarkersWomboCombo.MarkerPropertyBasedRules = new List <MarkerPropertyRequires>();


            foreach (var line in lines)
            {
                var markerRule = MarkerPropertyRequires.ParseFromString(line);

                if (markerRule != null)
                {
                    MarkerPropertyBasedRules.Add(markerRule);
                }
            }
        }
Beispiel #2
0
        public static MarkerPropertyRequires ParseFromString(string line)
        {
            if (string.IsNullOrEmpty(line) || string.IsNullOrWhiteSpace(line))
            {
                return(null);
            }


            var parts = line.Split(new char[] { '\t', '\r' });

            if (parts.Length < MarkersWomboCombo.IndexesMarkersPropertyBased.Count)
            {
                return(null);
            }


            var action_code_str = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["action_code"]];
            var action_code     = 0;

            if (int.TryParse(action_code_str, out action_code) == false)
            {
                return(null);
            }

            var name = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["name"]];

            var eng_name = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["name_eng"]];

            var action_id_str = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["action_id"]];
            var action_id     = 0;

            if (int.TryParse(action_id_str, out action_id) == false)
            {
                return(null);
            }

            var action_type_str = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["action_type"]];
            var action_type     = 0;

            if (int.TryParse(action_type_str, out action_type) == false)
            {
                return(null);
            }

            var win_str = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["win"]];
            var win     = 0;

            if (string.IsNullOrEmpty(win_str) || string.IsNullOrWhiteSpace(win_str))
            {
                win = 0;
            }
            else
            {
                if (int.TryParse(win_str, out win) == false)
                {
                    return(null);
                }
            }

            #region Player1

            var          p1      = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["player"]];
            NeedProperty player1 = null;
            if (string.IsNullOrEmpty(p1) || string.IsNullOrWhiteSpace(p1))
            {
                player1 = new NeedProperty(MarkerkFieldEnum.Player1, MarkerFieldRequireEnum.No);
            }
            else if (p1.Contains("p1"))
            {
                player1 = new NeedProperty(MarkerkFieldEnum.Player1, p1.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p1.Contains("TEAM"))
            {
                player1 = new NeedProperty(MarkerkFieldEnum.Team1, p1.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p1.Contains("p1[]"))
            {
                //Player1Array
                player1 = new NeedProperty(MarkerkFieldEnum.Player1Array, p1.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else
            {
                var p = 5;
                return(null);
            }

            #endregion


            #region Player2

            var          p2      = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["opponent"]];
            NeedProperty player2 = null;
            if (string.IsNullOrEmpty(p2) || string.IsNullOrWhiteSpace(p2))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.Opponent2, MarkerFieldRequireEnum.No);
            }
            else if (p2.Contains("p2"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.PlayerTeammate2, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("o2"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.Opponent2, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("G2"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.GoalKeeper2, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("o2notG2"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.OpponentNotGoalKeere2, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("p2auto"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.PlayerTeammate2Auto, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("o2ayto"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.Opponent2Auto, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("TEAM"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.Team2, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (p2.Contains("p1"))
            {
                player2 = new NeedProperty(MarkerkFieldEnum.Player1Same, p2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else
            {
                var p = 5;
                return(null);
            }

            #endregion

            var          t1     = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["point"]];
            NeedProperty point1 = null;
            if (string.IsNullOrEmpty(t1) || string.IsNullOrWhiteSpace(t1))
            {
                point1 = new NeedProperty(MarkerkFieldEnum.Point1, MarkerFieldRequireEnum.No);
            }
            else if (t1.Contains("t1"))
            {
                point1 = new NeedProperty(MarkerkFieldEnum.Point1, t1.Contains("?")? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (t1.Contains("t1mid"))
            {
                point1 = new NeedProperty(MarkerkFieldEnum.Point1Mid, t1.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (t1.Contains("t1|t1mid"))
            {
                point1 = new NeedProperty(MarkerkFieldEnum.Point1orPoint1Mid, t1.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else
            {
                var p = 5;
                return(null);
            }

            var          t2     = parts[MarkersWomboCombo.IndexesMarkersPropertyBased["dest"]];
            NeedProperty point2 = null;
            if (string.IsNullOrEmpty(t2) || string.IsNullOrWhiteSpace(t2))
            {
                point2 = new NeedProperty(MarkerkFieldEnum.Point2, MarkerFieldRequireEnum.No);
            }
            else if (t2.Contains("t2"))
            {
                point2 = new NeedProperty(MarkerkFieldEnum.Point2, t2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (t2.Contains("t2auto"))
            {
                point2 = new NeedProperty(MarkerkFieldEnum.Point2Auto, t2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else if (t2.Contains("t2autoVedenie"))
            {
                point2 = new NeedProperty(MarkerkFieldEnum.Point2AutoVedenie, t2.Contains("?") ? MarkerFieldRequireEnum.Maybe : MarkerFieldRequireEnum.Needs);
            }
            else
            {
                var p = 5;
                return(null);
            }


            var markerRule = new MarkerPropertyRequires(name, eng_name, action_code, action_id, action_type, win,
                                                        new NeedProperty[] { player1, player2, point1, point2 });

            return(markerRule);
        }