Exemple #1
0
        public string GetRewardPacket(Character character, bool onlyItems = false)
        {
            if (!QuestRewards.Any() || onlyItems && !QuestRewards.Any(s => (QuestRewardType)s.RewardType == QuestRewardType.WearItem || (QuestRewardType)s.RewardType == QuestRewardType.EtcMainItem))
            {
                return("");
            }

            return($"qr {GetRewardPacket()} {InfoId}");

            string GetRewardPacket()
            {
                string str = "";

                for (int a = 0; a < 4; a++)
                {
                    QuestRewardDTO reward = QuestRewards.Skip(a).FirstOrDefault();
                    if (reward == null || onlyItems && (QuestRewardType)reward.RewardType != QuestRewardType.WearItem && (QuestRewardType)reward.RewardType != QuestRewardType.EtcMainItem)
                    {
                        str += "0 0 0 ";
                        continue;
                    }
                    switch ((QuestRewardType)reward.RewardType)
                    {
                    // Item
                    case QuestRewardType.WearItem:
                    case QuestRewardType.EtcMainItem:
                        byte amount = (byte)(reward.Amount == 0 ? 1 : reward.Amount);
                        if (reward.Data == 1917 && character.IsMorphed)
                        {
                            amount *= 2;
                        }
                        character.GiftAdd((short)reward.Data, amount, reward.Rarity, reward.Upgrade, reward.Design, false);
                        str += $"{reward.RewardType} {reward.Data} {amount} ";
                        break;

                    // Gold
                    case QuestRewardType.Gold:
                    case QuestRewardType.SecondGold:
                    case QuestRewardType.ThirdGold:
                    case QuestRewardType.FourthGold:
                        character.GetGold(reward.Amount, true);
                        str += $"{reward.RewardType} 0 {(reward.Amount == 0 ? 1 : reward.Amount)} ";
                        break;

                    case QuestRewardType.Reput:     // Reputation
                        character.GetReputation(reward.Amount);
                        str += $"{reward.RewardType} 0 0";
                        break;

                    case QuestRewardType.Exp:     // Experience
                        if (character.Level < ServerManager.Instance.Configuration.MaxLevel)
                        {
                            character.GetXp((long)(CharacterHelper.XPData[reward.Data > 255 ? 255 : reward.Data] * reward.Amount / 100D));
                        }
                        str += $"{reward.RewardType} 0 0 ";
                        break;

                    case QuestRewardType.SecondExp:     // % Experience
                        if (character.Level < ServerManager.Instance.Configuration.MaxLevel)
                        {
                            character.GetXp((long)(CharacterHelper.XPData[character.Level] * reward.Amount / 100D));
                        }
                        str += $"{reward.RewardType} 0 0 ";
                        break;

                    case QuestRewardType.HeroExp:   // Experience
                        if (character.HeroLevel > 0 && character.HeroLevel < ServerManager.Instance.Configuration.MaxHeroLevel)
                        {
                            character.GetHeroExp((long)(CharacterHelper.HeroXpData[reward.Data > 255 ? 255 : reward.Data] * reward.Amount / 100D));
                        }
                        str += $"{reward.RewardType} 0 0 ";
                        break;

                    case QuestRewardType.JobExp:     // JobExperience
                        if (character.JobLevel < 20 && character.Class == ClassType.Adventurer || character.Class != ClassType.Adventurer && character.JobLevel < ServerManager.Instance.Configuration.MaxJobLevel)
                        {
                            character.GetJobExp((long)((character.Class == (byte)ClassType.Adventurer ? CharacterHelper.FirstJobXPData[reward.Data > 255 ? 255 : reward.Data] : CharacterHelper.SecondJobXPData[reward.Data > 255 ? 255 : reward.Data]) * reward.Amount / 100D));
                        }
                        str += $"{reward.RewardType} 0 0 ";
                        break;

                    case QuestRewardType.SecondJobExp:     // % JobExperience>
                        if (character.JobLevel < 20 && character.Class == ClassType.Adventurer || character.Class != ClassType.Adventurer && character.JobLevel < ServerManager.Instance.Configuration.MaxJobLevel)
                        {
                            character.GetJobExp((long)((character.Class == (byte)ClassType.Adventurer ? CharacterHelper.FirstJobXPData[character.JobLevel] : CharacterHelper.SecondJobXPData[character.JobLevel]) * reward.Amount / 100D));
                        }
                        str += $"{reward.RewardType} 0 0 ";
                        break;

                    default:
                        str += "0 0 0 ";
                        break;
                    }
                }
                return(str);
            }
        }