Beispiel #1
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();
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }