Exemplo n.º 1
0
        public async Task Status(IUser user = null)
        {
            if (user == null)
            {
                if (!await PlayerHandler.AttemptLogin(Context.User))
                {
                    await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_MSG);

                    return;
                }
                user = Context.User;
                Player player = PlayerHandler.GetPlayer(user);
                string doneIn = String.Format(Action.DONE_IN_FORMAT, ((DateTime)player.currentAction.finishTime - DateTime.Now));
                await ReplyAsync(Context.User.Mention + ": " + player.currentAction.GetActiveFormattingSecondPerson() +
                                 ((player.currentAction is ActionIdle) ? "" : doneIn));

                return;
            }
            if (!await PlayerHandler.AttemptLogin(user))
            {
                await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_THIRD_PERSON(user.Username));

                return;
            }
            Player target = PlayerHandler.GetPlayer(user);

            await ReplyAsync(Context.User.Mention + ": " + target.currentAction.GetActiveFormattingThridPerson(false));
        }
Exemplo n.º 2
0
        public async Task InventoryCommand()
        {
            if (!await PlayerHandler.AttemptLogin(Context.User))
            {
                await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_MSG);

                return;
            }

            Player        player = PlayerHandler.GetPlayer(Context.User);
            StringBuilder outp   = new StringBuilder($"Inventory for {Context.User.Mention}\n");

            outp.Append($"{player.inventory.FreeSpaces}/{player.inventory.size} Slots available\n");
            int i = 0;

            foreach (ItemStack stack in player.inventory.items)
            {
                if (i % 5 == 0)
                {
                    outp.Append("\n");
                }
                if (stack == null)
                {
                    outp.Append(ItemStack.empty.ToString());
                }
                else
                {
                    outp.Append(stack.ToString() + " ");
                }

                i++;
            }
            await ReplyAsync(outp.ToString());
        }
Exemplo n.º 3
0
        public async Task LoginCommand()
        {
            if (!await PlayerHandler.AttemptLogin(Context.User))
            {
                await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_MSG);

                return;
            }
            Player p = PlayerHandler.GetPlayer(Context.User);

            await ReplyAsync(Context.User.Mention + ": " + Modules.LOGGED_IN_AS + p.name);
        }
Exemplo n.º 4
0
        public async Task Prefs(string prefName = null, string value = null)
        {
            if (!await PlayerHandler.AttemptLogin(Context.User))
            {
                await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_MSG);

                return;
            }
            Player p = PlayerHandler.GetPlayer(Context.User);

            if (String.IsNullOrWhiteSpace(value) && String.IsNullOrWhiteSpace(prefName))
            {
                StringBuilder outp = new StringBuilder(Modules.PREF_MSG_START);
                foreach (string key in p.GetPreferences().Keys)
                {
                    IPreference pref = p.GetPreferences()[key];
                    outp.Append(key + ": " + pref + "\n");
                }
                await ReplyAsync(outp.ToString());

                return;
            }
            else if (!String.IsNullOrWhiteSpace(prefName) && String.IsNullOrWhiteSpace(value))
            {
                IPreference pref = p.GetPreferences()[prefName];

                if (pref == null)
                {
                    await ReplyAsync(Context.User.Mention + ": That preference does not exist");

                    return;
                }

                await ReplyAsync(Context.User.Mention + ": " + prefName + " is " + pref);

                return;
            }
            else if (!String.IsNullOrWhiteSpace(prefName) && !String.IsNullOrWhiteSpace(value))
            {
                IPreference pref  = p.GetPreferences()[prefName];
                Type        t     = pref.type;
                var         toSet = Convert.ChangeType(value, t);
                p.SetPreferenceWithType(prefName, toSet, t);
            }
        }
Exemplo n.º 5
0
        public async Task Register([Summary("The name to register with")] string name = null)
        {
            if (name == null || name.Trim().Equals(""))
            {
                name = Context.User.Username;
            }
            if (await PlayerHandler.AttemptLogin(Context.User))
            {
                await ReplyAsync($"{Context.User.Mention}: {Modules.ALREADY_REGISTERED_MSG}");

                return;
            }
            else
            {
                PlayerHandler.CreatePlayer(Context.User, name);
                await ReplyAsync($"{Context.User.Mention}: {String.Format(Modules.REGISTERED_FORMAT, name)}");
            }
        }
Exemplo n.º 6
0
        public async Task Chop()
        {
            if (!await PlayerHandler.AttemptLogin(Context.User))
            {
                await ReplyAsync(Context.User.Mention + ": " + Modules.NOT_REGISTERED_MSG);

                return;
            }

            Player p = PlayerHandler.GetPlayer(Context.User);

            if (!p.IsIdle)
            {
                await ReplyAsync(Context.User.Mention + ": " + String.Format(Modules.ALREADY_ACTIVE_TIME_LEFT_FORMAT, p.currentAction.finishTime - DateTime.Now));

                return;
            }

            p.SetAction(new ActionChopWood(p), p.GetPreference <bool>("pm"), false);
            Action a = p.currentAction;

            await ReplyAsync(Context.User.Mention + ": " + a.GetStartedFormattingSecondPerson());
        }