Exemple #1
0
        public static async Task <(Dynasty, DynastyMember, string)> Load(Player player)
        {
            if (player.dynasty == null)
            {
                return(null, null, "You are not in a Dynasty");
            }
            Dynasty dan = await Load(player.dynasty.id);

            if (dan == null)
            {
                player.dynasty = null;
                player.SaveFileMongo();
                return(dan, null, "Your dynasty was disbanded");
            }
            DynastyMember membership = dan.GetMember(player);

            if (membership == null)
            {
                player.dynasty = null;
                player.SaveFileMongo();
                return(dan, membership, "You were removed from the dynasty " + dan.name);
            }

            return(dan, membership, null);
        }
Exemple #2
0
 internal EmbedBuilder ToEmbed(Dynasty dan)
 {
     return(DUtils.BuildEmbed($"{name}, {dan.rankNames[rank]} of {dan.name}",
                              $"User: <@{userId}>" + Environment.NewLine +
                              $"Member since {joined.ToShortDateString()}",
                              null, default));
 }
Exemple #3
0
        public async Task CreateDynasty([Remainder] string dynastyName)
        {
            Context.WIPCheck();

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

                return;
            }

            StringM.RegexName(dynastyName, 5);

            Player player = Context.Player;

            if (player.userid != 201875246091993088 && player.level < 20)
            {
                await ReplyAsync("Character must be minimum level 20 to create a Dynasty.");

                return;
            }

            await Dynasty.Load(player);

            if (player.dynasty != null)
            {
                await ReplyAsync("You are already in a dynasty");
            }
            else
            {
                await player.NewUI(await ReplyAsync(
                                       $"Form the {dynastyName} Dynasty for {Dynasty.DYNASTY_COST} Kutsyei Coins?"),
                                   MsgType.DynastyUpgrade, dynastyName);
            }
        }
Exemple #4
0
 public static async Task DynastyHub(Player player, Dynasty dynasty, DynastyMember membership, ISocketMessageChannel chan)
 {
     membership ??= dynasty.GetMember(player);
     await chan.SendMessageAsync(embed : dynasty.ToEmbed(
                                     dynasty.MemberField(membership)
                                     ).Build());
 }
        public DynastyTicket(Dynasty dynasty, DynastyMember member)
        {
            id          = dynasty._id;
            dynastyName = dynasty.name;

            userId     = member.userId;
            memberRank = dynasty.rankNames[member.rank];
        }
Exemple #6
0
        public static async Task <(Dynasty dan, DynastyMember membership)> GetDynasty(Player player)
        {
            (Dynasty dan, DynastyMember membership, string error) = await Dynasty.Load(player);

            if (error != null)
            {
                throw NeitsilliaError.ReplyError(error);
            }
            return(dan, membership);
        }
Exemple #7
0
        static EmbedBuilder DynastyUserEmbed(Dynasty dan, ulong user, out string memberCount)
        {
            DynastyMember[] members = dan.members.FindAll(m => m.userId == user).ToArray();
            if (members.Length == 0)
            {
                throw NeitsilliaError.ReplyError("This user has no characters in your Dynasty");
            }

            memberCount = members.Join(";", (m, i) => m.PlayerId);

            return(DUtils.BuildEmbed($"{dan.name} Dynasty User",
                                     $"<@{user}> has {members.Length} characters in this dynasty",
                                     null, default, DUtils.NewField("Characters",
Exemple #8
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;
            }
        }
Exemple #9
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);
        }
 public void Update(Dynasty dynasty, int rank)
 {
     dynastyName = dynasty.name;
     memberRank  = dynasty.rankNames[rank];
 }