Exemple #1
0
        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));
        }