Exemple #1
0
        internal void Parse(string mapsinfo, string mapsraw, ZloBFGame game)
        {
            API_MapBase[] oldmaps;
            if (Values != null)
            {
                oldmaps = Values.ToArray();
            }
            else
            {
                oldmaps = null;
            }

            int oldcur  = CurrentMapIndex;
            int oldnext = NextMapIndex;

            Clear();
            //parse maps rotation
            string[] rawmgms = mapsraw.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < rawmgms.Length; i++)
            {
                //each map
                //name,gamemode
                var rawmgm = rawmgms[i].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (rawmgm.Length > 0)
                {
                    var m = new API_MapBase(this)
                    {
                        MapName = API_Dictionaries.GetMapName(game, rawmgm[0])
                    };
                    if (rawmgm.Length > 1)
                    {
                        m.GameModeName = API_Dictionaries.GetMapName(game, rawmgm[1]);
                    }
                    else
                    {
                        m.GameModeName = string.Empty;
                    }
                    Add(i, m);
                }
            }


            //parse maps info
            var infos = mapsinfo.Split(';').Select(x => x.Split(',')).ToArray();

            CurrentMapIndex = int.Parse(infos[1][0]);
            NextMapIndex    = int.Parse(infos[1][1]);

            //if (LogicalCurrentMap != null)
            //{
            //    LogicalCurrentMap.OPC(nameof(LogicalCurrentMap.IsCurrent));
            //    LogicalCurrentMap.OPC(nameof(LogicalCurrentMap.IsNext));
            //}
            //if (LogicalNextMap != null)
            //{
            //    LogicalNextMap.OPC(nameof(LogicalCurrentMap.IsCurrent));
            //    LogicalCurrentMap.OPC(nameof(LogicalCurrentMap.IsNext));
            //}
        }
Exemple #2
0
        internal API_Item(string flag, bool exists, ZloBFGame game)
        {
            FlagName   = flag;
            ItemExists = exists;


            API_Dictionaries.GetItemDetails(game, flag, out var name, out var desc);
            ItemName        = name;
            ItemDescription = desc;
        }
Exemple #3
0
        protected override void FixAttrs()
        {
            base.FixAttrs();

            if (Attributes.TryGetValue("mode", out var mode))
            {
                MapRotation.CurrentActualMap.GameModeName = API_Dictionaries.GetGameModeName(Game, mode);
                Attributes.Remove("mode");
            }
        }
Exemple #4
0
        protected virtual void FixAttrs()
        {
            List <string> KeysToRemove = new List <string>();

            for (int i = 0; i < Attributes.Count; i++)
            {
                string key = Attributes.Keys.ElementAt(i);
                if (KeysToRemove.Contains(key))
                {
                    continue;
                }
                string value = Attributes[key];
                if (key.IndexOfAny(numbs) > -1)
                {
                    //it contains a number
                    //remove the number and call it CleanKey
                    string cleankey = new string(key.Where(x => !numbs.Contains(x)).ToArray());

                    var allkeys   = Attributes.Keys.Where(x => new string(x.Where(z => !numbs.Contains(z)).ToArray()) == cleankey).OrderBy(q => q).ToList();
                    var allvalues = new List <string>();
                    foreach (var item in allkeys)
                    {
                        allvalues.Add(Attributes[item]);
                    }
                    string finalvalues = string.Join(string.Empty, allvalues);
                    Attributes.Add(cleankey, finalvalues);
                    KeysToRemove.AddRange(allkeys);
                }
            }

            foreach (var item in KeysToRemove)
            {
                Attributes.Remove(item);
            }
            ServerSettings.Clear();
            if (Attributes.TryGetValue("settings", out var settings))
            {
                var pairset = settings.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                //ServerSettings.Clear();
                foreach (var item in pairset)
                {
                    var splitpair = item.Split('=');
                    ServerSettings[splitpair[0]] = splitpair[1];
                }
                Attributes.Remove("settings");
            }
            if (ServerSettings.TryGetValue("vmsp", out var vmspStr) && bool.TryParse(vmspStr, out var vmsp))
            {
                if (Attributes.TryGetValue("servertype", out var serverType))
                {
                    if (serverType == "PRIVATE")
                    {
                        IsPasswordProtected = vmsp;
                    }
                    else
                    {
                        IsPasswordProtected = false;
                    }
                }
                else
                {
                    IsPasswordProtected = vmsp;
                }
                ServerSettings.Remove("vmsp");
            }
            else
            {
                IsPasswordProtected = false;
            }


            if (Attributes.TryGetValue("maps", out var mapsRaw) && Attributes.TryGetValue("mapsinfo", out var mapsInfo))
            {
                MapRotation.Parse(mapsInfo, mapsRaw, Game);
                Attributes.Remove("maps");
                Attributes.Remove("mapsinfo");
            }
            if (Attributes.TryGetValue("level", out var level))
            {
                MapRotation.CurrentActualMap.MapName = API_Dictionaries.GetMapName(Game, level);
                Attributes.Remove("level");
            }
        }