Exemplo n.º 1
0
 public static bool CanUseName(string name)
 {
     if (ArenaMgr.IsValidArenaTeamName(name))
     {
         return(ArenaMgr.GetArenaTeam(name) == null);
     }
     return(false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new ArenaTeamRecord row in the database with the given information.
        /// </summary>
        /// <param name="leader">leader's character record</param>
        /// <param name="name">the name of the new character</param>
        /// <returns>the <seealso cref="T:WCell.RealmServer.Battlegrounds.Arenas.ArenaTeam" /> object</returns>
        public ArenaTeam(CharacterRecord leader, string name, uint type)
            : this()
        {
            this._id          = ArenaTeam._idGenerator.Next();
            this._leaderLowId = (int)leader.EntityLowId;
            this._name        = name;
            this._type        = (int)type;
            this.m_slot       = ArenaMgr.GetSlotByType(type);
            this.m_leader     = new ArenaTeamMember(leader, this, true);
            this.m_stats      = new ArenaTeamStats(this);
            this.Members.Add(this.m_leader.Id, this.m_leader);
            this.m_leader.Create();
            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage(new Action(((ActiveRecordBase)this).Create));

            this.Register();
        }
Exemplo n.º 3
0
 /// <summary>Disbands the arena team</summary>
 /// <param name="update">if true, sends event to the team</param>
 public void Disband()
 {
     this.m_syncRoot.Enter();
     try
     {
         foreach (ArenaTeamMember member in this.Members.Values.ToArray <ArenaTeamMember>())
         {
             this.RemoveMember(member, false);
         }
         ArenaMgr.UnregisterArenaTeam(this);
         ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => this.Delete()));
     }
     finally
     {
         this.m_syncRoot.Exit();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Called before the given member is removed to clean up everything related to the given member
        /// </summary>
        protected void OnRemoveMember(ArenaTeamMember member)
        {
            ArenaMgr.UnregisterArenaTeamMember(member);
            Character character = member.Character;

            if (character == null)
            {
                return;
            }
            character.ArenaTeamMember[(int)this.Slot] = (ArenaTeamMember)null;
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_ID, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_TYPE, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_MEMBER, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_GAMES_WEEK, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_GAMES_SEASON, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_WINS_SEASON, 0U);
            character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_PERSONAL_RATING, 0U);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called before the given member is removed to clean up everything related to the given member
        /// </summary>
        protected void OnRemoveMember(ArenaTeamMember member)
        {
            ArenaMgr.UnregisterArenaTeamMember(member);

            var chr = member.Character;

            if (chr != null)
            {
                chr.ArenaTeamMember[(int)Slot] = null;
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_ID, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_TYPE, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_MEMBER, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_GAMES_WEEK, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_GAMES_SEASON, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_WINS_SEASON, 0);
                chr.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_PERSONAL_RATING, 0);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new ArenaTeamRecord row in the database with the given information.
        /// </summary>
        /// <param name="leader">leader's character record</param>
        /// <param name="name">the name of the new character</param>
        /// <returns>the <seealso cref="ArenaTeam"/> object</returns>
        public ArenaTeam(CharacterRecord leader, string name, uint type)
            : this()
        {
            _id          = _idGenerator.Next();
            _leaderLowId = (int)leader.EntityLowId;
            _name        = name;
            _type        = (int)type;

            m_slot = ArenaMgr.GetSlotByType(type);

            m_leader = new ArenaTeamMember(leader, this, true);
            m_stats  = new ArenaTeamStats(this);

            Members.Add(m_leader.Id, m_leader);
            m_leader.Create();

            RealmServer.IOQueue.AddMessage(Create);
            Register();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds a new arena team member
        /// Calls ArenaTeamMgr.OnJoinTeam
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <returns>ArenaTeamMember of new member</returns>
        public ArenaTeamMember AddMember(CharacterRecord chr)
        {
            ArenaTeamMember newMember;

            if (Members.Count >= Type * 2)
            {
                return(null);
            }

            SyncRoot.Enter();
            try
            {
                if (Members.TryGetValue(chr.EntityLowId, out newMember))
                {
                    return(newMember);
                }
                newMember = new ArenaTeamMember(chr, this, false);
                newMember.Character.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_ID, Id);
                newMember.Character.SetArenaTeamInfoField(Slot, ArenaTeamInfoType.ARENA_TEAM_MEMBER, 1);

                Members.Add(newMember.Id, newMember);

                newMember.Create();
                Update();
            }
            catch (Exception e)
            {
                LogUtil.ErrorException(e, string.Format("Could not add member {0} to arena team {1}", chr, this));
                return(null);
            }
            finally
            {
                SyncRoot.Exit();
            }

            ArenaMgr.RegisterArenaTeamMember(newMember);

            //ArenaTeamHandler.SendEventToTeam(this, ArenaTeamEvents.JOINED_SS, newMember);

            return(newMember);
        }
Exemplo n.º 8
0
        internal void InitAfterLoad()
        {
            foreach (ArenaTeamMember arenaTeamMember in ArenaTeamMember.FindAll(this))
            {
                arenaTeamMember.Init(this);
                this.Members.Add(arenaTeamMember.Id, arenaTeamMember);
            }

            this.m_stats = ActiveRecordBase <ArenaTeamStats> .FindByPrimaryKey((object)this.Id);

            this.m_slot   = ArenaMgr.GetSlotByType(this.Type);
            this.m_leader = this[this.LeaderLowId];
            if (this.m_leader == null)
            {
                this.OnLeaderDeleted();
            }
            if (this.m_leader == null)
            {
                return;
            }
            this.Register();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Disbands the arena team
        /// </summary>
        /// <param name="update">if true, sends event to the team</param>
        public void Disband()
        {
            m_syncRoot.Enter();
            try
            {
                //ArenaTeamHandler.SendEventToTeam(this, ArenaTeamEvents.DISBANDED_S);

                var members = Members.Values.ToArray();

                foreach (var member in members)
                {
                    RemoveMember(member, false);
                }

                ArenaMgr.UnregisterArenaTeam(this);
                RealmServer.IOQueue.AddMessage(() => Delete());
            }
            finally
            {
                m_syncRoot.Exit();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Load & initialize the Team
        /// </summary>
        internal void InitAfterLoad()
        {
            var members = ArenaTeamMember.FindAll(this);

            foreach (var atm in members)
            {
                atm.Init(this);
                Members.Add(atm.Id, atm);
            }
            m_stats = ArenaTeamStats.FindByPrimaryKey(this.Id);
            m_slot  = ArenaMgr.GetSlotByType(Type);

            m_leader = this[LeaderLowId];
            if (m_leader == null)
            {
                OnLeaderDeleted();
            }
            if (m_leader != null)
            {
                Register();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds a new arena team member
        /// Calls ArenaTeamMgr.OnJoinTeam
        /// </summary>
        /// <param name="chr">character to add</param>
        /// <returns>ArenaTeamMember of new member</returns>
        public ArenaTeamMember AddMember(CharacterRecord chr)
        {
            if ((long)this.Members.Count >= (long)(this.Type * 2U))
            {
                return((ArenaTeamMember)null);
            }
            this.SyncRoot.Enter();
            ArenaTeamMember atm;

            try
            {
                if (this.Members.TryGetValue(chr.EntityLowId, out atm))
                {
                    return(atm);
                }
                atm = new ArenaTeamMember(chr, this, false);
                atm.Character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_ID, this.Id);
                atm.Character.SetArenaTeamInfoField(this.Slot, ArenaTeamInfoType.ARENA_TEAM_MEMBER, 1U);
                this.Members.Add(atm.Id, atm);
                atm.Create();
                this.Update();
            }
            catch (Exception ex)
            {
                LogUtil.ErrorException(ex,
                                       string.Format("Could not add member {0} to arena team {1}", (object)chr, (object)this),
                                       new object[0]);
                return((ArenaTeamMember)null);
            }
            finally
            {
                this.SyncRoot.Exit();
            }

            ArenaMgr.RegisterArenaTeamMember(atm);
            return(atm);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes arena team after its creation or restoration from DB
 /// </summary>
 internal void Register()
 {
     ArenaMgr.RegisterArenaTeam(this);
 }
Exemplo n.º 13
0
 public static void Initialize()
 {
     ArenaMgr.LoadFromDB();
 }
Exemplo n.º 14
0
 public static bool DoesArenaTeamExist(string name)
 {
     return(ArenaMgr.GetArenaTeam(name) != null);
 }