예제 #1
0
        public override async Task Execute(IFieldObjUser user, StatCommandArgs args)
        {
            switch (args.Type)
            {
            case ModifyStatType.Skin:
            case ModifyStatType.Face:
            case ModifyStatType.Hair:
                await user.Prompt(target =>
                                  target.AskAvatar("Is this style okay?", new[] { args.Value })
                                  );

                break;

            case ModifyStatType.SP:
                if (GameConstants.IsExtendSPJob(user.Character.Job))
                {
                    var jobLevel = await user.Prompt(s => s.AskNumber("Which job level would you like to set?", min: 0, max: 10));

                    await user.ModifyStats(s => s.SetExtendSP((byte)jobLevel, (byte)args.Value));

                    await user.Message($"Successfully set extend SP (job level: {jobLevel}) to {args.Value}");

                    return;
                }
                break;
            }
            // TODO: pet

            await user.ModifyStats(s =>
            {
                switch (args.Type)
                {
                case ModifyStatType.Skin:
                    s.Skin = (byte)args.Value;
                    break;

                case ModifyStatType.Face:
                    s.Face = args.Value;
                    break;

                case ModifyStatType.Hair:
                    s.Hair = args.Value;
                    break;

                case ModifyStatType.Pet:
                case ModifyStatType.Pet2:
                case ModifyStatType.Pet3:
                    break;

                case ModifyStatType.Level:
                    s.Level = (byte)args.Value;
                    break;

                case ModifyStatType.Job:
                    s.Job = (short)args.Value;
                    break;

                case ModifyStatType.STR:
                    s.STR = (short)args.Value;
                    break;

                case ModifyStatType.DEX:
                    s.DEX = (short)args.Value;
                    break;

                case ModifyStatType.INT:
                    s.INT = (short)args.Value;
                    break;

                case ModifyStatType.LUK:
                    s.LUK = (short)args.Value;
                    break;

                case ModifyStatType.HP:
                    s.HP = args.Value;
                    break;

                case ModifyStatType.MaxHP:
                    s.MaxHP = args.Value;
                    break;

                case ModifyStatType.MP:
                    s.MP = args.Value;
                    break;

                case ModifyStatType.MaxMP:
                    s.MaxMP = args.Value;
                    break;

                case ModifyStatType.AP:
                    s.AP = (short)args.Value;
                    break;

                case ModifyStatType.SP:
                    s.SP = (short)args.Value;
                    break;

                case ModifyStatType.EXP:
                    s.EXP = args.Value;
                    break;

                case ModifyStatType.POP:
                    s.POP = (short)args.Value;
                    break;

                case ModifyStatType.Money:
                    s.Money = args.Value;
                    break;

                case ModifyStatType.TempEXP:
                    s.TempEXP = args.Value;
                    break;
                }
            });

            await user.Message($"Successfully set {args.Type} to {args.Value}");
        }
예제 #2
0
        protected override async Task Handle(GameStageUser stageUser, IFieldObjUser user, IPacketReader packet)
        {
            _ = packet.ReadInt();
            var templateID = packet.ReadInt();
            var template   = await stageUser.Stage.SkillTemplates.Retrieve(templateID);

            if (template == null)
            {
                return;
            }

            var job      = template.ID / 10000;
            var jobLevel = (byte)GameConstants.GetJobLevel(job);

            // TODO: job checks

            if (jobLevel == 0)
            {
                var sp = Math.Min(user.Character.Level - 1, job == 3000 ? 9 : 6);

                for (var i = 0; i < 3; i++)
                {
                    sp -= user.Character.GetSkillLevel(job * 1000 + 1000 + i);
                }
                if (sp > 0)
                {
                    await user.ModifySkills(s => s.Add(templateID), true);
                }
                return;
            }

            if (GameConstants.IsExtendSPJob(job) && user.Character.GetExtendSP(jobLevel) <= 0)
            {
                return;
            }
            if (!GameConstants.IsExtendSPJob(job) && user.Character.SP <= 0)
            {
                return;
            }

            var maxLevel = template.MaxLevel;

            if (GameConstants.IsSkillNeedMasterLevel(templateID))
            {
                maxLevel = (short)user.Character.GetSkillMasterLevel(templateID);
            }

            if (user.Character.GetSkillLevel(templateID) >= maxLevel)
            {
                return;
            }

            var increment = 1;

            await user.ModifyStats(s =>
            {
                if (GameConstants.IsExtendSPJob(job))
                {
                    s.SetExtendSP(jobLevel, (byte)(s.GetExtendSP(jobLevel) - increment));
                }
                else
                {
                    s.SP--;
                }
            });

            await user.ModifySkills(s => s.Add(templateID, increment), true);
        }