public void checkForwinner(int now) { List <Team> removes = _activeTeams.Where(t => t.ActivePlayerCount == 0).ToList(); foreach (Team team in removes) { if (_activeTeams.Contains(team)) { _activeTeams.Remove(team); } } List <Team> removes2 = new List <Team>(); foreach (Team team in _activeTeams) { int teamAlivePlayerCount = team.ActivePlayerCount; foreach (Player player in team.ActivePlayers) { if (player.IsDead) { teamAlivePlayerCount--; } } if (teamAlivePlayerCount == 0) { removes2.Add(team); } } foreach (Team team in removes2) { if (_activeTeams.Contains(team)) { _activeTeams.Remove(team); } } int teamCount = _activeTeams.Count; if (teamCount == 1) { _victoryTeam = _activeTeams.First(); _baseScript._winner = _victoryTeam; if (_victoryTeam == null) { _arena.sendArenaMessage("There was no winner"); } else { _arena.sendArenaMessage(String.Format("{0} has won!", _victoryTeam._name)); } _baseScript.bJackpot = false; int gameLength = 0; int fixedJackpot = 2000; gameLength = (now - _tickGameStart) / 1000; double jackpot = _arena.TotalPlayerCount * 500; jackpot += (gameLength * 50); jackpot += fixedJackpot; int bonusCash = 0; int bonusExp = 0; int bonusPoints = 0; foreach (Player player in _arena.Players) { if (_baseScript.StatsCurrent(player).hasPlayed) { if (_victoryTeam != null) { if (player._team._name == _victoryTeam._name) { bonusCash = Convert.ToInt32(jackpot * 0.5); bonusExp = Convert.ToInt32(jackpot * 0.5); bonusPoints = Convert.ToInt32(jackpot * 1); } else { bonusCash = Convert.ToInt32((jackpot * 0.5) / 4); bonusExp = Convert.ToInt32((jackpot * 0.5) / 4); bonusPoints = Convert.ToInt32((jackpot * 1) / 4); } } else { bonusCash = Convert.ToInt32((jackpot * 0.5) / 4); bonusExp = Convert.ToInt32((jackpot * 0.5) / 4); bonusPoints = Convert.ToInt32((jackpot * 1) / 4); } player.sendMessage(0, String.Format("Tournament Bonus: (Points={2} Cash={0} Experience={1} )", bonusCash, bonusExp, bonusPoints)); if (Script_Multi._bPvpHappyHour) { player.sendMessage(0, String.Format("Additional PvP Happy Hour Bonus: (Cash={0})", bonusCash)); bonusCash += bonusCash; } player.Cash += bonusCash; player.Experience += bonusExp; player.BonusPoints += bonusPoints; player.syncState(); } } _arena.gameEnd(); } if (teamCount == 0) //What about a tie? { _victoryTeam = null; _baseScript._winner = null; if (_victoryTeam == null) { _arena.sendArenaMessage("There was no winner"); } _baseScript.bJackpot = false; int gameLength = 0; int fixedJackpot = 2000; gameLength = (now - _tickGameStart) / 1000; double jackpot = _arena.TotalPlayerCount * 500; jackpot += (gameLength * 50); jackpot += fixedJackpot; int bonusCash = 0; int bonusExp = 0; int bonusPoints = 0; foreach (Player player in _arena.Players) { if (_baseScript.StatsCurrent(player).hasPlayed) { if (_victoryTeam != null) { if (player._team._name == _victoryTeam._name) { bonusCash = Convert.ToInt32(jackpot * 0.5); bonusExp = Convert.ToInt32(jackpot * 0.5); bonusPoints = Convert.ToInt32(jackpot * 1); } else { bonusCash = Convert.ToInt32((jackpot * 0.5) / 4); bonusExp = Convert.ToInt32((jackpot * 0.5) / 4); bonusPoints = Convert.ToInt32((jackpot * 1) / 4); } } else { bonusCash = Convert.ToInt32((jackpot * 0.5) / 4); bonusExp = Convert.ToInt32((jackpot * 0.5) / 4); bonusPoints = Convert.ToInt32((jackpot * 1) / 4); } player.sendMessage(0, String.Format("Tournament Bonus: (Points={2} Cash={0} Experience={1} )", bonusCash, bonusExp, bonusPoints)); if (Script_Multi._bPvpHappyHour) { player.sendMessage(0, String.Format("Additional PvP Happy Hour Bonus: (Cash={0})", bonusCash)); bonusCash += bonusCash; } player.Cash += bonusCash; player.Experience += bonusExp; player.BonusPoints += bonusPoints; player.syncState(); } } _arena.gameEnd(); } }
/// <summary> /// Updates our tickers /// </summary> public void UpdateTickers() { if (!_arena._bGameRunning) { return; } IEnumerable <Team> active = _arena.ActiveTeams; Team collie = active.Count() > 1 ? active.ElementAt(1) : _arena.getTeamByName(_config.teams[0].name); Team titan = active.Count() > 0 ? active.ElementAt(0) : _arena.getTeamByName(_config.teams[1].name); Rewards.Jackpot jackpot = Rewards.calculateJackpot(_arena.Players, null, Settings.GameTypes.Conquest, _baseScript, true); string format = string.Format(""); //_arena.setTicker(1, 2, 0, format); //Personal Scores _arena.setTicker(2, 1, 0, delegate(Player p) { if (_baseScript.StatsCurrent(p) == null) { return(""); } Rewards.Jackpot.Reward reward = jackpot._playerRewards.FirstOrDefault(r => r.player == p); if (reward == null) { return(""); } //Update their ticker return(string.Format("Personal Score: Kills={0} - Deaths={1} - MVP={2}%", _baseScript.StatsCurrent(p).kills, _baseScript.StatsCurrent(p).deaths, Math.Round(reward.MVP * 100, 1))); }); //1st and 2nd place List <Rewards.Jackpot.Reward> ranked = new List <Rewards.Jackpot.Reward>(); foreach (Rewards.Jackpot.Reward reward in jackpot._playerRewards.OrderByDescending(r => r.MVP)) { if (reward.Score == 0) { continue; } ranked.Add(reward); } int idx = 3; format = ""; foreach (Rewards.Jackpot.Reward ranker in ranked) { if (idx-- == 0) { break; } switch (idx) { case 2: format = string.Format("1st: {0}(K={1} D={2} MVP={3}%)", ranker.player._alias, _baseScript.StatsCurrent(ranker.player).kills, _baseScript.StatsCurrent(ranker.player).deaths, Math.Round(ranker.MVP * 100, 1)); break; case 1: format = (format + string.Format(" 2nd: {0}(K={1} D={2} MVP={3}%)", ranker.player._alias, _baseScript.StatsCurrent(ranker.player).kills, _baseScript.StatsCurrent(ranker.player).deaths, Math.Round(ranker.MVP * 100, 1))); break; } } if (!_arena.recycling) { _arena.setTicker(2, 0, 0, format); } }
/// <summary> /// Updates our tickers /// </summary> public void UpdateTickers() { if (!_arena._bGameRunning) { return; } IEnumerable <Team> active = _arena.ActiveTeams; if (activeTeams != null && activeTeams.Count() > 0) { active = activeTeams; } Team collie = active.Count() > 1 ? active.ElementAt(1) : _arena.getTeamByName(_config.teams[0].name); Team titan = active.Count() > 0 ? active.ElementAt(0) : _arena.getTeamByName(_config.teams[1].name); string format = string.Format("{0}={1} - {2}={3}", titan._name, titan._currentGameKills, collie._name, collie._currentGameKills); //We playing more events at the same time? if (active.Count() > 3) { Team third = active.ElementAt(2); Team fourth = active.ElementAt(3); format = string.Format("{0}={1} - {2}={3} | {4}={5} - {6}={7}", titan._name, titan._currentGameKills, collie._name, collie._currentGameKills, third._name, third._currentGameKills, fourth._name, fourth._currentGameKills); } _arena.setTicker(1, 2, 0, format); //Personal Scores _arena.setTicker(2, 1, 0, delegate(Player p) { if (_baseScript.StatsCurrent(p) == null) { return(""); } //Update their ticker return(string.Format("HP={0} Personal Score: Kills={1} - Deaths={2}", p._state.health, _baseScript.StatsCurrent(p).kills, _baseScript.StatsCurrent(p).deaths)); }); //1st and 2nd place List <Player> ranked = new List <Player>(); foreach (Player p in _arena.Players) { if (p == null) { continue; } if (_baseScript.StatsCurrent(p) == null) { continue; } if (_baseScript.StatsCurrent(p).hasPlayed) { ranked.Add(p); } } IEnumerable <Player> ranking = ranked.OrderBy(player => _baseScript.StatsCurrent(player).deaths).OrderByDescending(player => _baseScript.StatsCurrent(player).kills); int idx = 3; format = ""; foreach (Player rankers in ranking) { if (idx-- == 0) { break; } switch (idx) { case 2: format = string.Format("1st: {0}(K={1} D={2})", rankers._alias, _baseScript.StatsCurrent(rankers).kills, _baseScript.StatsCurrent(rankers).deaths); break; case 1: format = (format + string.Format(" 2nd: {0}(K={1} D={2})", rankers._alias, _baseScript.StatsCurrent(rankers).kills, _baseScript.StatsCurrent(rankers).deaths)); break; } } if (!_arena.recycling) { _arena.setTicker(2, 0, 0, format); } }