Ejemplo n.º 1
0
 public void RemoveEntry(AllyEntry entry)
 {
     RemoveEntry("alliances", entry.List);
 }
Ejemplo n.º 2
0
 public void UpdateEntry(AllyEntry entry)
 {
     UpdateEntry("alliances", entry.List);
 }
Ejemplo n.º 3
0
 public void RemoveEntryPending(AllyEntry entry)
 {
     RemoveEntry("alliance-pending", entry.List);
 }
Ejemplo n.º 4
0
 public void UpdateEntryPending(AllyEntry entry)
 {
     UpdateEntry("alliance-pending", entry.List);
 }
Ejemplo n.º 5
0
 public void AddEntry(AllyEntry entry)
 {
     AddEntry("alliances", entry.List);
 }
Ejemplo n.º 6
0
 public void AddEntryPending(AllyEntry entry)
 {
     AddEntry("alliance-pending", entry.List);
 }
Ejemplo n.º 7
0
        private void Request2(SocketCommandContext Context, dynamic user, dynamic target, string name)
        {
            string aID = "";
            string bID = "";

            string aDiscordID = "";
            string bDiscordID = "";

            string nameA = "";
            string nameB = "";

            if (user.GetType() == typeof(TownAccount))
            {
                TownAccount town = DatabaseService.GetTownByLeaderID(Context.Message.Author.Id.ToString());
                aID        = town.ID;
                nameA      = $"the city of {town.Name}";
                aDiscordID = town.LeaderID;
            }
            else
            {
                var nation = DatabaseService.GetNationByLeaderID(Context.Message.Author.Id.ToString());
                aID        = nation.ID;
                nameA      = $"the nation of {nation.Name}";
                aDiscordID = nation.LeaderID;
            }

            if (target.GetType() == typeof(TownAccount))
            {
                TownAccount town = DatabaseService.GetTownByName(name);
                bID        = town.ID;
                nameB      = $"the city of {town.Name}";
                bDiscordID = town.LeaderID;
            }
            else
            {
                NationAccount nation = DatabaseService.GetNationByName(name);
                bID        = nation.ID;
                nameB      = $"the nation of {nation.Name}";
                bDiscordID = nation.LeaderID;
            }

            AllyEntry ally = new AllyEntry(aID, bID, aDiscordID, bDiscordID, nameA, nameB);

            //Check if the alliance is already pending.
            if (DatabaseService.CheckExistancePending(ally))
            {
                Context.Message.AddReactionAsync(new Emoji("❎"));
                ReplyAsync($"You already have a pending alliance request with *`{name}`*.");
                return;
            }

            //Check if the alliance already exists.
            if (DatabaseService.CheckExistance(ally))
            {
                Context.Message.AddReactionAsync(new Emoji("❎"));
                ReplyAsync($"You already have an alliance with *`{name}`*.");
                return;
            }

            if (aID == bID)
            {
                Context.Message.AddReactionAsync(new Emoji("❎"));
                ReplyAsync($"You're already allied with yourself.");
                return;
            }

            Context.Client.GetUser(ulong.Parse(bDiscordID)).GetOrCreateDMChannelAsync().Result.SendMessageAsync($@"***New alliance request***

*Greetings,*

*`{FirstLetterToUpper(nameA)}`* has requested an alliance with *`{nameB}`*.
Please reply with `-accept {ally.ID}` or `-deny {ally.ID}`.");

            DatabaseService.AddEntryPending(ally);

            Context.Message.AddReactionAsync(new Emoji("✅"));
            ReplyAsync($"The alliance request has been sent to *`{name}`*. I will get back to you with their reaction.");
        }
Ejemplo n.º 8
0
        private void Remove2(SocketCommandContext Context, dynamic user, dynamic target, string name)
        {
            string aID = "";
            string bID = "";

            string aDiscordID = "";
            string bDiscordID = "";

            string nameA = "";
            string nameB = "";

            if (user.GetType() == typeof(TownAccount))
            {
                TownAccount town = DatabaseService.GetTownByLeaderID(Context.Message.Author.Id.ToString());
                aID        = town.ID;
                nameA      = $"the city of {town.Name}";
                aDiscordID = town.LeaderID;
            }
            else
            {
                var nation = DatabaseService.GetNationByLeaderID(Context.Message.Author.Id.ToString());
                aID        = nation.ID;
                nameA      = $"the nation of {nation.Name}";
                aDiscordID = nation.LeaderID;
            }

            if (target.GetType() == typeof(TownAccount))
            {
                TownAccount town = DatabaseService.GetTownByName(name);
                bID        = town.ID;
                nameB      = $"the city of {town.Name}";
                bDiscordID = town.LeaderID;
            }
            else
            {
                NationAccount nation = DatabaseService.GetNationByName(name);
                bID        = nation.ID;
                nameB      = $"the nation of {nation.Name}";
                bDiscordID = nation.LeaderID;
            }

            AllyEntry entry = new AllyEntry(aID, bID, aDiscordID, bDiscordID, nameA, nameB);

            //Check if the alliance exists.
            if (!DatabaseService.CheckExistance(entry))
            {
                Context.Message.AddReactionAsync(new Emoji("❎"));
                ReplyAsync($"You do not have an alliance with *`{name}`*.");
                return;
            }

            entry = DatabaseService.GetAlliance(aID, bID);

            if (aID == bID)
            {
                Context.Message.AddReactionAsync(new Emoji("❎"));
                ReplyAsync($"You can't betray yourself.");
                return;
            }

            Context.Client.GetUser(ulong.Parse(bDiscordID)).GetOrCreateDMChannelAsync().Result.SendMessageAsync($@"***Alliance terminated***

*Greetings,*

*`{FirstLetterToUpper(nameA)}`* has hereby terminated the alliance with *`{nameB}`*.
Please accept our condolences.
");

            DatabaseService.AddEntry(entry);
            DatabaseService.AddEntry(new AllyEntry(entry.BPartyID, entry.APartyID, entry.BPartyDiscordID, entry.APartyDiscordID, entry.BPartyName, entry.APartyName));

            Context.Message.AddReactionAsync(new Emoji("✅"));
            ReplyAsync($"The alliance with *`{name}`* has been terminated. I have informed them as well.");
        }