public PartialViewResult _myGames(LeagueState state = LeagueState.Preparation) { ApplicationUser user = UserManager.FindById(User.Identity.GetUserId()); IEnumerable <League> myLeagues = GetUsersLeagues(user, state).Where(l => l.State == state); return(PartialView("_myGames", myLeagues)); }
private IList <League> GetUsersLeagues(ApplicationUser user, LeagueState state) { IList <League> myLeagues = new List <League>(); var query = from league in dbContext.Leagues join leaguePlayer in dbContext.LeaguePlayer on league.Id equals leaguePlayer.League.Id where leaguePlayer.User.Id == user.Id && league.State == state select league; myLeagues = query.ToList(); return(myLeagues); }
private void leagueEnd() { switch (LeagueStates) { case LeagueState.None: //Do nothing break; case LeagueState.Match: if (WinningTeam == null) { //Since this was a match already, we are going into OT boys! LeagueStates = LeagueState.OverTime; arena.sendArenaMessage("Game is going into Over Time!"); } break; case LeagueState.OverTime: if (WinningTeam == null) { //Since this was a match already, we are going into Double OT boys! LeagueStates = LeagueState.DoubleOT; arena.sendArenaMessage("Game is going into Double Over Time!"); } break; case LeagueState.DoubleOT: if (WinningTeam == null) { arena.sendArenaMessage("Game is continuing Double Over Time!"); } break; } //Since there is a winner, reset the death count and league status back to default if (WinningTeam != null) { MinDeaths = DefaultMinDeaths; LeagueStates = LeagueState.None; arena._isMatch = false; LeagueEvent = false; arena.sendArenaMessage("This concludes our league match. League event has now been turned OFF!"); } }
/////////////////////////////////////////////////// // Game Functions /////////////////////////////////////////////////// public bool init(IEventObject invoker) { arena = invoker as Arena; CFG = arena._server._zoneConfig; arena.playtimeTickerIdx = 3; //Sets the global ticker index used for changing the timer MinPlayers = CFG.deathMatch.minimumPlayers; MinDeaths = 3; //Change this if we want to run a higher death count DefaultMinDeaths = MinDeaths; VictoryHoldTime = CFG.flag.victoryHoldTime; PreGamePeriod = CFG.deathMatch.startDelay; DeathmatchTimer = CFG.deathMatch.timer; CurrentPlayerStats = new Dictionary <string, PlayerStats>(); foreach (Arena.FlagState fs in arena._flags.Values) { //Register our flag games fs.TeamChange += OnFlagChange; } GameStates = GameState.Init; LeagueStates = LeagueState.None; return(true); }
private void leagueStart() { //Clear saved stats CurrentPlayerStats.Clear(); //Set their stats and make sure they cannot get banner spammed foreach (Player p in arena.PlayersIngame) { if (!CurrentPlayerStats.ContainsKey(p._alias)) { PlayerStats temp = new PlayerStats(); temp.Deaths = 0; temp.Kills = 0; temp.HasPlayed = false; temp.SubbedIn = false; CurrentPlayerStats.Add(p._alias, temp); } p._bAllowBanner = false; } //Lets start our timer switch (LeagueStates) { case LeagueState.None: //This is the start of a new league match, lets set it LeagueStates = LeagueState.Match; break; case LeagueState.Match: arena.sendArenaMessage("Game has started!"); arena.setTicker(1, 3, DeathmatchTimer * 100, "Time Left: ", delegate() { //Trigger game end arena.gameEnd(); } ); break; case LeagueState.OverTime: //Set the deaths since its OT MinDeaths = 1; arena.sendArenaMessage("Game has started!"); arena.setTicker(1, 3, DeathmatchTimer * 100, "Time Left: ", delegate() { //Trigger game end arena.gameEnd(); } ); break; case LeagueState.DoubleOT: //Double OT and after only have 15 min games arena.sendArenaMessage("Game has started!"); arena.setTicker(1, 3, (DeathmatchTimer / 2) * 100, "Time Left: ", delegate() { //Trigger game end arena.gameEnd(); } ); break; } }