// GET: /Ladders/Maps public ActionResult Maps(LaddersMapsModel model) { model = model ?? new LaddersMapsModel(); var ret = MapRatings.GetMapRanking(model.Category).AsQueryable(); if (!string.IsNullOrEmpty(model.Name)) { var termLower = model.Name.ToLower(); ret = ret.Where(x => x.Map.InternalName.ToLower().Contains(termLower)); } if (!string.IsNullOrEmpty(model.Author)) { var termLower = model.Author.ToLower(); ret = ret.Where(x => x.Map.AuthorName.ToLower().Contains(termLower)); } if (model.SizeFrom.HasValue) { ret = ret.Where(x => x.Map.MapWidth >= model.SizeFrom && x.Map.MapHeight >= model.SizeFrom); } if (model.SizeTo.HasValue) { ret = ret.Where(x => x.Map.MapWidth <= model.SizeTo && x.Map.MapHeight <= model.SizeTo); } if (model.SupportLevel.HasValue) { ret = ret.Where(x => x.Map.MapSupportLevel >= model.SupportLevel); } model.Data = ret; return(View("LaddersMaps", model)); }
public ZkLobbyServer(string geoIPpath, IPlanetwarsEventCreator creator) { RatingSystems.Init(); MapRatings.Init(); PlanetWarsEventCreator = creator; var entry = Assembly.GetExecutingAssembly(); Version = entry.GetName().Version.ToString(); Engine = MiscVar.DefaultEngine; SpringPaths = new SpringPaths(GlobalConst.SpringieDataDir, false, false); Downloader = new PlasmaDownloader.PlasmaDownloader(null, SpringPaths); Downloader.GetResource(DownloadType.ENGINE, MiscVar.DefaultEngine); Downloader.PackageDownloader.DoMasterRefresh(); Game = MiscVar.LastRegisteredZkVersion; LoginChecker = new LoginChecker(this, geoIPpath); SteamWebApi = new SteamWebApi(GlobalConst.SteamAppID, new Secrets().GetSteamWebApiKey()); chatRelay = new ChatRelay(this, new List <string>() { "zkdev", "sy", "moddev", "weblobbydev", "ai", "zk", "zkmap", "springboard", GlobalConst.ModeratorChannel, GlobalConst.CoreChannel, "off-topic", "support", "modding", "crashreports" }); textCommands = new ServerTextCommands(this); ChannelManager = new ChannelManager(this); MatchMaker = new MatchMaker(this); battleListUpdater = new BattleListUpdater(this); PartyManager = new PartyManager(this); PlanetWarsMatchMaker = new PlanetWarsMatchMaker(this); NewsListManager = new NewsListManager(this); LadderListManager = new LadderListManager(this); ForumListManager = new ForumListManager(this); SpawnAutohosts(); RatingSystems.GetRatingSystems().ForEach(x => x.RatingsUpdated += (sender, data) => { var db = new ZkDataContext(); var updatedUsers = ConnectedUsers.Select(c => c.Value.User.AccountID).Intersect(data.affectedPlayers).ToHashSet(); db.Accounts.Where(acc => updatedUsers.Contains(acc.AccountID)).ForEach(p => { PublishAccountUpdate(p); PublishUserProfileUpdate(p); }); }); }
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>(); using (var db = new ZkDataContext()) { for (int i = 0; i < NumberOfMapChoices; i++) { Resource map = null; if (i < NumberOfMapChoices / 2) { map = MapPicker.GetRecommendedMap(GetContext(), 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)); }