Ejemplo n.º 1
0
        public async Task RetireAsync()
        {
            var person = await API.DecksiteApi.GetPersonAsync(Context.User.Id.ToString());

            if (string.IsNullOrEmpty(person.Name))
            {
                await ReplyAsync("I don't know who you are.  Please message me on MTGO, or https://pennydreadfulmagic.com/link your account first.");

                return;
            }
            var run = await DecksiteApi.GetRunAsync(person.Name);

            if (run == null)
            {
                await ReplyAsync($"You do not have an active deck in {DecksiteApi.CurrentLeagueName()}.");

                return;
            }

            var res = await run.RetireAsync();

            if (res)
            {
                await ReplyAsync($"Your deck {run.Name} has been retired from the {run.CompetitionName}");
            }
            else
            {
                await ReplyAsync($"Unable to retire your deck.  Please message Katelyn on discord.");
            }
        }
Ejemplo n.º 2
0
        public async Task <string> RunAsync(string user, IMatch game, string[] args)
        {
            DecksiteApi.Deck run;
            try
            {
                run = await DecksiteApi.GetRunAsync(user);
            }
            catch (WebException)
            {
                return("Error contacting PDM website.");
            }
            if (run == null)
            {
                return($"You do not have an active deck in {DecksiteApi.CurrentLeagueName()}.");
            }
            var res = await run.RetireAsync();

            if (res)
            {
                return($"Your deck {run.Name} has been retired from the {run.CompetitionName}");
            }
            else
            {
                return($"Unable to retire your deck.  Please message Katelyn on discord.");
            }
        }
Ejemplo n.º 3
0
 public async Task <string> RunAsync(string player, IMatch game, string[] args)
 {
     DecksiteApi.Deck run;
     try
     {
         run = await DecksiteApi.GetRunAsync(player);
     }
     catch (WebException)
     {
         return("Error contacting PDM website.");
     }
     if (run == null)
     {
         return($"You do not have an active deck in {DecksiteApi.CurrentLeagueName()}.");
     }
     return($"Your deck '{run.Name}' is currently {run.Wins}-{run.Losses}");
 }
Ejemplo n.º 4
0
        private async Task <bool> CheckForLeagueAsync()
        {
            if (match.Players.Length != 2)
            {
                return(false);
            }
            await Task.Delay(TimeSpan.FromSeconds(2)); // Sometimes PDBot gets into a game before one of the players.  If this happens, they miss the message.

            var desc = match.Comments.ToLower();
            var loud = desc.Contains("league");

            try
            {
                HostRun = await DecksiteApi.GetRunAsync(match.Players[0]);
            }
            catch (Exception)
            {
                match.Log($"[League] Unable to reach PDM");
                if (loud)
                {
                    match.SendChat($"[sD][sR] Error contacting pennydreadfulmagic.com, Please @[Report] manually!");
                }
                return(false);
            }
            if (HostRun == null)
            {
                match.Log($"[League] Host doesn't have active run");
                if (loud)
                {
                    match.SendChat($"[sD][sR] This is not a valid @[League] pairing!");
                    match.SendChat($"[sD][sR] {match.Players[0]}, you do not have an active run.");
                }

                return(false);
            }

            var opp = match.Players[1];

            try
            {
                LeagueRunOpp = await DecksiteApi.GetRunAsync(opp);
            }
            catch (Exception)
            {
                match.Log($"[League] Unable to reach PDM");
                if (loud)
                {
                    match.SendChat($"[sD][sR] Error contacting pennydreadfulmagic.com, Please @[Report] manually!");
                }
                return(false);
            }

            if (HostRun.CanPlay.Contains(opp, StringComparer.InvariantCultureIgnoreCase))
            {
                if (loud)
                {
                    match.SendChat($"[sD] Good luck in your @[League] match!");
                }
                else
                {
                    match.SendChat($"[sD] If this is a league match, don't forget to @[Report]!");
                }

                match.Log($"[League] {HostRun} ({HostRun.Id}) vs {LeagueRunOpp} ({LeagueRunOpp.Id})");

                if (File.Exists(Path.Combine("Updates", "urgent.txt")))
                {
                    match.SendChat("[sD] PDBot will be going down for scheduled maintenance.  Please @[Report] this league match manually.");
                    HostRun = null;
                }
                else if (!Features.PublishResults)
                {
                    match.SendChat("[sD] Due to a Magic Online bug, PDBot is unable to tell which player is which.  Please @[Report] this league match manually.");
                    HostRun = null;
                }

                if (match.MinutesPerPlayer != 25)
                {
                    match.SendChat($"[sAdept] This match has a {match.MinutesPerPlayer} timer.  If you are not comfortable with this, say !notleague");
                }
                return(true);
            }
            else
            {
                if (loud)
                {
                    match.SendChat($"[sD][sR] This is not a valid @[League] pairing!");
                }
                if (HostRun == null)
                {
                    if (loud)
                    {
                        match.SendChat($"[sD][sR] {match.Players[0]}, you do not have an active run.");
                    }
                    match.Log($"[League] {match.Players[0]} doesn't have active run");
                }
                else if (LeagueRunOpp == null)
                {
                    if (loud)
                    {
                        match.SendChat($"[sD][sR] {opp}, you do not have an active run.");
                    }
                    match.Log($"[League] {opp} doesn't have active run");
                }
                else
                {
                    if (loud)
                    {
                        match.SendChat($"[sD][sR] You have both already played each other with these decks.");
                    }
                    match.Log($"[League] Duplicate Pairing: {HostRun} ({HostRun.Id}) vs {LeagueRunOpp} ({LeagueRunOpp.Id})");
                }

                HostRun      = null;
                LeagueRunOpp = null;
                return(false);
            }
        }