/// <summary> /// Allows the user to restore a map that was deleted during this session. /// </summary> public static void RestoreMap() { if (DeletedMaps.Count == 0) { new MessageBox("Info", "You have not deleted any maps during this session. If you delete a map, it will be available for restoration here for the rest of the session, or until you clear the deleted map cache.", IconType.Info); } else { MapPicker picker = new MapPicker(DeletedMaps, "Restore a Map", false); picker.OnClosed += delegate(BaseEventArgs e) { if (picker.ChosenMap != null) { bool NewID = false; Map Map = picker.ChosenMap; if (Data.Maps.ContainsKey(picker.ChosenMap.ID)) // ID in use, generate new ID { Map.ID = GetFreeMapID(); NewID = true; } DeletedMaps.Remove(Map); AddMap(Map); if (NewID) { new MessageBox("Warning", "The ID of the restored map was already in use. It has been assigned a new ID. This may affect map connections or transfer commands.", IconType.Warning); } } }; } }
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} ?"); } }
public MatchManager(GameManager gm, int goal, GameObject medalPrefab, GameObject p1_medaltext, GameObject p2_medaltext, GameObject scoreboard, GameObject countdownText) { this.p1 = gm.p1; this.p2 = gm.p2; this.goal = goal; this.scoreboard = scoreboard; this.countdown = countdownText; this.mapPicker = gm.mapPicker; p1_medals = new Image[goal]; p2_medals = new Image[goal]; for (int i = 0; i < goal; i++) { double offset = (i) * (medalPrefab.GetComponent <RectTransform>().sizeDelta.x * 1.5f); GameObject temp_p1_medal = GameObject.Instantiate(medalPrefab, p1_medaltext.transform); temp_p1_medal.GetComponent <RectTransform>().anchoredPosition += Vector2.right * (float)offset; p1_medals[i] = temp_p1_medal.GetComponent <Image>(); GameObject temp_p2_medal = GameObject.Instantiate(medalPrefab, p2_medaltext.transform); temp_p2_medal.GetComponent <RectTransform>().anchoredPosition += Vector2.right * (float)offset; p2_medals[i] = temp_p2_medal.GetComponent <Image>(); } }
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} ?"); }
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}?"); } }
private async Task <bool> CreateMultiMapPoll() { var poll = new CommandPoll(this, false, false, true); poll.PollEnded += MapVoteEnded; var options = new List <PollOption>(); List <int> pickedMaps = new List <int>(); pickedMaps.Add(HostedMap?.ResourceID ?? 0); using (var db = new ZkDataContext()) { for (int i = 0; i < NumberOfMapChoices; i++) { Resource map = null; if (i < NumberOfMapChoices / 2) { map = MapPicker.GetRecommendedMap(GetContext(), (MinimalMapSupportLevel < MapSupportLevel.Supported) ? MapSupportLevel.Supported : MinimalMapSupportLevel, MapRatings.GetMapRanking(Mode).TakeWhile(x => x.Percentile < 0.2).Select(x => x.Map).Where(x => !pickedMaps.Contains(x.ResourceID)).AsQueryable()); //choose at least 50% popular maps } if (map == null) { map = MapPicker.GetRecommendedMap(GetContext(), (MinimalMapSupportLevel < MapSupportLevel.Featured) ? MapSupportLevel.Supported : MinimalMapSupportLevel, db.Resources.Where(x => !pickedMaps.Contains(x.ResourceID))); } pickedMaps.Add(map.ResourceID); options.Add(new PollOption() { Name = map.InternalName, URL = $"{GlobalConst.BaseSiteUrl}/Maps/Detail/{map.ResourceID}", ResourceID = map.ResourceID, Action = async() => { var cmd = new CmdMap().Create(); cmd.Arm(this, null, map.ResourceID.ToString()); if (cmd.Access == BattleCommand.AccessType.NotIngame && spring.IsRunning) { return; } if (cmd.Access == BattleCommand.AccessType.Ingame && !spring.IsRunning) { return; } await cmd.ExecuteArmed(this, null); } }); } } return(await StartVote(new CmdMap().GetIneligibilityReasonFunc(this), options, null, "Choose the next map", poll, MapVoteTime)); }
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 RecommendedMapResult GetRecommendedMap(BattleContext context, bool pickNew) { return(MapPicker.GetRecommendedMap(context, pickNew)); }
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); }