public void CheckForDeathBall() { Mobile owner = null; if (this.m_DeathBall != null && this.m_DeathBall.RootParent is Mobile) { owner = this.m_DeathBall.RootParent as Mobile; } // only score if one player is carrying the ball if (owner != null) { IChallengeEntry entry = this.GetParticipant(owner); // dont let players who are in a caution state such as hidden or out of bounds to score if (entry != null && entry.Participant != null && entry.Caution == ChallengeStatus.None) { // bump their score entry.Score++; // display the score entry.Participant.PublicOverheadMessage(MessageType.Regular, 0, true, entry.Score.ToString()); // update all the gumps if you like TeamDeathballGump.RefreshAllGumps(this, false); // check for win conditions this.CheckForGameEnd(); } } else { // check to see if someone is carrying it if (this.Participants != null) { foreach (IChallengeEntry entry in this.Participants) { if (entry.Status == ChallengeStatus.Active && entry.Participant != null && entry.Participant.Holding == this.m_DeathBall) { // bump their score entry.Score++; // display the score entry.Participant.PublicOverheadMessage(MessageType.Regular, 0, true, entry.Score.ToString()); // update all the gumps if you like TeamDeathballGump.RefreshAllGumps(this, false); // check for win conditions this.CheckForGameEnd(); break; } } } } }
public override void CheckForGameEnd() { if (Participants == null || !GameInProgress) { return; } int leftstanding = 0; TeamInfo winner = null; ArrayList teams = GetTeams(); foreach (TeamInfo t in teams) { if (!HasValidMembers(t)) { continue; } if (t.Score >= TargetScore) { winner = t; leftstanding = 1; break; } leftstanding++; winner = t; } // and then check to see if this is the King of the Hill if (leftstanding == 1 && winner != null) { // declare the winner(s) and end the game // flag all members as winners foreach (IChallengeEntry entry in winner.Members) { entry.Winner = true; } GameBroadcast(100414, winner.ID); // "Team {0} is the winner!" AwardTeamWinnings(winner.ID, TotalPurse); Winner = winner.ID; EndGame(); TeamDeathballGump.RefreshAllGumps(this, true); } if (leftstanding < 1) { // declare a tie and keep the fees GameBroadcast(100313); // "The match is a draw" EndGame(); TeamDeathballGump.RefreshAllGumps(this, true); } }
public void CheckForDisqualification() { if (this.Participants == null || !this.GameInProgress) { return; } bool statuschange = false; foreach (IChallengeEntry entry in this.Participants) { if (entry.Participant == null || entry.Status == ChallengeStatus.Forfeit || entry.Status == ChallengeStatus.Disqualified) { 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) { entry.Status = ChallengeStatus.Disqualified; this.GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" this.RefreshSymmetricNoto(entry.Participant); statuschange = true; } } else { entry.LastCaution = DateTime.UtcNow; statuschange = true; } entry.Caution = ChallengeStatus.Offline; } else { // changing to any other map is instant disqualification entry.Status = ChallengeStatus.Disqualified; this.GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" this.RefreshSymmetricNoto(entry.Participant); statuschange = true; } } 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) { entry.Status = ChallengeStatus.Disqualified; this.GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" this.RefreshSymmetricNoto(entry.Participant); 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) { entry.Status = ChallengeStatus.Disqualified; this.GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" this.RefreshSymmetricNoto(entry.Participant); 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 they were disqualified, then drop any ball they might have had and boot them from the game if (entry.Status == ChallengeStatus.Disqualified) { this.ClearChallenge(entry.Participant); this.DropBall(entry.Participant, this.Location, this.Map); } } if (statuschange) { // update gumps with the new status TeamDeathballGump.RefreshAllGumps(this, false); } // it is possible that the game could end like this so check this.CheckForGameEnd(); }