Exemple #1
0
        public override string Arm(ServerBattle battle, Say e, string arguments = null)
        {
            map = string.IsNullOrEmpty(arguments)
                ? MapPicker.GetRecommendedMap(battle.GetContext())
                : MapPicker.FindResources(ResourceType.Map, arguments, battle.MinimalMapSupportLevel).FirstOrDefault();


            if (map == null)
            {
                battle.Respond(e, "Cannot find such map.");
                return(null);
            }
            else if (map.InternalName == battle.MapName)
            {
                battle.Respond(e, "Already on this map.");
                return(null);
            }
            else if (!string.IsNullOrEmpty(arguments) && map.MapSupportLevel < MapSupportLevel.Supported)
            {
                alternativeMap = MapPicker.FindResources(ResourceType.Map, arguments, MapSupportLevel.Supported).FirstOrDefault();
            }


            if (map.MapSupportLevel >= MapSupportLevel.Supported)
            {
                return($"Change map to {map.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{map.ResourceID} ?");
            }
            else
            {
                return($"Change to UNSUPPORTED map {map.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{map.ResourceID} ?");
            }
        }
Exemple #2
0
        public override string Arm(ServerBattle battle, Say e, string arguments = null)
        {
            map = string.IsNullOrEmpty(arguments)
                ? MapPicker.GetRecommendedMap(battle.GetContext())
                : MapPicker.FindResources(ResourceType.Map, arguments).FirstOrDefault();

            if (map == null)
            {
                battle.Respond(e, "Cannot find such map.");
                return(null);
            }

            return($"Change map to {map.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{map.ResourceID} ?");
        }
Exemple #3
0
        public override string Arm(ServerBattle battle, Say e, string arguments = null)
        {
            Map = string.IsNullOrEmpty(arguments)
                ? MapPicker.GetRecommendedMap(battle.GetContext(), (battle.MinimalMapSupportLevel > MapSupportLevel.Featured) ? battle.MinimalMapSupportLevel : MapSupportLevel.Featured)
                : MapPicker.FindResources(ResourceType.Map, arguments, battle.MinimalMapSupportLevel, true).FirstOrDefault();


            if (Map == null)
            {
                var unsupportedMap = MapPicker.FindResources(ResourceType.Map, arguments, MapSupportLevel.None).FirstOrDefault();
                if (unsupportedMap != null)
                {
                    if (battle.IsAutohost)
                    {
                        battle.Respond(e, $"The map {unsupportedMap.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{unsupportedMap.ResourceID} is not available on this autohost. Play it in a player hosted battle.");
                    }
                    else
                    {
                        battle.Respond(e, $"The map {unsupportedMap.InternalName} {GlobalConst.BaseSiteUrl}/Maps/Detail/{unsupportedMap.ResourceID} is not supported. Unsupported maps can only be played on passworded hosts.");
                    }
                }
                else
                {
                    battle.Respond(e, "Cannot find such a map.");
                }
                return(null);
            }
            else if (Map.InternalName == battle.MapName)
            {
                battle.Respond(e, "Already on this map.");
                return(null);
            }
            else if (!string.IsNullOrEmpty(arguments) && Map.MapSupportLevel < MapSupportLevel.Supported)
            {
                alternativeMap = MapPicker.FindResources(ResourceType.Map, arguments, MapSupportLevel.Supported, true).FirstOrDefault();
            }


            if (Map.MapSupportLevel >= MapSupportLevel.Supported)
            {
                return($"Change map to {Map.InternalName}?");
            }
            else
            {
                return($"Change to UNSUPPORTED map {Map.InternalName}?");
            }
        }
        public override string Arm(ServerBattle battle, Say e, string arguments = null)
        {
            if (string.IsNullOrEmpty(arguments))
            {
                arguments = battle.server.Game ?? GlobalConst.DefaultZkTag;
            }
            game = MapPicker.FindResources(ResourceType.Mod, arguments).FirstOrDefault();

            if ((battle.Mode != AutohostMode.None || !battle.IsPassworded) && arguments != "zk:stable" && !battle.IsAutohost)
            {
                battle.Respond(e, $"You can only do this on custom passworded hosts.");
                return(null);
            }

            if (game == null)
            {
                battle.Respond(e, "Cannot find such game.");
                return(null);
            }

            return($"Change game to {game.RapidTag} {game.InternalName}?");
        }
        public void ValidateAndFillDetails()
        {
            if (IsNullOrEmpty(Title))
            {
                Title = $"{FounderName}'s game";
            }
            if (IsNullOrEmpty(EngineVersion) || (Mode != AutohostMode.None))
            {
                EngineVersion = server.Engine;
            }
            server.Downloader.GetResource(DownloadType.ENGINE, server.Engine);

            switch (Mode)
            {
            case AutohostMode.Game1v1:
                MaxPlayers = 2;
                break;

            case AutohostMode.Planetwars:
                if (MaxPlayers < 2)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.GameChickens:
                if (MaxPlayers < 2)
                {
                    MaxPlayers = 10;
                }
                break;

            case AutohostMode.GameFFA:
                if (MaxPlayers < 3)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.Teams:
                if (MaxPlayers < 4)
                {
                    MaxPlayers = 16;
                }
                break;

            case AutohostMode.None:
                if (MaxPlayers == 0)
                {
                    MaxPlayers = 16;
                }
                break;
            }
            if (MaxPlayers > 32)
            {
                MaxPlayers = 32;
            }

            HostedMod = MapPicker.FindResources(ResourceType.Mod, ModName ?? server.Game ?? GlobalConst.DefaultZkTag).FirstOrDefault();
            HostedMap = MapName != null
                ? MapPicker.FindResources(ResourceType.Map, MapName).FirstOrDefault()
                : MapPicker.GetRecommendedMap(GetContext());

            ModName = HostedMod?.InternalName ?? ModName ?? server.Game ?? GlobalConst.DefaultZkTag;
            MapName = HostedMap?.InternalName ?? MapName ?? "Small_Divide-Remake-v04";

            if (HostedMod != null)
            {
                try
                {
                    HostedModInfo = MetaDataCache.ServerGetMod(HostedMod.InternalName);
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Error loading mod metadata for {0} : {1}", HostedMod.InternalName, ex);
                }
            }
        }
 public override string Arm(ServerBattle battle, Say e, string arguments = null)
 {
     maps = MapPicker.FindResources(ResourceType.Map, arguments, battle.MinimalMapSupportLevel).Take(200).ToList();
     return(String.Empty);
 }
 public override string Arm(ServerBattle battle, Say e, string arguments = null)
 {
     games = MapPicker.FindResources(ResourceType.Mod, arguments).Take(200).ToList();
     return(String.Empty);
 }