public void AddScore(ChallengeEntry entry) { if (entry == null) { return; } entry.Score++; // refresh the gumps CTFGump.RefreshAllGumps(this, false); }
public override void CheckForGameEnd() { if (this.Participants == null || !this.GameInProgress) { return; } ArrayList winner = new ArrayList(); ArrayList teams = this.GetTeams(); int leftstanding = 0; int maxscore = -99999; // has any team reached the target score TeamInfo lastt = null; foreach (TeamInfo t in teams) { if (!this.HasValidMembers(t)) { continue; } if (this.TargetScore > 0 && t.Score >= this.TargetScore) { winner.Add(t); t.Winner = true; } if (t.Score >= maxscore) { maxscore = t.Score; } leftstanding++; lastt = t; } // check to make sure the team hasnt been disqualified // if only one is left then they are the winner if (leftstanding == 1 && winner.Count == 0) { winner.Add(lastt); lastt.Winner = true; } if (winner.Count == 0 && this.MatchLength > TimeSpan.Zero && (DateTime.Now >= this.MatchStart + this.MatchLength)) { // find the highest score // has anyone reached the target score foreach (TeamInfo t in teams) { if (!this.HasValidMembers(t)) { continue; } if (t.Score >= maxscore) { winner.Add(t); t.Winner = true; } } } // and then check to see if this is the CTF if (winner.Count > 0) { // declare the winner(s) and end the game foreach (TeamInfo t in winner) { // flag all members as winners foreach (IChallengeEntry entry in t.Members) { entry.Winner = true; } this.GameBroadcast(100414, t.ID); // "Team {0} is the winner!" this.GameBroadcastSound(744); this.AwardTeamWinnings(t.ID, this.TotalPurse / winner.Count); if (winner.Count == 1) { this.Winner = t.ID; } } this.RefreshAllNoto(); this.EndGame(); CTFGump.RefreshAllGumps(this, true); } }
public void CheckForDisqualification() { if (this.Participants == null || !this.GameInProgress) { return; } bool statuschange = false; foreach (ChallengeEntry entry in this.Participants) { if (entry.Participant == null || entry.Status != ChallengeStatus.Active) { continue; } bool hadcaution = (entry.Caution != ChallengeStatus.None); // and a map check if (entry.Participant.Map != this.Map) { // check to see if they are offline if (entry.Participant.Map == Map.Internal) { // then give them a little time to return before disqualification if (entry.Caution == ChallengeStatus.Offline) { // were previously out of bounds so check for disqualification // check to see how long they have been out of bounds if (DateTime.Now - entry.LastCaution > MaximumOfflineDuration) { // return any flag they might be carrying this.ReturnAnyFlags(entry.Participant); entry.LastCaution = DateTime.Now; } } else { entry.LastCaution = DateTime.Now; statuschange = true; } entry.Caution = ChallengeStatus.Offline; } else { // changing to any other map results in // return of any flag they might be carrying this.ReturnAnyFlags(entry.Participant); entry.Caution = ChallengeStatus.None; } } else if (this.m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, this.Location, this.m_ArenaSize) || (this.IsInChallengeGameRegion && !(Region.Find(entry.Participant.Location, entry.Participant.Map) is ChallengeGameRegion))) { if (entry.Caution == ChallengeStatus.OutOfBounds) { // were previously out of bounds so check for disqualification // check to see how long they have been out of bounds if (DateTime.Now - entry.LastCaution > MaximumOutOfBoundsDuration) { // return any flag they might be carrying this.ReturnAnyFlags(entry.Participant); entry.Caution = ChallengeStatus.None; statuschange = true; } } else { entry.LastCaution = DateTime.Now; // inform the player XmlPoints.SendText(entry.Participant, 100309, MaximumOutOfBoundsDuration.TotalSeconds); // "You are out of bounds! You have {0} seconds to return" statuschange = true; } entry.Caution = ChallengeStatus.OutOfBounds; } else if (entry.Participant.Hidden) { if (entry.Caution == ChallengeStatus.Hidden) { // were previously hidden so check for disqualification // check to see how long they have hidden if (DateTime.Now - entry.LastCaution > MaximumHiddenDuration) { // return any flag they might be carrying this.ReturnAnyFlags(entry.Participant); entry.Participant.Hidden = false; entry.Caution = ChallengeStatus.None; statuschange = true; } } else { entry.LastCaution = DateTime.Now; // inform the player XmlPoints.SendText(entry.Participant, 100310, MaximumHiddenDuration.TotalSeconds); // "You have {0} seconds become unhidden" statuschange = true; } entry.Caution = ChallengeStatus.Hidden; } else { entry.Caution = ChallengeStatus.None; } if (hadcaution && entry.Caution == ChallengeStatus.None) { statuschange = true; } } if (statuschange) { // update gumps with the new status CTFGump.RefreshAllGumps(this, false); } // it is possible that the game could end like this so check this.CheckForGameEnd(); }