Beispiel #1
0
        public void BuyTab(Character chr, GameObject bank, byte tabId)
        {
            if (!GuildBank.CheckBankObj(chr, bank))
            {
                return;
            }
            GuildMember guildMember = chr.GuildMember;

            if (guildMember == null)
            {
                return;
            }
            GuildRank rank = guildMember.Rank;

            if (rank == null || !guildMember.IsLeader || (tabId >= (byte)6 || this.Guild.PurchasedBankTabCount >= 6) ||
                (int)tabId != this.Guild.PurchasedBankTabCount)
            {
                return;
            }
            int bankTabPrice = GuildBank.BankTabPrices[(int)tabId];

            if ((long)chr.Money < (long)bankTabPrice || !this.AddNewBankTab((int)tabId))
            {
                return;
            }
            rank.BankTabRights[(int)tabId].Privileges         = GuildBankTabPrivileges.Full;
            rank.BankTabRights[(int)tabId].WithdrawlAllowance = uint.MaxValue;
            GuildHandler.SendGuildRosterToGuildMembers(this.Guild);
            GuildHandler.SendGuildBankTabNames(chr, bank);
        }
Beispiel #2
0
        public void SetBankTabText(Character chr, byte tabId, string newText)
        {
            GuildMember guildMember = chr.GuildMember;

            if (guildMember == null)
            {
                return;
            }
            GuildRank rank = guildMember.Rank;

            if (rank == null || tabId < (byte)0 ||
                (tabId >= (byte)6 || (int)tabId > this.Guild.PurchasedBankTabCount))
            {
                return;
            }
            GuildBankTab record = this[(int)tabId];

            if (record == null || !rank.BankTabRights[(int)tabId].Privileges
                .HasFlag((Enum)GuildBankTabPrivileges.UpdateText))
            {
                return;
            }
            record.Text = newText.Length < 501 ? newText : newText.Substring(0, 500);
            record.UpdateLater();
            this.Guild.Broadcast(GuildHandler.CreateBankTabTextPacket(tabId, newText));
        }
Beispiel #3
0
        /// <summary>Adds rank to the tail of ranks list</summary>
        /// <param name="name">name of new rank</param>
        /// <param name="privileges">privileges of new rank</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>new rank</returns>
        public GuildRank AddRank(string name, GuildPrivileges privileges, bool update)
        {
            GuildRank guildRank;

            lock (this)
            {
                foreach (GuildRank rank in this.m_ranks)
                {
                    if (rank.Name == name)
                    {
                        return((GuildRank)null);
                    }
                }

                if (this.m_ranks.Count >= 10)
                {
                    return((GuildRank)null);
                }
                guildRank = new GuildRank(this, name, privileges, this.m_ranks.Count);
                this.m_ranks.Add(guildRank);
            }

            guildRank.SaveLater();
            if (update)
            {
                GuildHandler.SendGuildQueryToGuildMembers(this);
                GuildHandler.SendGuildRosterToGuildMembers(this);
            }

            return(guildRank);
        }
Beispiel #4
0
        /// <summary>
        /// Adds rank to the tail of ranks list
        /// </summary>
        /// <param name="name">name of new rank</param>
        /// <param name="privileges">privileges of new rank</param>
        /// <param name="update">if true, sends event to the guild</param>
        /// <returns>new rank</returns>
        public GuildRank AddRank(string name, GuildPrivileges privileges, bool update)
        {
            GuildRank rank;

            //using (syncRoot.Enter())
            lock (this)
            {
                foreach (var gRank in m_ranks)
                {
                    if (gRank.Name == name)
                    {
                        return(null);
                    }
                }

                if (m_ranks.Count >= GuildMgr.MAX_GUILD_RANKS)
                {
                    return(null);
                }

                rank = new GuildRank(this, name, privileges, m_ranks.Count);
                m_ranks.Add(rank);
            }


            rank.SaveLater();
            if (update)
            {
                GuildHandler.SendGuildQueryToGuildMembers(this);
                GuildHandler.SendGuildRosterToGuildMembers(this);
            }

            return(rank);
        }
Beispiel #5
0
        public static ImmutableList <GuildRank> CreateDefaultRanks(Guild guild)
        {
            var ranks    = new ImmutableList <GuildRank>();
            var ranksNum = 0;
            var gmRank   = new GuildRank(guild, "Guild Master", GuildPrivileges.All, ranksNum++);

            ranks.Add(gmRank);
            ranks.Add(new GuildRank(guild, "Officer", GuildPrivileges.Applicants, ranksNum++));
            ranks.Add(new GuildRank(guild, "Veteran", GuildPrivileges.Default, ranksNum++));
            ranks.Add(new GuildRank(guild, "Member", GuildPrivileges.Default, ranksNum++));
            ranks.Add(new GuildRank(guild, "Initiate", GuildPrivileges.Default, ranksNum));
            return(ranks);
        }
Beispiel #6
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 #7
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 #8
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 #9
0
        public GuildMember(CharacterRecord chr, Guild guild, GuildRank rank)
            : this()
        {
            var zoneId = (int)chr.Zone;

            Guild = guild;

            CharacterLowId = (int)chr.EntityLowId;
            _rankId        = rank.RankIndex;
            _name          = chr.Name;
            _lastLevel     = chr.Level;
            _lastLogin     = DateTime.Now;
            _lastZoneId    = zoneId;
            _class         = (int)chr.Class;
            _publicNote    = string.Empty;
            _officerNote   = string.Empty;
        }
Beispiel #10
0
		public GuildMember(CharacterRecord chr, Guild guild, GuildRank rank)
			: this()
		{
			var zoneId = (int)chr.Zone;

			Guild = guild;

			CharacterLowId = (int)chr.EntityLowId;
			_rankId = rank.RankIndex;
			_name = chr.Name;
			_lastLevel = chr.Level;
			_lastLogin = DateTime.Now;
			_lastZoneId = zoneId;
			_class = (int)chr.Class;
			_publicNote = string.Empty;
			_officerNote = string.Empty;
		}
Beispiel #11
0
        public GuildMember(CharacterRecord chr, Guild guild, GuildRank rank)
            : this()
        {
            int zone = (int)chr.Zone;

            this.Guild            = guild;
            this.CharacterLowId   = (long)(int)chr.EntityLowId;
            this._rankId          = rank.RankIndex;
            this._name            = chr.Name;
            this._lastLevel       = chr.Level;
            this._lastLogin       = DateTime.Now;
            this._lastZoneId      = zone;
            this._class           = (int)chr.Class;
            this._publicNote      = string.Empty;
            this._officerNote     = string.Empty;
            this.AccId            = chr.AccountId;
            this.ProffessionLevel = chr.ProfessionLevel;
            this.CharNum          = chr.CharNum;
        }
Beispiel #12
0
        public static ImmutableList <GuildRank> CreateDefaultRanks(Guild guild)
        {
            ImmutableList <GuildRank> immutableList1 = new ImmutableList <GuildRank>();
            int       num1       = 0;
            Guild     guild1     = guild;
            string    name1      = "Guild Master";
            int       maxValue   = sbyte.MaxValue;
            int       id1        = num1;
            int       num2       = id1 + 1;
            GuildRank guildRank1 = new GuildRank(guild1, name1, (GuildPrivileges)maxValue, id1);

            immutableList1.Add(guildRank1);
            ImmutableList <GuildRank> immutableList2 = immutableList1;
            Guild     guild2     = guild;
            string    name2      = "Officer";
            int       num3       = 2;
            int       id2        = num2;
            int       num4       = id2 + 1;
            GuildRank guildRank2 = new GuildRank(guild2, name2, (GuildPrivileges)num3, id2);

            immutableList2.Add(guildRank2);
            ImmutableList <GuildRank> immutableList3 = immutableList1;
            Guild     guild3     = guild;
            string    name3      = "Veteran";
            int       num5       = 0;
            int       id3        = num4;
            int       num6       = id3 + 1;
            GuildRank guildRank3 = new GuildRank(guild3, name3, (GuildPrivileges)num5, id3);

            immutableList3.Add(guildRank3);
            ImmutableList <GuildRank> immutableList4 = immutableList1;
            Guild     guild4     = guild;
            string    name4      = "Member";
            int       num7       = 0;
            int       id4        = num6;
            int       id5        = id4 + 1;
            GuildRank guildRank4 = new GuildRank(guild4, name4, (GuildPrivileges)num7, id4);

            immutableList4.Add(guildRank4);
            immutableList1.Add(new GuildRank(guild, "Initiate", GuildPrivileges.None, id5));
            return(immutableList1);
        }
Beispiel #13
0
        public void SwapItemsManualBankToBank(Character chr, GameObject bankObj, byte fromBankTabId, byte fromTabSlot,
                                              byte toBankTabId, byte toTabSlot, uint itemEntryId, byte amount)
        {
            if (!GuildBank.CheckBankObj(chr, bankObj))
            {
                return;
            }
            GuildMember guildMember = chr.GuildMember;

            if (guildMember == null)
            {
                return;
            }
            GuildRank rank = guildMember.Rank;

            if (rank == null)
            {
                return;
            }
            GuildBankTab intoTab1 = this[(int)fromBankTabId];

            if (intoTab1 == null)
            {
                return;
            }
            GuildBankTab intoTab2 = this[(int)toBankTabId];

            if (intoTab2 == null || fromTabSlot >= (byte)98 || toTabSlot >= (byte)98)
            {
                return;
            }
            GuildBankTabRights[] bankTabRights = rank.BankTabRights;
            if (!bankTabRights[(int)fromBankTabId].Privileges.HasFlag((Enum)GuildBankTabPrivileges.ViewTab) ||
                bankTabRights[(int)fromBankTabId].WithdrawlAllowance <= 0U || !bankTabRights[(int)toBankTabId]
                .Privileges.HasFlag((Enum)GuildBankTabPrivileges.DepositItem))
            {
                return;
            }
            ItemRecord itemRecord1 = intoTab1[(int)fromTabSlot];

            if (itemRecord1 == null || (int)itemRecord1.EntryId != (int)itemEntryId ||
                itemRecord1.Amount < (int)amount)
            {
                return;
            }
            if (amount == (byte)0)
            {
                amount = (byte)itemRecord1.Amount;
            }
            bool flag = (int)fromBankTabId == (int)toBankTabId;

            if (flag)
            {
                if ((int)fromTabSlot == (int)toTabSlot)
                {
                    return;
                }
                ItemRecord itemRecord2 = intoTab2.StoreItemInSlot(itemRecord1, (int)amount, (int)toTabSlot, true);
                intoTab1[(int)fromTabSlot] = itemRecord2;
            }
            else
            {
                if (intoTab2.CheckStoreItemInSlot(itemRecord1, (int)amount, (int)toTabSlot, true))
                {
                    ItemRecord itemRecord2 = intoTab2.StoreItemInSlot(itemRecord1, (int)amount, (int)toTabSlot, true);
                    intoTab1[(int)fromTabSlot] = itemRecord2;
                }
                else
                {
                    if (!bankTabRights[(int)fromBankTabId].Privileges
                        .HasFlag((Enum)GuildBankTabPrivileges.DepositItem) ||
                        bankTabRights[(int)toBankTabId].WithdrawlAllowance <= 0U)
                    {
                        return;
                    }
                    ItemRecord itemRecord2 = intoTab2.StoreItemInSlot(itemRecord1, (int)amount, (int)toTabSlot, true);
                    intoTab1[(int)fromTabSlot] = itemRecord2;
                    if (itemRecord2 != itemRecord1)
                    {
                        --bankTabRights[(int)toTabSlot].WithdrawlAllowance;
                        --bankTabRights[(int)fromBankTabId].WithdrawlAllowance;
                        this.BankLog.LogEvent(GuildBankLogEntryType.MoveItem, chr, itemRecord1, (int)amount, intoTab2);
                        this.BankLog.LogEvent(GuildBankLogEntryType.MoveItem, chr, itemRecord2, intoTab1);
                        this.Guild.SendGuildBankTabContentUpdateToAll(fromBankTabId, (int)fromTabSlot);
                        this.Guild.SendGuildBankTabContentUpdateToAll(toBankTabId, (int)toTabSlot);
                        return;
                    }
                }

                --bankTabRights[(int)fromBankTabId].WithdrawlAllowance;
            }

            this.BankLog.LogEvent(GuildBankLogEntryType.MoveItem, chr, itemRecord1, (int)amount, intoTab2);
            this.Guild.SendGuildBankTabContentUpdateToAll(fromBankTabId, (int)fromTabSlot,
                                                          flag ? (int)toTabSlot : -1);
        }