public void AddScore(ChallengeEntry entry) { if (entry == null) { return; } entry.Score++; // refresh the gumps DeathmatchGump.RefreshAllGumps(this, false); }
public override void CheckForGameEnd() { if (this.Participants == null || !this.GameInProgress) { return; } ArrayList winner = new ArrayList(); int leftstanding = 0; IChallengeEntry lastentry = null; int maxscore = -99999; // has anyone reached the target score foreach (IChallengeEntry entry in this.Participants) { if (entry.Status == ChallengeStatus.Active) { if (this.TargetScore > 0 && entry.Score >= this.TargetScore) { winner.Add(entry); entry.Winner = true; } if (entry.Score >= maxscore) { maxscore = entry.Score; } leftstanding++; lastentry = entry; } } // if only one is left then they are the winner if (leftstanding == 1 && winner.Count == 0) { winner.Add(lastentry); lastentry.Winner = true; } if (winner.Count == 0 && this.MatchLength > TimeSpan.Zero && (DateTime.UtcNow >= this.MatchStart + this.MatchLength)) { // find the highest score // has anyone reached the target score foreach (IChallengeEntry entry in this.Participants) { if (entry.Status == ChallengeStatus.Active) { if (entry.Score >= maxscore) { winner.Add(entry); entry.Winner = true; } } } } // and then check to see if this is the Deathmatch if (winner.Count > 0) { // declare the winner(s) and end the game foreach (IChallengeEntry entry in winner) { if (entry.Participant != null) { XmlPoints.SendText(entry.Participant, 100311, this.ChallengeName); // "You have won {0}" this.GameBroadcast(100312, entry.Participant.Name); // "The winner is {0}" this.AwardWinnings(entry.Participant, this.TotalPurse / winner.Count); } } this.EndGame(); DeathmatchGump.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.UtcNow - entry.LastCaution > MaximumOfflineDuration) { // penalize them this.SubtractScore(entry); entry.LastCaution = DateTime.UtcNow; } } else { entry.LastCaution = DateTime.UtcNow; statuschange = true; } entry.Caution = ChallengeStatus.Offline; } else { // changing to any other map results in instant // teleport back to the gauntlet // and point loss this.RespawnWithPenalty(entry); 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.UtcNow - entry.LastCaution > MaximumOutOfBoundsDuration) { // teleport them back to the gauntlet this.RespawnWithPenalty(entry); this.GameBroadcast(100401, entry.Participant.Name); // "{0} was penalized." entry.Caution = ChallengeStatus.None; statuschange = true; } } else { entry.LastCaution = DateTime.UtcNow; // 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.UtcNow - entry.LastCaution > MaximumHiddenDuration) { // penalize them this.SubtractScore(entry); entry.Participant.Hidden = false; this.GameBroadcast(100401, entry.Participant.Name); // "{0} was penalized." entry.Caution = ChallengeStatus.None; statuschange = true; } } else { entry.LastCaution = DateTime.UtcNow; // 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 DeathmatchGump.RefreshAllGumps(this, false); } // it is possible that the game could end like this so check this.CheckForGameEnd(); }