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(); TeamKotHGump.RefreshAllGumps(this, true); } if (leftstanding < 1) { // declare a tie and keep the fees GameBroadcast(100313); // "The match is a draw" EndGame(); TeamKotHGump.RefreshAllGumps(this, true); } }
public void CheckForKingOfTheHill() { ArrayList mlist = new ArrayList(); ArrayList elist = new ArrayList(); // who is currently on the hill foreach (Mobile p in this.GetMobilesInRange(0)) { if (p == null) { continue; } IChallengeEntry entry = GetParticipant(p); // if this is not a current participant then move them if (entry == null) { // prepare to move them off mlist.Add(p); } else // dont let players who are in a caution state such as hidden to score if (entry.Caution == ChallengeStatus.None) { // prepare to bump their score elist.Add(entry); } } // move non-participants foreach (Mobile p in mlist) { for (int i = 10; i < 20; i++) { int x = p.Location.X + i * (Utility.RandomBool() ? 1 : -1); int y = p.Location.Y + i * (Utility.RandomBool() ? 1 : -1); int z = Map.GetAverageZ(x, y); Point3D newloc = new Point3D(x, y, z); if (XmlSpawner.IsValidMapLocation(newloc, p.Map)) { p.MoveToWorld(newloc, p.Map); } } } // only score if one player is alone on the hill if (elist.Count == 1) { IChallengeEntry entry = (IChallengeEntry)elist[0]; if (entry != null && entry.Participant != null) { // 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 TeamKotHGump.RefreshAllGumps(this, false); // check for win conditions CheckForGameEnd(); } } }
public void CheckForDisqualification() { if (Participants == null || !GameInProgress) { return; } bool statuschange = false; foreach (IChallengeEntry entry in 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 != 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; GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" 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; GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" RefreshSymmetricNoto(entry.Participant); statuschange = true; } } else // make a range check if (m_ArenaSize > 0 && !Utility.InRange(entry.Participant.Location, Location, m_ArenaSize) || (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; GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" 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 // make a hiding check 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; GameBroadcast(100308, entry.Participant.Name); // "{0} has been disqualified" 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 them if (entry.Status == ChallengeStatus.Disqualified) { ClearChallenge(entry.Participant); } } if (statuschange) { // update gumps with the new status TeamKotHGump.RefreshAllGumps(this, false); } // it is possible that the game could end like this so check CheckForGameEnd(); }