Exemplo n.º 1
0
        public async Task DynastyEdit(string field, [Remainder] string value)
        {
            Player player = Context.Player;

            (Dynasty dan, DynastyMember _) = await GetDynasty(player);

            switch (field?.ToLower())
            {
            case "desc":
            case "description":
                if (value.Length > 240)
                {
                    await ReplyAsync("Description may not be longer than 240 characters");

                    return;
                }
                dan.description = value;
                await dan.Save();

                break;

            case "message":
                if (value.Length > 120)
                {
                    await ReplyAsync("Description may not be longer than 120 characters");

                    return;
                }
                dan.messageOfTheDay = value;
                await dan.Save();

                break;

            case "name":
                if (Dynasty.Exist(value))
                {
                    await ReplyAsync($"Dyansty name {value} is already in use");

                    return;
                }
                StringM.RegexName(value, 5);
                dan.name = value;
                await dan.Save();

                break;
            }
        }
Exemplo n.º 2
0
        public static async Task <Dynasty> CreateDynasty(Player founder, string name)
        {
            if (founder.dynasty != null)
            {
                throw NeitsilliaError.ReplyError(
                          "You are already part of a dynasty.");
            }
            if (founder.KCoins < DYNASTY_COST)
            {
                throw NeitsilliaError.ReplyError
                          ($"You are missing the required funds: {founder.KCoins}/{DYNASTY_COST}");
            }

            Dynasty dan = new Dynasty(founder, name);
            await dan.Save();

            founder.SaveFileMongo();
            return(dan);
        }