Ejemplo n.º 1
0
        private static void HandleUpgradeBuff(GameSession session, PacketReader packet)
        {
            int buffId = packet.ReadInt();

            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null)
            {
                return;
            }

            GuildBuff buff = guild.Buffs.First(x => x.Id == buffId);

            // get next level's data
            GuildBuffLevel metadata = GuildBuffMetadataStorage.GetGuildBuffLevelData(buffId, buff.Level + 1);

            GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp);

            if (guildProperty.Level < metadata.LevelRequirement)
            {
                return;
            }

            if (guild.Funds < metadata.UpgradeCost)
            {
                return;
            }

            guild.ModifyFunds(session, guildProperty, -metadata.UpgradeCost);
            buff.Level++;
            guild.BroadcastPacketGuild(GuildPacket.UpgradeBuff(buffId, buff.Level, session.Player.Name));
        }
Ejemplo n.º 2
0
        public Guild(string name)
        {
            GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(0);

            Name       = name;
            Capacity   = (byte)property.Capacity;
            Exp        = 0;
            Funds      = 0;
            Emblem     = "";
            Notice     = "";
            Searchable = true;
            HouseRank  = 1;
            HouseTheme = 1;
            Ranks      = new GuildRank[6] {
                new GuildRank("Master", 4095),
                new GuildRank("Jr. Master"),
                new GuildRank("Member 1"),
                new GuildRank("Member 2"),
                new GuildRank("New Member 1"),
                new GuildRank("New Member 2")
            };
            CreationTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount;

            List <int> buffIds = GuildBuffMetadataStorage.GetBuffList();

            foreach (int buffId in buffIds)
            {
                Buffs.Add(new GuildBuff(buffId));
            }
            Id = DatabaseManager.CreateGuild(this);
        }
        public Guild(string name, Player leader)
        {
            GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(0);

            Name              = name;
            LeaderAccountId   = leader.AccountId;
            LeaderCharacterId = leader.CharacterId;
            LeaderName        = leader.Name;
            Capacity          = (byte)property.Capacity;
            Exp        = 0;
            Funds      = 0;
            Emblem     = "";
            Notice     = "";
            Searchable = true;
            HouseRank  = 1;
            HouseTheme = 1;
            Ranks      = new GuildRank[6] {
                new GuildRank("Master", 4095),
                new GuildRank("Jr. Master"),
                new GuildRank("Member 1"),
                new GuildRank("Member 2"),
                new GuildRank("New Member 1"),
                new GuildRank("New Member 2")
            };
            CreationTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount;

            List <int> buffIds = GuildBuffMetadataStorage.GetBuffList();

            foreach (int buffId in buffIds)
            {
                Buffs.Add(new GuildBuff(buffId));
            }
            Id = DatabaseManager.Guilds.Insert(this);

            GuildMember guildMemberLeader = new GuildMember(leader, 0, Id);

            Members.Add(guildMemberLeader);

            leader.Guild       = this;
            leader.GuildMember = guildMemberLeader;
            DatabaseManager.Characters.Update(leader);
        }
Ejemplo n.º 4
0
        private static void HandleUseBuff(GameSession session, PacketReader packet)
        {
            int buffId = packet.ReadInt();

            Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id);

            if (guild == null)
            {
                return;
            }

            int buffLevel = guild.Buffs.FirstOrDefault(x => x.Id == buffId).Level;

            GuildBuffLevel buff = GuildBuffMetadataStorage.GetGuildBuffLevelData(buffId, buffLevel);

            if (buff == null)
            {
                return;
            }

            if (buffId > 1000)
            {
                if (!session.Player.Wallet.Meso.Modify(-buff.Cost))
                {
                    return;
                }
            }
            else
            {
                if (buff.Cost > guild.Funds)
                {
                    return;
                }
                guild.Funds -= buff.Cost;
            }
            session.Send(GuildPacket.ActivateBuff(buffId));
            session.Send(GuildPacket.UseBuffNotice(buffId));
        }