コード例 #1
0
    private static void HandleReward(GameSession session, PacketReader packet)
    {
        int rank = packet.ReadInt();

        if (session.Player.PrestigeRewardsClaimed.Contains(rank))
        {
            return;
        }

        // Get reward data
        PrestigeReward reward = PrestigeMetadataStorage.GetReward(rank);

        if (reward.Type.Equals("item"))
        {
            Item item = new(reward.Id)
            {
                CreationTime = TimeInfo.Now(),
                Rarity       = 4
            };

            session.Player.Inventory.AddItem(session, item, true);
        }
        else if (reward.Type.Equals("statPoint"))
        {
            session.Player.StatPointDistribution.AddTotalStatPoints(reward.Value);
        }

        session.Send(PrestigePacket.Reward(rank));
        session.Player.PrestigeRewardsClaimed.Add(rank);
    }
コード例 #2
0
    public static void BlackMarketCancellation(BlackMarketListing listing)
    {
        long deposit = 0;

        if (TimeInfo.Now() > listing.ExpiryTimestamp)
        {
            deposit = listing.Deposit;
        }

        string senderName    = "<ms2><v key=\"s_blackmarket_mail_to_sender\" /></ms2>";
        string title         = "<ms2><v key=\"s_blackmarket_mail_to_cancel_title\" /></ms2>";
        string body          = "<ms2><v key=\"s_blackmarket_mail_to_cancel_content\" /></ms2>";
        string addParameter1 = $"<ms2><v item=\"{listing.Item.Id}\" ></v></ms2>";
        string addParameter2 = "<ms2>" +
                               "<v key=\"s_blackmarket_mail_to_cancel_direct\" ></v>" +
                               $"<v item=\"{listing.Item.Id}\" ></v>" +
                               $"<v str=\"{listing.ListedQuantity}\" ></v>" +
                               $"<v money=\"{listing.Price * listing.ListedQuantity}\" ></v>" +
                               $"<v money=\"{listing.Price}\" ></v>" +
                               $"<v money=\"{deposit}\" ></v>" +
                               "</ms2>";

        Mail mail = new(MailType.BlackMarketListingCancel, listing.OwnerCharacterId, 0, senderName, title, body, addParameter1, addParameter2, new()
        {
            listing.Item
        }, deposit, 0);

        GameServer.MailManager.AddMail(mail);
        SendNotification(mail);
    }
コード例 #3
0
ファイル: Club.cs プロジェクト: Etchavious/MapleServer2
 public void SetName(string newName)
 {
     Name = newName;
     LastNameChangeTimestamp = TimeInfo.Now();
     DatabaseManager.Clubs.Update(this);
     BroadcastPacketClub(ClubPacket.Rename(this));
 }
コード例 #4
0
    private static void HandleChatEmoticonAdd(GameSession session, Item item)
    {
        long expiration = long.MaxValue;

        if (item.Function.ChatEmoticonAdd.Duration > 0)
        {
            expiration = item.Function.ChatEmoticonAdd.Duration + TimeInfo.Now();
        }

        // sticker exists and no expiration
        if (session.Player.ChatSticker.Any(p => p.GroupId == item.Function.ChatEmoticonAdd.Id && p.Expiration == long.MaxValue))
        {
            return;
        }

        // Add time if the sticker is already in the list
        ChatSticker sticker = session.Player.ChatSticker.FirstOrDefault(p => p.GroupId == item.Function.ChatEmoticonAdd.Id);

        if (sticker is not null && sticker.Expiration != long.MaxValue)
        {
            expiration += sticker.Expiration - TimeInfo.Now();
        }

        session.Send(ChatStickerPacket.AddSticker(item.Id, item.Function.ChatEmoticonAdd.Id, expiration));
        session.Player.ChatSticker.Add(new((byte)item.Function.ChatEmoticonAdd.Id, expiration));
        session.Player.Inventory.ConsumeItem(session, item.Uid, 1);
    }
コード例 #5
0
    private static void HandleCompleteNavigator(GameSession session, PacketReader packet)
    {
        int questId = packet.ReadInt();

        if (!session.Player.QuestData.TryGetValue(questId, out QuestStatus questStatus) || questStatus.State is QuestState.Finished)
        {
            return;
        }

        foreach (QuestRewardItem rewardItem in questStatus.RewardItems)
        {
            Item item = new(rewardItem.Code)
            {
                Amount = rewardItem.Count,
                Rarity = rewardItem.Rank
            };
            session.Player.Inventory.AddItem(session, item, true);
        }

        Condition firstCondition = questStatus.Condition.First();

        firstCondition.Current++;
        firstCondition.Completed = true;

        questStatus.State             = QuestState.Finished;
        questStatus.CompleteTimestamp = TimeInfo.Now();
        DatabaseManager.Quests.Update(questStatus);
        session.Send(QuestPacket.CompleteQuest(questId, false));
    }
コード例 #6
0
    /// <summary>
    /// Increase the current condition value by 1.
    /// If the condition value is already at the maximum, the condition is completed.
    /// Send the respective quest packets to the player.
    /// </summary>
    private static void UpdateConditions(this IEnumerable <Condition> relevantConditions, GameSession session, QuestStatus quest)
    {
        foreach (Condition condition in relevantConditions)
        {
            if (condition.Goal != 0 && condition.Goal == condition.Current)
            {
                continue;
            }

            condition.Current++;
            if (condition.Current >= condition.Goal)
            {
                condition.Completed = true;
            }

            session.Send(QuestPacket.UpdateCondition(quest.Basic.Id, quest.Condition));

            if (!condition.Completed || quest.Basic.QuestType is not QuestType.Exploration)
            {
                continue;
            }

            quest.State = QuestState.Completed;
            quest.AmountCompleted++;
            quest.CompleteTimestamp = TimeInfo.Now();

            session.Player.Levels.GainExp(quest.Reward.Exp);
            session.Player.Wallet.Meso.Modify(quest.Reward.Money);
            session.Send(QuestPacket.CompleteQuest(quest.Basic.Id, false));

            DatabaseManager.Quests.Update(quest);
        }
    }
コード例 #7
0
    public Item(int id, bool saveToDatabase = true)
    {
        Id = id;
        SetMetadataValues();
        Name       = ItemMetadataStorage.GetName(id);
        Level      = ItemMetadataStorage.GetLevel(id);
        ItemSlot   = ItemMetadataStorage.GetSlot(id);
        IsTemplate = ItemMetadataStorage.GetIsTemplate(id);
        if (GemSlot == GemSlot.TRANS)
        {
            TransparencyBadgeBools = new byte[10];
        }

        Rarity                = ItemMetadataStorage.GetRarity(id);
        PlayCount             = ItemMetadataStorage.GetPlayCount(id);
        Color                 = ItemMetadataStorage.GetEquipColor(id);
        CreationTime          = TimeInfo.Now();
        RemainingGlamorForges = ItemExtractionMetadataStorage.GetExtractionCount(id);
        Slot   = -1;
        Amount = 1;
        Score  = new();
        Stats  = new(id, Rarity, ItemSlot, Level);
        if (saveToDatabase)
        {
            Uid = DatabaseManager.Items.Insert(this);
        }
    }
コード例 #8
0
    private static void HandleRename(GameSession session, PacketReader packet)
    {
        long   clubId      = packet.ReadLong();
        string clubNewName = packet.ReadUnicodeString();

        Club club = GameServer.ClubManager.GetClubById(clubId);

        if (club is null)
        {
            return;
        }

        if (club.LastNameChangeTimestamp > TimeInfo.Now() + 3600) // 1 hour restriction to change names
        {
            session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.CanOnlyBeRenamedOnceAnHour));
            return;
        }

        if (!ValidClubName(session, clubNewName))
        {
            return;
        }

        if (clubNewName == club.Name)
        {
            session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.NewNameIsCurrentName));
            return;
        }

        club.SetName(clubNewName);
    }
コード例 #9
0
 public GuildApplication(long player, long guild)
 {
     CharacterId       = player;
     GuildId           = guild;
     CreationTimestamp = TimeInfo.Now() + Environment.TickCount;
     Id = DatabaseManager.GuildApplications.Insert(this);
 }
コード例 #10
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 = TimeInfo.Now() + Environment.TickCount;
        session.Send(GuildPacket.CheckInBegin());

        Item guildCoins = new(id : 30000861, amount : property.AttendGuildCoin, rarity : 4);

        session.Player.Inventory.AddItem(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));
    }
コード例 #11
0
    private static void PurchaseUgcItem(GameSession session, long ugcMarketItemId)
    {
        UgcMarketItem marketItem = GameServer.UgcMarketManager.FindItemById(ugcMarketItemId);

        if (marketItem is null || marketItem.ListingExpirationTimestamp < TimeInfo.Now())
        {
            return;
        }

        if (!HandleMarketItemPay(session, marketItem.Price, MeretMarketCurrencyType.Meret))
        {
            return;
        }

        marketItem.SalesCount++;
        DatabaseManager.UgcMarketItems.Update(marketItem);
        _ = new UgcMarketSale(marketItem.Price, marketItem.Item.Ugc.Name, marketItem.SellerCharacterId);

        Item item = new(marketItem.Item)
        {
            CreationTime = TimeInfo.Now()
        };

        item.Uid = DatabaseManager.Items.Insert(item);

        session.Player.Inventory.AddItem(session, item, true);
        session.Send(MeretMarketPacket.Purchase(0, marketItem.MarketId, marketItem.Price, 1));
    }
コード例 #12
0
    private static void HandleSaveHair(GameSession session, PacketReader packet)
    {
        long hairUid = packet.ReadLong();

        Item hair = session.Player.Inventory.Cosmetics.FirstOrDefault(x => x.Value.Uid == hairUid).Value;

        if (hair == null || hair.ItemSlot != ItemSlot.HR)
        {
            return;
        }

        if (session.Player.HairInventory.SavedHair.Count > 30) // 30 is the max slots
        {
            return;
        }

        Item hairCopy = new(hair.Id)
        {
            HairData     = hair.HairData,
            Color        = hair.Color,
            CreationTime = TimeInfo.Now() + Environment.TickCount
        };

        session.Player.HairInventory.SavedHair.Add(hairCopy);

        session.Send(BeautyPacket.SaveHair(hair, hairCopy));
    }
コード例 #13
0
ファイル: ClubMember.cs プロジェクト: Etchavious/MapleServer2
 public ClubMember(Player player, long clubId)
 {
     Player         = player;
     JoinTimestamp  = TimeInfo.Now();
     ClubId         = clubId;
     InviteResponse = ClubInviteResponse.Pending;
     DatabaseManager.ClubMembers.Insert(this);
 }
コード例 #14
0
 private static void HandleClose(GameSession session)
 {
     if (session.Player.MapId == (int)Map.PrivateResidence)
     {
         session.Player.HouseDoctorAccessTime = TimeInfo.Now();
     }
     DatabaseManager.BankInventories.Update(session.Player.Account.BankInventory);
 }
コード例 #15
0
    public static PacketWriter SetInitial2()
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.ResponseTimeSync);

        pWriter.Write(TimeSyncPacketMode.SetInitial2);
        pWriter.WriteLong(TimeInfo.Now());

        return(pWriter);
    }
コード例 #16
0
    public static PacketWriter UpdatePlayerDonation(/*int totalDonationAmount*/)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD);

        pWriter.Write(GuildPacketMode.UpdatePlayerDonation);
        pWriter.WriteInt(0x3); // total amount of donations today
        pWriter.WriteLong(TimeInfo.Now() + Environment.TickCount);
        return(pWriter);
    }
コード例 #17
0
    public static PacketWriter MemberLoggedOff(Player player)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD);

        pWriter.Write(GuildPacketMode.MemberLoggedOff);
        pWriter.WriteUnicodeString(player.Name);
        pWriter.WriteLong(TimeInfo.Now());
        return(pWriter);
    }
コード例 #18
0
    // Called first time when starting a new session
    public void InitPlayer(Player player)
    {
        Debug.Assert(player.FieldPlayer == null, "Not allowed to reinitialize player.");

        Player             = player;
        FieldManager       = FieldManagerFactory.GetManager(player);
        player.FieldPlayer = FieldManager.RequestCharacter(player);
        player.LastLogTime = TimeInfo.Now();
    }
コード例 #19
0
    public static PacketWriter SetInitial2()
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.RESPONSE_TIME_SYNC);

        pWriter.Write(TimeSyncPacketMode.SetInitial2);
        pWriter.WriteLong(TimeInfo.Now());

        return(pWriter);
    }
コード例 #20
0
        /*
         * In a Visual Studio project create a class Time to hold information about the current time and the current date .
         *
         * Make an easy-to-use constructor (from client perspective), that would represent the time and date the client wants to hold in your class.
         *
         * Implement the ToString() method, returning the time and date in format : "hh:mm:ss dd.MM.YY".
         *
         * Bonus Make a static method Now() for your class, returning the Time at the present moment :) (of type Time)
         */
        static void Main(string[] args)
        {
            var ourTime = new TimeInfo(new DateTime(2015, 02, 16, 14, 16, 00));

            Console.WriteLine(ourTime.ToString());

            var time = TimeInfo.Now();

            Console.WriteLine(time.ToString());
        }
コード例 #21
0
    public static PacketWriter Collect(Mail mail)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.MAIL);

        pWriter.Write(MailPacketMode.Collect);
        pWriter.WriteLong(mail.Id);
        pWriter.WriteByte(1);
        pWriter.WriteByte();
        pWriter.WriteLong(TimeInfo.Now());
        return(pWriter);
    }
コード例 #22
0
 public GuildMember(Player player, byte rank, long guildId)
 {
     Id               = player.CharacterId;
     Player           = player;
     Rank             = rank;
     Motto            = "";
     JoinTimestamp    = TimeInfo.Now() + Environment.TickCount;
     LastLogTimestamp = player.LastLogTime;
     GuildId          = guildId;
     DatabaseManager.GuildMembers.Insert(this);
 }
コード例 #23
0
    public static PacketWriter FailLikeSkill(long characterId, CoordB coordB)
    {
        PacketWriter packetWriter = PacketWriter.Of(SendOp.FunctionCube);

        packetWriter.Write(FunctionCubeMode.FailLifeSkill);
        packetWriter.WriteLong(characterId);
        packetWriter.WriteUnicodeString($"4_{coordB.AsHexadecimal()}");
        packetWriter.WriteLong(TimeInfo.Now());

        return(packetWriter);
    }
コード例 #24
0
ファイル: QuestPacket.cs プロジェクト: quotopian/MapleServer2
    // Animation: Animates the quest helper
    public static PacketWriter CompleteQuest(int questId, bool animation)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.QUEST);

        pWriter.Write(QuestType.CompleteQuest);
        pWriter.WriteInt(questId);
        pWriter.WriteInt(animation ? 1 : 0);
        pWriter.WriteLong(TimeInfo.Now());

        return(pWriter);
    }
コード例 #25
0
    public static PacketWriter SuccessLifeSkill(long characterId, CoordB coordB, int status)
    {
        PacketWriter packetWriter = PacketWriter.Of(SendOp.FUNCTION_CUBE);

        packetWriter.Write(FunctionCubeMode.SuccessLifeSkill);
        packetWriter.WriteLong(characterId);
        packetWriter.WriteUnicodeString($"4_{CoordB.AsHexadecimal(coordB)}");
        packetWriter.WriteLong(TimeInfo.Now());
        packetWriter.WriteInt(status);

        return(packetWriter);
    }
コード例 #26
0
    public static PacketWriter UpdateArchitectScore(int ownerObjectId, int architectScoreCurrent, int architectScoreTotal)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.HOME_COMMAND);

        pWriter.Write(HomeCommandMode.UpdateArchitectScore);
        pWriter.WriteInt(ownerObjectId);
        pWriter.WriteLong(TimeInfo.Now());
        pWriter.WriteInt(architectScoreCurrent);
        pWriter.WriteInt(architectScoreTotal);

        return(pWriter);
    }
コード例 #27
0
ファイル: QuestPacket.cs プロジェクト: quotopian/MapleServer2
    public static PacketWriter AcceptQuest(int questId)
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.QUEST);

        pWriter.Write(QuestType.AcceptQuest);
        pWriter.WriteInt(questId);
        pWriter.WriteLong(TimeInfo.Now());
        pWriter.WriteByte(1);
        pWriter.WriteInt();

        return(pWriter);
    }
コード例 #28
0
ファイル: Party.cs プロジェクト: quotopian/MapleServer2
    public Party(Player partyLeader)
    {
        Id                = GuidGenerator.Int();
        Leader            = partyLeader;
        ReadyCheck        = new();
        Members           = new();
        PartyFinderId     = 0;
        Approval          = true;
        CreationTimestamp = TimeInfo.Now() + Environment.TickCount;

        AddMember(partyLeader);
    }
コード例 #29
0
    public static PacketWriter SetInitial1()
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.ResponseTimeSync);

        pWriter.Write(TimeSyncPacketMode.SetInitial1);
        pWriter.WriteInt(Environment.TickCount);
        pWriter.WriteLong(TimeInfo.Now());
        pWriter.WriteByte();
        pWriter.WriteInt();

        return(pWriter);
    }
コード例 #30
0
    public static PacketWriter Request()
    {
        PacketWriter pWriter = PacketWriter.Of(SendOp.RESPONSE_TIME_SYNC);

        pWriter.Write(TimeSyncPacketMode.Request);
        pWriter.WriteInt(Environment.TickCount);
        pWriter.WriteLong(TimeInfo.Now());
        pWriter.WriteByte();
        pWriter.WriteInt();

        return(pWriter);
    }