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)); }
private static void HandleChangeHomeTheme(GameSession session, PacketReader packet) { int themeId = packet.ReadInt(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null || guild.LeaderCharacterId != session.Player.CharacterId) { return; } GuildHouseMetadata houseMetadata = GuildHouseMetadataStorage.GetMetadataByThemeId(guild.HouseRank, themeId); if (houseMetadata == null) { return; } GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); if (guild.Funds < houseMetadata.UpgradeCost) { return; } guild.ModifyFunds(session, guildProperty, -houseMetadata.RethemeCost); guild.HouseTheme = houseMetadata.Theme; guild.BroadcastPacketGuild(GuildPacket.ChangeHouse(session.Player.Name, guild.HouseRank, guild.HouseTheme)); }
private static void HandleCheckIn(GameSession session) { Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildMember member = guild.Members.First(x => x.Player == session.Player); // Check if attendance timestamp is today DateTimeOffset date = DateTimeOffset.FromUnixTimeSeconds(member.AttendanceTimestamp); if (date == DateTime.Today) { return; } int contributionAmount = GuildContributionMetadataStorage.GetContributionAmount("attend"); GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); member.AddContribution(contributionAmount); member.AttendanceTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount; session.Send(GuildPacket.CheckInBegin()); Item guildCoins = new Item(30000861) { Amount = property.AttendGuildCoin }; InventoryController.Add(session, guildCoins, true); guild.AddExp(session, property.AttendExp); guild.ModifyFunds(session, property, property.AttendFunds); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, contributionAmount)); session.Send(GuildPacket.FinishCheckIn(member)); }
private static void HandleUpgradeHome(GameSession session, PacketReader packet) { int themeId = packet.ReadInt(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null || guild.Leader != session.Player) { return; } GuildHouseMetadata houseMetadata = GuildHouseMetadataStorage.GetMetadataByThemeId(guild.HouseRank + 1, themeId); if (houseMetadata == null) { return; } GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); if (guildProperty.Level < houseMetadata.RequiredLevel || guild.Funds < houseMetadata.UpgradeCost) { return; } guild.ModifyFunds(session, guildProperty, -houseMetadata.UpgradeCost); guild.HouseRank = houseMetadata.Level; guild.HouseTheme = houseMetadata.Theme; guild.BroadcastPacketGuild(GuildPacket.ChangeHouse(session.Player.Name, guild.HouseRank, guild.HouseTheme)); // need to confirm if this is the packet used when upgrading }
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); }
private static void HandleGuildDonate(GameSession session, PacketReader packet) { int donateQuantity = packet.ReadInt(); int donationAmount = donateQuantity * 10000; Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildPropertyMetadata guildProperty = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); GuildMember member = guild.Members.First(x => x.Player == session.Player); if (member.DailyDonationCount >= guildProperty.DonationMax) { return; } if (!session.Player.Wallet.Meso.Modify(-donationAmount)) { session.Send(GuildPacket.ErrorNotice((byte)GuildErrorNotice.NotEnoughMesos)); return; } Item coins = new(30000861) { Rarity = 4, Amount = guildProperty.DonateGuildCoin * donateQuantity }; session.Player.Inventory.AddItem(session, coins, true); int contribution = GuildContributionMetadataStorage.GetContributionAmount("donation"); member.DailyDonationCount += (byte)donateQuantity; member.AddContribution(contribution * donateQuantity); guild.ModifyFunds(session, guildProperty, donationAmount); session.Send(GuildPacket.UpdatePlayerDonation()); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, donateQuantity)); }
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); }
public override void Execute(GameCommandTrigger trigger) { Guild guild = GameServer.GuildManager.GetGuildById(trigger.Session.Player.Guild.Id); if (guild == null) { trigger.Session.SendNotice("Player is not in a guild to add exp. Make sure you join one."); return; } int guildExp = trigger.Get <int>("exp"); if (guildExp <= 0) { trigger.Session.SendNotice("Amount must be more than 0 to add."); return; } guild.Exp = guildExp; guild.BroadcastPacketGuild(GuildPacket.UpdateGuildExp(guild.Exp)); GuildPropertyMetadata data = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); DatabaseManager.Guilds.Update(guild); }
private static void HandleServices(GameSession session, PacketReader packet) { int serviceId = packet.ReadInt(); Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } int currentLevel = 0; GuildService service = guild.Services.FirstOrDefault(x => x.Id == serviceId); if (service != null) { service.Level = currentLevel; } GuildServiceMetadata serviceMetadata = GuildServiceMetadataStorage.GetMetadata(serviceId, currentLevel); if (serviceMetadata == null) { return; } GuildPropertyMetadata propertyMetadata = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); if (guild.HouseRank < serviceMetadata.HouseLevelRequirement || propertyMetadata.Level < serviceMetadata.LevelRequirement || guild.Funds < serviceMetadata.UpgradeCost) { return; } guild.ModifyFunds(session, propertyMetadata, -serviceMetadata.UpgradeCost); guild.BroadcastPacketGuild(GuildPacket.UpgradeService(session.Player, serviceId, serviceMetadata.Level)); }