コード例 #1
0
 public TournamentPrizeGump(Mobile from, Tournament tournament)
     : this()
 {
     caller = from;
     t = tournament;
     PrizeInfo();
 }
コード例 #2
0
 public TournamentInfoGump(Mobile from, Tournament tournament)
     : this()
 {
     caller = from;
     t = tournament;
     TournamentInfo();
 }
コード例 #3
0
 public TeamConfirmGump(Mobile from, Tournament tournament, Teams fullteam)
     : this()
 {
     caller = from;
     t = tournament;
     team = fullteam;
     size = team.getOwners().Count-1;
     TeamInfo();
 }
コード例 #4
0
ファイル: Manager.cs プロジェクト: greeduomacro/RunUO-1
        public static void FilterInactiveTeams(Tournament tourney)
        {
            List<Teams> inactive = new List<Teams>();
            foreach (Teams t in tourney.Teams)
            {
                foreach(Mobile m in t.getOwners())
                {
                    if ((!IsOnline((PlayerMobile)m) || (!(m.Region is GuardedRegion) && !(m.Region is HouseRegion)) || m.Criminal) && !inactive.Contains(t))
                        inactive.Add(t);
                }
            }

            foreach (Teams t in inactive)
                tourney.Teams.Remove(t);
        }
コード例 #5
0
        /// <summary>
        /// The main tournament timer.
        /// Setup the brackets and start the timer
        /// </summary>
        public TournamentTimer(Tournament tournament)
        {
            Random rand = new Random();
            Manager.FilterInactiveTeams(tournament);
            m_CurrentRound = 0;
            m_CurrentMatch = 0;
            m_DelayStart = TimeSpan.FromSeconds(30.0);
            m_Contestants = new List<Teams>();
            m_Matches = new List<Match>();
            m_Arenas = new List<ArenaControl>();
            m_Tournament = tournament;
            m_Bracket = new BuildBracket();
            m_TournamentStarted = false;
            m_Contestants.AddRange(tournament.Teams);
            ShuffleTeams();

            switch (m_Tournament.Type)
            {
                case TournamentType.RoundRobin:
                {
                    break;
                }
                case TournamentType.SingleElimination:
                {
                    m_Bracket.SingleElimination(m_Contestants);
                    break;
                }
                case TournamentType.DoubleElimination:
                {
                    break;
                }
                case TournamentType.Hybrid:
                {
                    break;
                }
            }

            string arenaset = (m_Tournament.ArenaSets != null && m_Tournament.ArenaSets.Count > 0)? m_Tournament.ArenaSets[rand.Next(m_Tournament.ArenaSets.Count)] : "";
            m_Arenas = ArenaControl.GetArenaSet(m_Tournament.TeamSize, arenaset);
            if (!(m_Arenas.Count > 0))
                m_Arenas = ArenaControl.RandomArenaSet(m_Tournament.TeamSize);
        }
コード例 #6
0
        public CreateTeamGump(Mobile from, Tournament tournament)
            : this()
        {
            caller = from;
            t = tournament;

            switch (t.TeamSize)
            {
                case ArenaType.TwoVsTwo:
                {
                    size = 1;
                    break;
                }
                case ArenaType.ThreeVsThree:
                {
                    size = 2;
                    break;
                }
                case ArenaType.FourVsFour:
                {
                    size = 3;
                    break;
                }
                case ArenaType.FiveVsFive:
                {
                    size = 4;
                    break;
                }
                default:
                {
                    size = 0;
                    break;
                }
            }

            team = new List<Mobile>();
            team.Add(from);
            TeamInfo();
        }
コード例 #7
0
 public InternalTarget(Tournament tournament, string place)
     : base(10, true, TargetFlags.None)
 {
     t = tournament;
     p = place;
 }
コード例 #8
0
ファイル: XMLDates.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Adds the tournament to the "tournament" list
        /// and sorts the list by date
        /// </summary>
        /// <param name="tournament">Tournament to be added</param>
        public static void AddTournament(Tournament tournament)
        {
            if (!m_Events.ContainsKey("tournament"))
            {
                List<object> list = new List<object>();
                list.Add(tournament);
                m_Events.Add("tournament", list);
            }
            else
            {
                m_Events["tournament"].Add(tournament);
            }

            if (m_Events.ContainsKey("tournament"))
            {
                List<Tournament> list = new List<Tournament>();
                foreach (object obj in m_Events["tournament"])
                {
                    Tournament t = (Tournament)obj;
                    list.Add(t);
                }

                list.Sort(delegate(Tournament t1, Tournament t2) { return t1.Date.CompareTo(t2.Date); });
                m_Events["tournament"].Clear();
                foreach (object obj in list)
                {
                    m_Events["tournament"].Add(obj);
                }
            }
            Save();
        }
コード例 #9
0
ファイル: XMLDates.cs プロジェクト: greeduomacro/RunUO-1
 /// <summary>
 /// Gets if the tournament is the type that is to be
 /// removed
 /// </summary>
 /// <param name="t">tournament to check</param>
 /// <returns></returns>
 private static bool RemoveType(Tournament t)
 {
     return t.TeamSize == m_Type;
 }
コード例 #10
0
ファイル: XMLDates.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Loads the various events to EventDates.xml
        /// </summary>
        private static void Load()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(filePath);
            XmlElement root = doc["eventdates"];

            #region Load Tournaments
            foreach (XmlElement ts in root.GetElementsByTagName("tournaments"))
            {
                foreach (XmlElement element in ts.GetElementsByTagName("tournament"))
                {
                    Tournament tournament = new Tournament();
                    bool supplied;
                    if (!bool.TryParse(element.GetAttribute("supplied"), out supplied))
                        supplied = false;
                    tournament.Supplied = supplied;

                    foreach (XmlElement e in element.GetElementsByTagName("date"))
                    {
                        string typestring = e.InnerText;
                        string[] split = typestring.Split(' ');
                        if (split.Length == 3)
                        {
                            string date = split[0];
                            string time = split[1];
                            string pm = split[2];
                            tournament.Date = ValidDateTime(date, time, pm);
                        }
                    }

                    foreach (XmlElement e in element.GetElementsByTagName("type"))
                    {
                        string typestring = e.InnerText;
                        typestring = typestring.ToLower();

                        switch (typestring)
                        {
                            case "roundrobin":
                            {
                                tournament.Type = TournamentType.RoundRobin;
                                break;
                            }
                            case "singleelimination":
                            {
                                tournament.Type = TournamentType.SingleElimination;
                                break;
                            }
                            case "doubleeleimination":
                            {
                                tournament.Type = TournamentType.DoubleElimination;
                                break;
                            }
                            case "hybrid":
                            {
                                tournament.Type = TournamentType.Hybrid;
                                break;
                            }
                        }
                    }
                    foreach (XmlElement e in element.GetElementsByTagName("teamsize"))
                    {
                        string typestring = e.InnerText;
                        typestring = typestring.ToLower();

                        switch (typestring)
                        {
                            case "onevsone":
                            {
                                tournament.TeamSize = ArenaType.OneVsOne;
                                break;
                            }
                            case "twovstwo":
                            {
                                tournament.TeamSize = ArenaType.TwoVsTwo;
                                break;
                            }
                            case "threevsthree":
                            {
                                tournament.TeamSize = ArenaType.ThreeVsThree;
                                break;
                            }
                            case "fourvsfour":
                            {
                                tournament.TeamSize = ArenaType.FourVsFour;
                                break;
                            }
                            case "fivevsfive":
                            {
                                tournament.TeamSize = ArenaType.FiveVsFive;
                                break;
                            }
                        }
                    }

                    foreach (XmlElement e in element.GetElementsByTagName("teams"))
                    {
                        string typestring = e.InnerText;
                        Mobile m;
                        string[] list = typestring.Split('/');
                        foreach (string t in list)
                        {
                            if (t.Length > 0)
                            {
                                List<Mobile> team = new List<Mobile>();
                                string[] mobiles = t.Split(',');
                                foreach (string s in mobiles)
                                {
                                    try
                                    {
                                        Serial serial = Utility.ToInt32(s);
                                        World.Mobiles.TryGetValue(serial, out m);
                                        team.Add(m);
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine("Error in XMLDates: " + exception.Message);
                                    }
                                }
                                tournament.Teams.Add(new Teams(team));
                            }
                        }
                    }

                    foreach (XmlElement e in element.GetElementsByTagName("prizes"))
                    {
                        string typestring = e.InnerText;
                        string[] list = typestring.Split('/');
                        foreach (XmlElement i in e.GetElementsByTagName("item"))
                        {
                            Type type = null;
                            Item item;
                            string place = i.GetAttribute("place");
                            int hue, amount;
                            string itemProps = i.InnerText;
                            string[] props = itemProps.Split(',');

                            if (Region.ReadType(i, "type", ref type))
                            {
                                item = Activator.CreateInstance(type) as Item;
                                if (int.TryParse(props[0], out hue))
                                    item.Hue = hue;
                                if (int.TryParse(props[1], out amount))
                                    item.Amount = amount;
                                tournament.AddPrize(place, item);
                            }
                        }
                    }

                    if (tournament.Date > DateTime.Now && ArenaControl.Arenas.ContainsKey(tournament.TeamSize) &&
                        ArenaControl.Arenas[tournament.TeamSize] != null && ArenaControl.Arenas[tournament.TeamSize].Count > 0)
                        AddTournament(tournament);
                }
            }
            #endregion

            Save();
        }
コード例 #11
0
ファイル: XMLDates.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Removes the tournament from the "tournament" list
        /// and sorts the list by date
        /// </summary>
        /// <param name="tournament">Tournament to be removed</param>
        public static void RemoveTournament(Tournament tournament)
        {
            List<Mobile> hasGump = new List<Mobile>();

            if (m_Events.ContainsKey("tournament"))
            {
                if (m_Events["tournament"].Contains(tournament))
                    m_Events["tournament"].Remove(tournament);

                List<Tournament> list = new List<Tournament>();
                foreach (object obj in m_Events["tournament"])
                {
                    Tournament t = (Tournament)obj;
                    list.Add(t);
                }

                list.Sort(delegate(Tournament t1, Tournament t2) { return t1.Date.CompareTo(t2.Date); });
                m_Events["tournament"].Clear();
                foreach (object obj in list)
                {
                    m_Events["tournament"].Add(obj);
                }
            }

            foreach (UpcomingEventsGump gump in UpcomingEventsGump.OpenGumpList)
                hasGump.Add(gump.caller);
            foreach(Mobile m in hasGump)
            {
                if (m.HasGump(typeof(UpcomingEventsGump)))
                    m.CloseGump(typeof(UpcomingEventsGump));
                m.SendGump(new UpcomingEventsGump(m));
            }

            Save();
        }
コード例 #12
0
 public InternalTarget(Tournament tournament, List<Mobile> updateteam, int position)
     : base(10, true, TargetFlags.None)
 {
     t = tournament;
     team = updateteam;
     pos = position;
 }
コード例 #13
0
ファイル: Teams.cs プロジェクト: greeduomacro/RunUO-1
        public void IsFullTeam( Tournament t, bool accept)
        {
            Accepted.Add(accept);

            if (!Accepted.Contains(false) && (Accepted.Count == (getOwners().Count - 1)))
            {
                bool added = t.AddTeam(this);
                foreach (Mobile m in getOwners())
                {
                    if (added)
                    {
                        if (Manager.IsOnline((PlayerMobile)m))
                            m.SendMessage(String.Format("You have been registered for the {0} tournament on {1} at {2}.", t.TeamSize, t.Date.ToString("MM/dd/yy"), t.Date.ToString("hh:mm tt")));
                    }
                    else if (Manager.IsOnline((PlayerMobile)m))
                        m.SendMessage(String.Format("One or more members are already registered for the {0} tournament on {1} at {2}.", t.TeamSize, t.Date.ToString("MM/dd/yy"), t.Date.ToString("hh:mm tt")));

                    if (m.HasGump(typeof(UpcomingEventsGump)))
                    {
                        UpcomingEventsGump g = (UpcomingEventsGump)m.FindGump(typeof(UpcomingEventsGump));
                        int page = g.CurrentPage;
                        m.CloseGump(typeof(UpcomingEventsGump));
                        m.SendGump(new UpcomingEventsGump(m, page));
                    }
                }
            }
            else if (Accepted.Contains(false) && (Accepted.Count == (getOwners().Count - 1)))
            {
                foreach (Mobile m in getOwners())
                    if (Manager.IsOnline((PlayerMobile)m))
                        m.SendMessage(String.Format("One or more members declined the team invite for the {0} tournament on {1} at {2}.", t.TeamSize, t.Date.ToString("MM/dd/yy"), t.Date.ToString("hh:mm tt")));
            }
        }
コード例 #14
0
ファイル: Manager.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Rewards the top 3 place winners by giving the specified item(s) and
        /// placing them in thier banks.Notifies the winners that thier winnings
        /// have been placed in thier bank.
        /// Loads the previous tournaments.xml file
        /// Saves the results to the tournaments.xml file
        /// Removes the spectator gates.
        /// Moves the winners so they may leave.
        /// Stops the tournament timer to officially end the tournament.
        /// </summary>
        /// <param name="first"> First place contestant</param>
        /// <param name="second"> Second place contestant</param>
        /// <param name="third"> Third place contestant</param>
        public static void TournamentReward(Tournament t, string place, Teams team)
        {
            BankBox bank;
            Item prize = (Item)Activator.CreateInstance(t.Prizes[place].GetType(), false);
            Dupe.CopyProperties(prize,t.Prizes[place]);

            foreach(Mobile m in team.getOwners())
            {
                bank = m.BankBox;
                bank.AddItem(prize);
                m.SendMessage("Your winnings have been sent to your bankbox.");
                if (place.Contains("first"))
                    World.Broadcast(0,false, m.Name+" has won the " + t.TeamSize + " tournament.");
            }
        }
コード例 #15
0
ファイル: AutoTimer.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Provides notifications of approaching events and starts them
        /// </summary>
        protected override void OnTick()
        {
            if (!m_EventsEnabled || AutoRestart.Restarting)
                Stop();

            // Checks the next scheduled tournament and gives out notifications for the tournament
            if (XMLDates.Events.ContainsKey("tournament"))
            {
                if (XMLDates.Events["tournament"].Count > 0 && ArenaControl.Arenas.Count > 0)
                {
                    t = (Tournament)XMLDates.Events["tournament"][0];
                    TimeSpan date = t.Date - DateTime.Now;
                    // Give 15 minute warning for the tournament
                    if (date.Days == 0 && date.Hours == 0 && date.Minutes == 15 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will commence in approximately 15 minutes.", t.TeamSize));
                        World.Broadcast(0, false, "If you have not registered, please do so at this time with [tournaments");
                    }
                    // Give 5 minute warning for the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 5 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will commence in approximately 5 minutes.", t.TeamSize));
                        World.Broadcast(0, false, "If you have registered, please make your way to a safe location.");
                    }
                    // Give 2 minute warning for the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 2 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("Two minute warning for the {0} tournament.", t.TeamSize));
                    }
                    // Begin the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 0 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will begin shortly.", t.TeamSize));
                        TournamentTimer timer = new TournamentTimer(t);
                        timer.Prepare();
                        XMLDates.RemoveTournament(t);
                    }
                }
            }
        }
コード例 #16
0
ファイル: BuildBracket.cs プロジェクト: greeduomacro/RunUO-1
        /// <summary>
        /// Gets the winners for the Single Elimination Bracket
        /// </summary>
        /// <param name="t"></param>
        public void SEGetWinners(Tournament t)
        {
            List<Match> Finals = Bracket[TotalRounds - 1];

            if (Finals.Count == 2)
            {
                if (t.Prizes.ContainsKey("third"))
                    Manager.TournamentReward(t, "third", Finals[0].Winner);
                if (t.Prizes.ContainsKey("second"))
                    Manager.TournamentReward(t, "second", Finals[1].Loser);
                if (t.Prizes.ContainsKey("first"))
                    Manager.TournamentReward(t, "first", Finals[1].Winner);
            }
            else if (Finals.Count == 1)// Fix for 3 Team Tournament
            {
                if (t.Prizes.ContainsKey("third"))
                    Manager.TournamentReward(t, "third", Bracket[TotalRounds-2][0].Loser);
                if (t.Prizes.ContainsKey("second"))
                    Manager.TournamentReward(t, "second", Finals[0].Loser);
                if (t.Prizes.ContainsKey("first"))
                    Manager.TournamentReward(t, "first", Finals[0].Winner);
            }
            else // Why were there only 2 Teams?? this was a bit overkill...
            {
                if (t.Prizes.ContainsKey("second"))
                    Manager.TournamentReward(t, "second", Finals[0].Loser);
                if (t.Prizes.ContainsKey("first"))
                    Manager.TournamentReward(t, "first", Finals[0].Winner);
            }
        }