Ejemplo n.º 1
0
    public override void Execute(GameCommandTrigger trigger)
    {
        int questId = trigger.Get <int>("id");

        if (questId == 0)
        {
            trigger.Session.SendNotice("Please type an quest id");
            return;
        }
        if (!QuestMetadataStorage.IsValid(questId))
        {
            trigger.Session.Send(NoticePacket.Notice($"Quest not found with id: {questId.ToString().Color(Color.Aquamarine)}.", NoticeType.Chat));
            return;
        }

        Player player = trigger.Session.Player;

        if (!player.QuestData.TryGetValue(questId, out QuestStatus questStatus))
        {
            questStatus = new(player, QuestMetadataStorage.GetMetadata(questId));
            player.QuestData.Add(questId, questStatus);
        }
        questStatus.State             = QuestState.Finished;
        questStatus.StartTimestamp    = TimeInfo.Now();
        questStatus.CompleteTimestamp = TimeInfo.Now();
        player.Levels.GainExp(questStatus.Reward.Exp);
        player.Wallet.Meso.Modify(questStatus.Reward.Money);

        foreach (QuestRewardItem reward in questStatus.RewardItems)
        {
            Item newItem = new(reward.Code)
            {
                Amount = reward.Count,
                Rarity = reward.Rank
            };
            if (newItem.RecommendJobs.Contains(player.Job) || newItem.RecommendJobs.Contains(0))
            {
                player.Inventory.AddItem(trigger.Session, newItem, true);
            }
        }
        DatabaseManager.Quests.Update(questStatus);
        trigger.Session.Send(QuestPacket.CompleteQuest(questId, true));

        // Add next quest
        IEnumerable <KeyValuePair <int, QuestMetadata> > questList = QuestMetadataStorage.GetAllQuests().Where(x => x.Value.Require.RequiredQuests.Contains(questId));

        foreach ((int id, QuestMetadata quest) in questList)
        {
            player.QuestData.Add(id, new(player, quest));
        }
    }
}
        public override void Execute(GameCommandTrigger trigger)
        {
            int questId = trigger.Get <int>("id");

            if (questId == 0)
            {
                trigger.Session.SendNotice("Please type an quest id");
                return;
            }
            if (!QuestMetadataStorage.IsValid(questId))
            {
                trigger.Session.Send(NoticePacket.Notice($"Quest not found with id: {questId.ToString().Color(Color.Aquamarine)}.", NoticeType.Chat));
                return;
            }
            QuestStatus questStatus = trigger.Session.Player.QuestList.FirstOrDefault(x => x.Basic.Id == questId);

            if (questStatus == null)
            {
                questStatus = new QuestStatus(trigger.Session.Player, QuestMetadataStorage.GetMetadata(questId));
                trigger.Session.Player.QuestList.Add(questStatus);
            }
            questStatus.Completed         = true;
            questStatus.CompleteTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
            trigger.Session.Player.Levels.GainExp(questStatus.Reward.Exp);
            trigger.Session.Player.Wallet.Meso.Modify(questStatus.Reward.Money);

            foreach (QuestRewardItem reward in questStatus.RewardItems)
            {
                Item newItem = new Item(reward.Code)
                {
                    Amount = reward.Count,
                    Rarity = reward.Rank
                };
                if (newItem.RecommendJobs.Contains(trigger.Session.Player.Job) || newItem.RecommendJobs.Contains(0))
                {
                    InventoryController.Add(trigger.Session, newItem, true);
                }
            }
            trigger.Session.Send(QuestPacket.CompleteQuest(questId, true));

            // Add next quest
            IEnumerable <KeyValuePair <int, QuestMetadata> > questList = QuestMetadataStorage.GetAllQuests().Where(x => x.Value.Require.RequiredQuests.Contains(questId));

            foreach (KeyValuePair <int, QuestMetadata> kvp in questList)
            {
                trigger.Session.Player.QuestList.Add(new QuestStatus(trigger.Session.Player, kvp.Value));
            }
        }
Ejemplo n.º 3
0
        private static void ProcessQuestCommand(GameSession session, string command)
        {
            if (command == "")
            {
                session.SendNotice("Type a quest id.");
                return;
            }
            if (!int.TryParse(command, out int questId))
            {
                return;
            }
            QuestStatus questStatus = session.Player.QuestList.FirstOrDefault(x => x.Basic.Id == questId);

            if (questStatus == null)
            {
                return;
            }

            questStatus.Completed         = true;
            questStatus.CompleteTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();

            session.Player.Levels.GainExp(questStatus.Reward.Exp);
            session.Player.Wallet.Meso.Modify(questStatus.Reward.Money);

            foreach (QuestRewardItem reward in questStatus.RewardItems)
            {
                Item newItem = new Item(reward.Code)
                {
                    Amount = reward.Count,
                    Rarity = reward.Rank
                };
                if (newItem.RecommendJobs.Contains(session.Player.Job) || newItem.RecommendJobs.Contains(0))
                {
                    InventoryController.Add(session, newItem, true);
                }
            }

            session.Send(QuestPacket.CompleteQuest(questId, true));

            // Add next quest
            IEnumerable <KeyValuePair <int, QuestMetadata> > questList = QuestMetadataStorage.GetAllQuests().Where(x => x.Value.Require.RequiredQuests.Contains(questId));

            foreach (KeyValuePair <int, QuestMetadata> kvp in questList)
            {
                session.Player.QuestList.Add(new QuestStatus(kvp.Value));
            }
        }
Ejemplo n.º 4
0
    private static void HandleCompleteQuest(GameSession session, PacketReader packet)
    {
        int questId  = packet.ReadInt();
        int objectId = packet.ReadInt();

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

        questStatus.State             = QuestState.Finished;
        questStatus.CompleteTimestamp = TimeInfo.Now();

        session.Player.Levels.GainExp(questStatus.Reward.Exp);
        session.Player.Wallet.Meso.Modify(questStatus.Reward.Money);

        foreach (QuestRewardItem reward in questStatus.RewardItems)
        {
            Item newItem = new(reward.Code)
            {
                Amount = reward.Count,
                Rarity = reward.Rank
            };
            if (newItem.RecommendJobs.Contains(session.Player.Job) || newItem.RecommendJobs.Contains(0))
            {
                session.Player.Inventory.AddItem(session, newItem, true);
            }
        }

        DatabaseManager.Quests.Update(questStatus);
        session.Send(QuestPacket.CompleteQuest(questId, true));

        // Add next quest
        IEnumerable <QuestMetadata> questList = QuestMetadataStorage.GetAllQuests().Values
                                                .Where(x => x.Require.RequiredQuests.Contains(questId));

        foreach (QuestMetadata questMetadata in questList)
        {
            if (session.Player.QuestData.ContainsKey(questMetadata.Basic.Id))
            {
                continue;
            }

            session.Player.QuestData.Add(questMetadata.Basic.Id, new(session.Player, questMetadata));
        }
    }
        private static void HandleCompleteQuest(GameSession session, PacketReader packet)
        {
            int questId  = packet.ReadInt();
            int objectId = packet.ReadInt();

            QuestStatus questStatus = session.Player.QuestList.FirstOrDefault(x => x.Basic.Id == questId);

            if (questStatus == null || questStatus.Completed)
            {
                return;
            }

            questStatus.Completed         = true;
            questStatus.CompleteTimestamp = DateTimeOffset.Now.ToUnixTimeSeconds();

            session.Player.Levels.GainExp(questStatus.Reward.Exp);
            session.Player.Wallet.Meso.Modify(questStatus.Reward.Money);

            foreach (QuestRewardItem reward in questStatus.RewardItems)
            {
                Item newItem = new Item(reward.Code)
                {
                    Amount = reward.Count,
                    Rarity = reward.Rank
                };
                if (newItem.RecommendJobs.Contains(session.Player.Job) || newItem.RecommendJobs.Contains(0))
                {
                    InventoryController.Add(session, newItem, true);
                }
            }

            DatabaseManager.Quests.Update(questStatus);
            session.Send(QuestPacket.CompleteQuest(questId, true));

            // Add next quest
            IEnumerable <KeyValuePair <int, QuestMetadata> > questList = QuestMetadataStorage.GetAllQuests().Where(x => x.Value.Require.RequiredQuests.Contains(questId));

            foreach (KeyValuePair <int, QuestMetadata> kvp in questList)
            {
                if (session.Player.QuestList.Exists(x => x.Basic.Id == kvp.Value.Basic.Id))
                {
                    continue;
                }
                session.Player.QuestList.Add(new QuestStatus(session.Player, kvp.Value));
            }
        }