Exemplo n.º 1
0
        protected override async Task Execute(FieldUser sender, object option)
        {
            var field          = sender.Field;
            var stringTemplate = sender.Service.TemplateManager.Get <FieldStringTemplate>(field.ID);

            await sender.Message($"{stringTemplate.StreetName}: {stringTemplate.MapName} ({field.ID})");

            await sender.Message(
                $"Object count: {field.GetObjects().Count()} (Controlled: {field.GetControlledObjects(sender).Count()} / {field.GetObjects<IFieldControlledObj>().Count()})");
        }
Exemplo n.º 2
0
        public Task Process(FieldUser sender, Queue <string> args)
        {
            if (args.Count > 0)
            {
                var first   = args.Peek();
                var command = GetCommand(first);

                if (command != null)
                {
                    args.Dequeue();
                    return(command.Process(sender, args));
                }
            }

            var result = _parser.ParseArguments <T>(args);

            return(Task.Run(() => result
                            .WithParsed(o => Execute(sender, o))
                            .WithNotParsed(errs =>
            {
                var helpText = HelpText.AutoBuild(result, _parser.Settings.MaximumDisplayWidth);

                helpText.Heading = string.Empty;
                helpText.Copyright = string.Empty;

                helpText.AddPostOptionsLines(
                    Commands.Select(c => $"{c.Name}\t\t\t\t{c.Description}")
                    );

                Regex
                .Split(helpText.ToString(), "\r\n|\r|\n")
                .ForEach((s, i) => sender.Message(s));
            }
                                           )));
        }
Exemplo n.º 3
0
        public override async Task Handle(RecvPacketOperations operation, IPacket packet, FieldUser user)
        {
            packet.Decode <int>();

            var message     = packet.Decode <string>();
            var onlyBalloon = packet.Decode <bool>();

            if (message.StartsWith(CommandManager.Prefix))
            {
                try
                {
                    await user.Service.CommandManager.Process(
                        user,
                        message.Substring(1)
                        );
                }
                catch (Exception e)
                {
                    await user.Message("An error has occured while executing that command.");
                }

                return;
            }

            using (var p = new Packet(SendPacketOperations.UserChat))
            {
                p.Encode <int>(user.ID);
                p.Encode <bool>(false);
                p.Encode <string>(message);
                p.Encode <bool>(onlyBalloon);
                await user.Field.BroadcastPacket(p);
            }
        }
Exemplo n.º 4
0
        public static async Task <QuestResult> Act(this QuestTemplate template, QuestState state, FieldUser user)
        {
            var act = template.Act[state];

            if (!user.Character.HasSlotFor(act.Items
                                           .Select(i =>
            {
                var item = user.Service.TemplateManager.Get <ItemTemplate>(i.TemplateID);
                var slot = item.ToItemSlot();

                if (slot is ItemSlotBundle bundle)
                {
                    bundle.Number = (short)i.Quantity;
                }

                return(slot);
            })
                                           .ToList()))
            {
                return(QuestResult.ActFailedInventory);
            }

            if (act.EXP != 0)
            {
                await user.ModifyStats(s => s.EXP += act.EXP);

                await user.Message(new IncEXPMessage
                {
                    EXP     = act.EXP,
                    OnQuest = true
                });
            }

            if (act.Items.Any())
            {
                await user.ModifyInventory(i =>
                                           act.Items.ForEach(ii =>
                {
                    if (ii.Quantity > 0)
                    {
                        i.Add(
                            user.Service.TemplateManager.Get <ItemTemplate>(ii.TemplateID),
                            (short)ii.Quantity
                            );
                    }
                    else
                    {
                        i.Remove(ii.TemplateID, (short)ii.Quantity);
                    }
                }
                                                             ));

                await user.Effect(new QuestEffect(act.Items
                                                  .Select(i => Tuple.Create(i.TemplateID, i.Quantity))
                                                  .ToList()));
            }

            return(QuestResult.ActSuccess);
        }
Exemplo n.º 5
0
        protected override async Task Execute(FieldUser sender, LevelUpCommandOption option)
        {
            if (option.Value < 0)
            {
                await sender.Message("This command cannot de-level character use only positive integers!");

                return;
            }

            await sender.ModifyStats(s =>
            {
                for (var i = 0; i < option.Value; i++)
                {
                    s.LevelUp();
                }
            });

            await sender.Message($"Successfully underwent level up {option.Value} times!");
        }
Exemplo n.º 6
0
 protected override async Task Execute(FieldUser sender, object option)
 {
     /*
      * var tradingRoom = new TradingRoom();
      * var tradingDialog = new MiniroomDialog(sender, tradingRoom);
      *
      * await sender.Interact(tradingDialog);
      */
     await sender.Message(
         $"{sender.Character.Level} : {GameConstants.CharacterEXPTable[sender.Character.Level]}");
 }
Exemplo n.º 7
0
        protected override async Task Execute(FieldUser sender, CashCommandOption option)
        {
            var account = sender.Socket.Account;
            var cash    = option.Type switch {
                0x2 => "Maple Point",
                0x4 => "Prepaid NX Cash",
                _ => "Nexon Cash"
            };

            account.IncCash(option.Type, option.Value - account.GetCash(option.Type));
            await sender.Message($"Successfully set {cash} to {option.Value}");
        }
    }
Exemplo n.º 8
0
        protected override async Task Execute(FieldUser sender, TOption option)
        {
            var templateManager = sender.Service.TemplateManager;
            var templateStrings = templateManager.GetAll <TString>().ToList();
            var templateID      = option.TemplateID;

            if (!string.IsNullOrEmpty(option.Search))
            {
                var glob    = Glob.Parse(option.Search, _globOptions);
                var results = templateStrings
                              .Where(p => glob.IsMatch(p.Name))
                              .ToList();

                if (!results.Any())
                {
                    results = templateStrings
                              .Where(p => p.Name.ToLower().Contains(option.Search.ToLower()))
                              .ToList();
                }

                if (results.Any())
                {
                    templateID = await sender.Prompt <int>(target => target.AskMenu(
                                                               $"Here are the results for '{option.Search}'",
                                                               results.ToDictionary(
                                                                   r => r.ID,
                                                                   r => $"{r.Name} ({r.ID})"
                                                                   )
                                                               ));
                }
            }

            if (templateID == null)
            {
                return;
            }

            var template = templateManager.Get <TTemplate>(templateID.Value);

            if (template == null)
            {
                await sender.Message($"Unable to find template of ID: {templateID}");

                return;
            }

            await ExecuteAfter(sender, template, option);
        }
Exemplo n.º 9
0
        protected override async Task ExecuteAfter(FieldUser sender, QuestTemplate template, QuestCommandOption option)
        {
            await sender.ModifyQuests(q =>
            {
                switch (option.State)
                {
                default:
                case QuestState.No:
                    q.Resign((short)template.ID);
                    break;

                case QuestState.Perform:
                    q.Accept((short)template.ID);
                    break;

                case QuestState.Complete:
                    q.Complete((short)template.ID);
                    break;
                }
            });

            await sender.Message($"Successfully set quest {template.ID} to {option.State}");
        }
Exemplo n.º 10
0
        protected override async Task Execute(FieldUser sender, StatCommandOption option)
        {
            if (option.Value < 0)
            {
                await sender.Message("This command cannot use negative integers use only positive integers!");

                return;
            }

            switch (option.Type)
            {
            case ModifyStatType.Skin:
            case ModifyStatType.Face:
            case ModifyStatType.Hair:
                await sender.Prompt(target =>
                                    target.AskAvatar("Is this style okay?", new[] { option.Value })
                                    );

                break;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                case ModifyStatType.SP:
                    if (option.ExtendSP.HasValue)
                    {
                        s.SetExtendSP(option.ExtendSP.Value, (byte)option.Value);
                    }
                    else
                    {
                        s.SP = (short)option.Value;
                    }
                    break;

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

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

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

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

            await sender.Message($"Successfully set {option.Type} to {option.Value}");
        }