Beispiel #1
0
        /// <summary>
        /// Creates a new GuildRecord 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="Guild"/> object</returns>
        public Guild(CharacterRecord leader, string name)
            : this(true)
        {
            _created     = DateTime.Now;
            _id          = _idGenerator.Next();
            _leaderLowId = (int)leader.EntityLowId;
            _name        = name;
            _tabard      = new GuildTabard();
            _MOTD        = "Default MOTD";
            _info        = "Default info";
            _level       = 1;
            m_ranks      = GuildMgr.CreateDefaultRanks(this);
            foreach (var guildRank in m_ranks)
            {
                guildRank.CreateLater();
            }
            //m_leader = new GuildMember(leader, this, HighestRank);

            Register();

            m_leader = AddMember(leader);
            var chr = World.GetCharacter(leader.Name, true);
            Leader.Character = chr;

            //Set the leader as guild master rank
            m_leader.RankId = 0;
            _clanCrest      = new byte[40];
            this.CreateLater();                                         // save to DB, asynchronously
        }
Beispiel #2
0
        /// <summary>
        /// Initialize the Guild after loading from DB
        /// </summary>
        internal void InitAfterLoad()
        {
            var ranks = GuildRank.FindAll(this);

            if (ranks.Length == 0)
            {
                log.Warn(string.Format("Guild {0} did not have ranks - Recreating default Ranks.", this));
                m_ranks = GuildMgr.CreateDefaultRanks(this);
            }
            else
            {
                m_ranks = new ImmutableList <GuildRank>(ranks.OrderBy(rank => rank.RankIndex));
            }

            foreach (var rank in m_ranks)
            {
                rank.InitRank();
            }

            var members = GuildMember.FindAll(Id);

            foreach (var gm in members)
            {
                gm.Init(this, World.GetCharacter((uint)gm.CharacterLowId));
                Members.Add(gm.Id, gm);
            }

            var skills = GuildSkill.FindAll(this);

            foreach (var guildSkill in skills)
            {
                guildSkill.InitAfterLoad(this);
                if (Skills[(int)guildSkill.Id] == null)
                {
                    Skills[(int)guildSkill.Id] = guildSkill;
                }
                else
                {
                    guildSkill.DeleteLater();
                }
            }
            m_leader = this[LeaderLowId];
            if (m_leader == null)
            {
                OnNoLeaderFound();
            }
            if (m_leader != null)
            {
                Register();
            }
        }
Beispiel #3
0
        /// <summary>Initialize the Guild after loading from DB</summary>
        internal void InitAfterLoad()
        {
            GuildRank[] all = GuildRank.FindAll(this);
            if (all.Length == 0)
            {
                Guild.log.Warn(string.Format("Guild {0} did not have ranks - Recreating default Ranks.",
                                             (object)this));
                this.m_ranks = GuildMgr.CreateDefaultRanks(this);
            }
            else
            {
                this.m_ranks = new ImmutableList <GuildRank>(
                    (IEnumerable <GuildRank>)((IEnumerable <GuildRank>)all).OrderBy <GuildRank, int>(
                        (Func <GuildRank, int>)(rank => rank.RankIndex)));
            }

            foreach (GuildRank rank in this.m_ranks)
            {
                rank.InitRank();
            }
            foreach (GuildMember guildMember in GuildMember.FindAll(this.Id))
            {
                guildMember.Init(this, World.GetCharacter((uint)guildMember.CharacterLowId));
                this.Members.Add(guildMember.Id, guildMember);
            }

            foreach (GuildSkill record in GuildSkill.FindAll(this))
            {
                record.InitAfterLoad(this);
                if (this.Skills[(int)record.Id] == null)
                {
                    this.Skills[(int)record.Id] = record;
                }
                else
                {
                    record.DeleteLater();
                }
            }

            this.m_leader = this[this.LeaderLowId];
            if (this.m_leader == null)
            {
                this.OnNoLeaderFound();
            }
            if (this.m_leader == null)
            {
                return;
            }
            this.Register();
        }
Beispiel #4
0
        /// <summary>Initialize the Guild after loading from DB</summary>
        internal void InitAfterLoad()
        {
            GuildRank[] all = GuildRank.FindAll(this);
            if (all.Length == 0)
            {
                log.Warn(string.Format("Guild {0} did not have ranks - Recreating default Ranks.",
                                       this));
                m_ranks = GuildMgr.CreateDefaultRanks(this);
            }
            else
            {
                m_ranks = new ImmutableList <GuildRank>(
                    all.OrderBy(
                        rank => rank.RankIndex));
            }

            foreach (GuildRank rank in m_ranks)
            {
                rank.InitRank();
            }
            foreach (GuildMember guildMember in GuildMember.FindAll(Id))
            {
                guildMember.Init(this, World.GetCharacter((uint)guildMember.CharacterLowId));
                Members.Add(guildMember.Id, guildMember);
            }

            foreach (GuildSkill record in GuildSkill.FindAll(this))
            {
                record.InitAfterLoad(this);
                if (Skills[(int)record.Id] == null)
                {
                    Skills[(int)record.Id] = record;
                }
                else
                {
                    record.DeleteLater();
                }
            }

            m_leader = this[LeaderLowId];
            if (m_leader == null)
            {
                OnNoLeaderFound();
            }
            if (m_leader == null)
            {
                return;
            }
            Register();
        }
Beispiel #5
0
 /// <summary>
 /// Creates a new GuildRecord 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.Guilds.Guild" /> object</returns>
 public Guild(CharacterRecord leader, string name)
     : this(true)
 {
     this._created     = DateTime.Now;
     this._id          = Guild._idGenerator.Next();
     this._leaderLowId = (int)leader.EntityLowId;
     this._name        = name;
     this._tabard      = new GuildTabard();
     this._MOTD        = "Default MOTD";
     this._info        = "Default info";
     this._level       = (byte)1;
     this.m_ranks      = GuildMgr.CreateDefaultRanks(this);
     foreach (ActiveRecordBase rank in this.m_ranks)
     {
         rank.CreateLater();
     }
     this.Register();
     this.m_leader         = this.AddMember(leader);
     this.Leader.Character = World.GetCharacter(leader.Name, true);
     this.m_leader.RankId  = 0;
     this._clanCrest       = new byte[40];
     this.CreateLater();
 }
Beispiel #6
0
        /// <summary>
        /// Creates a new GuildRecord 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="Guild"/> object</returns>
        public Guild(CharacterRecord leader, string name)
            : this(true)
        {
            _created     = DateTime.Now;
            _id          = _idGenerator.Next();
            _leaderLowId = (int)leader.EntityLowId;
            _name        = name;
            _tabard      = new GuildTabard();
            _MOTD        = "Default MOTD";
            _info        = "Default info";

            m_ranks = GuildMgr.CreateDefaultRanks(this);
            //m_leader = new GuildMember(leader, this, HighestRank);

            Register();

            m_leader = AddMember(leader);

            //Set the leader as guild master rank
            m_leader.RankId = 0;

            this.CreateLater();                                                         // save to DB, asynchronously
        }