Пример #1
0
        public bool Equals(MapVariant p)
        {
            // If parameter is null, return false.
            if (Object.ReferenceEquals(p, null))
            {
                return(false);
            }

            // Optimization for a common success case.
            if (Object.ReferenceEquals(this, p))
            {
                return(true);
            }

            // If run-time types are not exactly the same, return false.
            if (this.GetType() != p.GetType())
            {
                return(false);
            }

            // Return true if the fields match.
            // Note that the base class is not invoked because it is
            // System.Object, which defines Equals as reference equality.
            return(this.TypeNameForVotingFile == p.TypeNameForVotingFile);
        }
Пример #2
0
 public static Type SingleOption(GameVariant game, MapVariant map, List <string> commands = null)
 {
     return(new Type()
     {
         GameVariant = game,
         Commands = commands ?? new List <string>(),
         SpecificMaps = new List <MapVariant>()
         {
             map,
             map
         }
     });
 }
Пример #3
0
 public static bool TryGetBuiltInMapVariant(string name, out MapVariant mapVariant)
 {
     if (!string.IsNullOrWhiteSpace(name) && BaseMapIDsByName.ContainsKey(name))
     {
         mapVariant = BaseMapVariantsByBaseMap[BaseMapIDsByName[name]];
         return(true);
     }
     else
     {
         mapVariant = null;
         return(false);
     }
 }
Пример #4
0
 /// <summary>
 /// Makes this option into a single-option voting file. Requires special handling of the server to make sure it doesn't crash from having too few voting options.
 /// </summary>
 /// <param name="game">The game that will be used. Is not validated here.</param>
 /// <param name="map">The map that will be used. Is not validated here.</param>
 /// <param name="writeImmediately">True by default. If true, writes/updates the vote file to disk immediately after updating.</param>
 public void MakeSingleOptionVotingFile(GameVariant game, MapVariant map, bool writeImmediately = true)
 {
     Maps = new List <MapVariant>()
     {
         map, map
     };
     //Games = new List<GameVariant>() { game };
     Types = new List <Type>()
     {
         Type.SingleOption(game, map), Type.SingleOption(game, map)
     };
     if (writeImmediately)
     {
         WriteToDisk();
     }
 }
Пример #5
0
        public bool ValidateMaps(List <MapVariant> maps, ServerSettings settings, out int losses)
        {
            losses = 0;
            bool mapExists;

            // Validate the maps referenced in the file
            for (int i = 0; i < maps.Count; i++)
            {
                if (MapVariant.BaseMapStringIDs.Contains(maps[i].TypeNameForVotingFile))
                {
                    maps[i].IsBaseMap = true;
                    continue;
                }

                DirectoryInfo match = null;

                try { mapExists = maps[i].Exists(settings.MapVariantsDirectory, out match); }
                catch (Exception e) { App.Log("Failed to validate map \"" + maps[i].Name + "\" | " + e.Message, settings); mapExists = false; }

                if (mapExists)
                {
                    try { maps[i] = new MapVariant(match); }
                    catch (Exception e) { App.Log("Failed to validate map \"" + maps[i].Name + "\" | " + e.Message, settings); }
                }
                else
                {
                    losses++;
                }
            }

            if (maps.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
 public MatchInfo(GameVariant game, MapVariant map)
 {
     GameVariant = game; MapVariant = map;
 }