예제 #1
0
		private void FillTable() //Uses SignedUp to fill the GameTable with Matches -> NOTE: Shuffle before calling
		{
			for(int i = 0; i < GameTable.Length; ++i)
			{
				int defender = GameTable.Length + i;

				GameTable[i] = new Match((List<Mobile>)(i > m_SignedUp.Count - 1 ? null : m_SignedUp[i]), (List<Mobile>)(defender > m_SignedUp.Count - 1 ? null : m_SignedUp[defender]), (m_AllowTeams ? MatchType.Multi : MatchType.Single));
			}
		}
예제 #2
0
		private void RefactorTable()
		{
			if(GameTable.Length % 2 != 0)
				Console.WriteLine("GameTable has uneven amount of matches. Matches: {0}", GameTable.Length); //Debugging purposes

			//Take the first half of the Game Table, and load the winners into Attacker slots
			for(int i = 0; i < (GameTable.Length / 2); i++)
			{
				Match current = GameTable[i];

				current.Attackers = current.Winners;

				current.Defenders = null;
				current.Winners = null;
				current.MatchStatus = MatchStatus.Waiting;
			}

			//Take second half of the Game Table, and load all winners into Defender slots
			for(int i = (GameTable.Length / 2); i < GameTable.Length; i++)
			{
				Match current = GameTable[i];
				Match toSwitch = GameTable[i - (GameTable.Length / 2)];

				toSwitch.Defenders = current.Winners;
			}

			//Make a temp array half sized
			Match[] temp = new Match[GameTable.Length / 2];

			//Move first half of GameTable to temp
			for(int i = 0; i < temp.Length; ++i)
			{
				temp[i] = GameTable[i];
			}

			//Reassign GameTable
			GameTable = temp;
		}
예제 #3
0
		private Match[] GetCurrentMatches()
		{
			List<Match> temp = new List<Match>();

			for(int i = 0; i < GameTable.Length; ++i)
			{
				Match current = GameTable[i];

				if(current != null && current.MatchStatus == MatchStatus.Fighting)
					temp.Add(current);
			}

			if(temp.Count != 0)
			{
				Match[] fighting = new Match[temp.Count];

				for(int i = 0; i < fighting.Length; ++i)
					fighting[i] = temp[i];

				return fighting;
			}

			return null;
		}
예제 #4
0
		private bool ArenaContainsMatch(Rectangle3D arena, Match match)
		{
			for(int i = 0; i < match.Attackers.Count; ++i) //Loop through attackers
			{
				if(arena.Contains(match.Attackers[i].Location))
					return true;
			}

			for(int i = 0; i < match.Defenders.Count; ++i) //Loop through defenders
			{
				if(arena.Contains(match.Defenders[i].Location))
					return true;
			}

			return false;
		}
예제 #5
0
		private bool CheckFight(Match m)
		{
			if(m.Attackers == null && m.Defenders != null)
			{
				m.Winners = m.Defenders;
				return false;
			}
			if(m.Attackers != null && m.Defenders == null)
			{
				m.Winners = m.Attackers;
				return false;
			}
			if(m.Attackers == null && m.Defenders == null)
			{
				m.Winners = null;
				return false;
			}

			return true;
		}
예제 #6
0
		private void PrepMatch(Match m, Rectangle3D arena)
		{
			if(!CheckFight(m)) //Checks for nulls in Matches
			{
				Match_OnEnd(m);
				return;
			}

			m.MatchStatus = MatchStatus.Fighting;

			//Prepare attackers
			for(int i = 0; i < m.Attackers.Count; ++i)
			{
				PrepFighter(m.Attackers[i]); //Res -> Unmount -> AntiCheat
				m.Attackers[i].Location = GetLocation(arena, true);
			}
			//Prepare defenders
			for(int i = 0; i < m.Defenders.Count; ++i)
			{
				PrepFighter(m.Defenders[i]); //Res -> Unmount -> AntiCheat
				m.Defenders[i].Location = GetLocation(arena, false);
			}

			Item wall = new WallOfStoneEast();
			wall.MoveToWorld(Middle(arena), this.Map);

			Timer.DelayCall(TimeSpan.FromSeconds(10.0),new TimerStateCallback( Start_CallBack ), new object[]{ m, wall });

			Round_NewMatch(); //Check to see if any more matches can take place
		}
예제 #7
0
		private void Match_OnEnd(Match match) //Called by "PrepMatch()" when there is a null fight or a "bye"
		{
			List<Mobile> losers;

			//Find the losers
			if(match.Winners == match.Attackers)
				losers = match.Defenders;
			else
				losers = match.Attackers;

			Match_OnEnd(match, losers);
		}
예제 #8
0
		private void Match_OnEnd(Match match, List<Mobile> losers)
		{
			if(losers == match.Attackers)
				match.Winners = match.Defenders;
			else
				match.Winners = match.Attackers;

			match.MatchStatus = MatchStatus.Over;

			if(match.Attackers != null && match.Defenders != null)
			{
				//Prepare attackers
				for(int i = 0; i < match.Attackers.Count; ++i)
					HandleMatchEnd(match.Attackers[i], true);

				//Prepare defenders
				for(int i = 0; i < match.Defenders.Count; ++i)
					HandleMatchEnd(match.Defenders[i], true);
			}

			NullifyEmptyTeams();

			if(Round_IsOver())
			{
				if(GameTable.Length > 1)
					RefactorTable();
				else //FINAL ROUND
				{
					Tournament_OnEnd(match);
					return;
				}
			}

			Round_NewMatch();
		}
예제 #9
0
		private void Tournament_OnEnd(Match match)
		{
			string names = "";
			bool multi = match.Winners.Count > 1;

			for(int i = 0; i < match.Winners.Count; ++i)
				names += match.Winners[i].Name + (i == match.Winners.Count - 1 ? "" : ", ");

			World.Broadcast( 1154, true, String.Format("The tournament is now over. The winner{0} {1}: {2}", multi ? "s" : "", multi ? "were" : "was", names) );

			GameTable = null;
			m_SignedUp = new List<List<Mobile>>();
			m_Started = false;
		}