public async Task <IActionResult> AdvanceCreatureManaCurve()
        {
            ScryfallDAL dl       = new ScryfallDAL();
            string      identity = FindPlayerType();

            AssistedDeckViewModel assistedDeck = OpenSession();

            string assistedDeckJSON = "";

            assistedDeck.CurvePosition++;


            //Checks if all points on the mana curve have been filled out. Once they have, creatures portion of deck
            //being true should now be true, so f converted t at position 5, and information is returned to index. this will
            //update the button status from red to green and indicate that this portion is taken care of.
            if (assistedDeck.CurvePosition >= assistedDeck.CurveData.Count())
            {
                assistedDeck.DeckStatus = assistedDeck.DeckStatus.Substring(0, 4) + "t";
                assistedDeckJSON        = System.Text.Json.JsonSerializer.Serialize(assistedDeck);
                HttpContext.Session.SetString("AssistedDeck", assistedDeckJSON);
                return(View("Index", assistedDeck));
            }
            ;


            assistedDeck.ErrorMessage = $"You need to select exactly {assistedDeck.CurveData[assistedDeck.CurvePosition]} creatures of this mana level.";

            assistedDeck.CardSearch = await dl.GetSearch($"id:{identity.ToLower()}+t:\"Creature\"+cmc={assistedDeck.CurvePosition+2}{RemoveDuplicatesFromEndpoint(assistedDeck.DeckName)}", FindPlayerBudget());

            assistedDeck.Creatures = assistedDeck.CurveData[assistedDeck.CurvePosition];
            assistedDeckJSON       = System.Text.Json.JsonSerializer.Serialize(assistedDeck);
            HttpContext.Session.SetString("AssistedDeck", assistedDeckJSON);

            return(View("FindCreatures", assistedDeck));
        }
        public async Task <IActionResult> StartCreatures()
        {
            //This List displays how many creatures should be chosen at each mana value along a mana curve.
            List <int> cardCurveData = new List <int>()
            {
                5,
                8,
                7,
                5,
                4,
                2
            };

            //Opens session, stores card curve data, then re-serializes as assistedDeckJSON. This assisted deck is then passed to the view
            AssistedDeckViewModel assistedDeck = OpenSession();

            assistedDeck.CurveData    = cardCurveData;
            assistedDeck.ErrorMessage = $"You need to select exactly {assistedDeck.CurveData[assistedDeck.CurvePosition]} creatures of this mana level.";

            //Reserialize the session, so that the information can be saved.
            string assistedDeckJSON = System.Text.Json.JsonSerializer.Serialize(assistedDeck);

            HttpContext.Session.SetString("AssistedDeck", assistedDeckJSON);

            //Taps into the DAL inorder to connect to scryfall endpoints for returning creatures that cost 2 mana
            ScryfallDAL dl       = new ScryfallDAL();
            string      identity = FindPlayerType();

            assistedDeck.CardSearch = await dl.GetSearch($"id:{identity.ToLower()}+t:\"Creature\"+cmc={assistedDeck.CurvePosition+2}{RemoveDuplicatesFromEndpoint(assistedDeck.DeckName)}", FindPlayerBudget());

            return(View("FindCreatures", assistedDeck));
        }
        public async void AddCardsToCardsTable(string assistedCardId)
        {
            Thread.Sleep(100);
            CardsTable cardTable = new CardsTable();

            if (_context.CardsTable.Where(x => x.CardId == assistedCardId).FirstOrDefault() == null)
            {
                Cardobject cardItem = await ScryfallDAL.GetApiResponse <Cardobject>("cards", assistedCardId, "https://api.scryfall.com/", "");

                if (cardItem.image_uris != null)
                {
                    cardTable.CardArtUrl = cardItem.image_uris.normal;
                }
                else
                {
                    cardTable.CardArtUrl = "https://img4.wikia.nocookie.net/__cb20140414012548/villains/images/8/86/Dennis_Nedry.png";
                }
                cardTable.CardId     = cardItem.id;
                cardTable.Cmc        = cardItem.cmc;
                cardTable.ManaCost   = cardItem.mana_cost;
                cardTable.Name       = cardItem.name;
                cardTable.OracleText = cardItem.oracle_text;
                cardTable.TypeLine   = cardItem.type_line;
                cardTable.EdhrecRank = cardItem.edhrec_rank;
                if (cardItem.prices.usd == null)
                {
                    cardItem.prices.usd = "0.00";
                }
                cardTable.CardPrice = decimal.Parse(cardItem.prices.usd);

                if (cardItem.color_identity.Contains("B"))
                {
                    cardTable.Black = "B";
                }
                if (cardItem.color_identity.Contains("U"))
                {
                    cardTable.Blue = "U";
                }
                if (cardItem.color_identity.Contains("W"))
                {
                    cardTable.White = "W";
                }
                if (cardItem.color_identity.Contains("G"))
                {
                    cardTable.Green = "G";
                }
                if (cardItem.color_identity.Contains("R"))
                {
                    cardTable.Red = "R";
                }
                _context.CardsTable.Add(cardTable);
                _context.SaveChanges();
            }
        }
        public async Task <IActionResult> FindDraw(AssistedDeckViewModel assistedDeck)
        {
            AssistedDeckViewModel session = OpenSession();
            string      identity          = FindPlayerType();
            ScryfallDAL dl = new ScryfallDAL();

            assistedDeck.CardSearch = await dl.GetSearch($"id:{identity.ToLower()}+o:draw{RemoveDuplicatesFromEndpoint(session.DeckName)}", FindPlayerBudget());

            assistedDeck.ErrorMessage = "You need to select exactly 10 card draw sources.";
            return(View(assistedDeck));
        }
        public async Task <IActionResult> FindSingleRemoval(AssistedDeckViewModel assistedDeck)
        {
            AssistedDeckViewModel session = OpenSession();
            ScryfallDAL           dl      = new ScryfallDAL();
            string identity = FindPlayerType();

            assistedDeck.CardSearch = await dl.GetSearch($"id:{identity.ToLower()}+o:\"destroy\"+t:\"instant\"ort:\"sorcery\"{RemoveDuplicatesFromEndpoint(session.DeckName)}", FindPlayerBudget());

            assistedDeck.ErrorMessage = "You need to select exactly 5 single target removal.";
            return(View(assistedDeck));
        }
        public async Task <IActionResult> FindRamp(AssistedDeckViewModel assistedDeck)
        {
            AssistedDeckViewModel session = OpenSession();
            string      identity          = FindPlayerType();
            ScryfallDAL dl = new ScryfallDAL();

            assistedDeck.CardSearch = await dl.GetSearch($"id:{identity.ToLower()}+produces<={FindPlayerType()}c+-t:\"Land\"{RemoveDuplicatesFromEndpoint(session.DeckName)}", FindPlayerBudget());

            assistedDeck.ErrorMessage = "You need to select exactly 10 sources of ramp.";
            //ramp goes to draw from the view
            return(View(assistedDeck));
        }
Exemple #7
0
        public async Task <IActionResult> AddCard(CardsTable cId, DecksTable dName)
        {
            var userId = FindUserId();

            string id = cId.CardId;

            if (_context.CardsTable.Where(x => x.CardId == id).FirstOrDefault() == null)
            {
                Cardobject cardItem = await ScryfallDAL.GetApiResponse <Cardobject>("cards", id, "https://api.scryfall.com/", "" + RemoveDuplicatesFromEndpoint(dName.DeckName));

                cId.CardArtUrl = cardItem.image_uris.normal;
                cId.CardId     = cardItem.id;
                cId.Cmc        = cardItem.cmc;
                cId.ManaCost   = cardItem.mana_cost;
                cId.Name       = cardItem.name;
                cId.OracleText = cardItem.oracle_text;
                cId.TypeLine   = cardItem.type_line;
                cId.EdhrecRank = cardItem.edhrec_rank;
                if (cardItem.prices.usd == null)
                {
                    cardItem.prices.usd = "0.00";
                }
                cId.CardPrice = decimal.Parse(cardItem.prices.usd);
                if (cardItem.color_identity.Contains("B"))
                {
                    cId.Black = "B";
                }
                if (cardItem.color_identity.Contains("U"))
                {
                    cId.Blue = "U";
                }
                if (cardItem.color_identity.Contains("W"))
                {
                    cId.White = "W";
                }
                if (cardItem.color_identity.Contains("G"))
                {
                    cId.Green = "G";
                }
                if (cardItem.color_identity.Contains("R"))
                {
                    cId.Red = "R";
                }
                _context.CardsTable.Add(cId);
                _context.SaveChanges();
            }

            //if the card the user is adding exists in the decks table, return to deckview with an error
            //otherwise, add the card

            //find ID of the card in the cards table
            var idCollection = (from x in _context.CardsTable where id == x.CardId select x.Id).FirstOrDefault();
            //find if the card exists in the decks table for this user and this deck
            var cardExists = (from d in _context.DecksTable where idCollection == d.CardId && FindUserId() == d.AspUserId && dName.DeckName == d.DeckName select d).FirstOrDefault();

            //if the linq statement returns null, the card doesn't exist and needs to be added.
            if (cardExists == null || cardExists.CardId == 5633 || cardExists.CardId == 5634 || cardExists.CardId == 5635 || cardExists.CardId == 5636 || cardExists.CardId == 5637)
            {
                if (cId.ManaCost != null)
                {
                    string colorId = FindColorId(cId);
                    dName.ColorIdentity = colorId;
                }
                else
                {
                    dName.ColorIdentity = "L";
                }
                dName.CardId   = idCollection;
                dName.Quantity = 1;


                if (userId != null)
                {
                    dName.AspUserId = userId;
                }

                _context.DecksTable.Add(dName);
                _context.SaveChanges();

                return(RedirectToAction("DeckList", dName));
            }
            //else redirect to the decklist
            else
            {
                dName.errorMessage = "The card you've added already exists in your deck!";
                return(RedirectToAction("DeckList", dName));
            }
        }
Exemple #8
0
        public async Task <IActionResult> CardManaCost(string manaCost)
        {
            Cardobject cardItem = await ScryfallDAL.GetApiResponse <Cardobject>("cards", "order?cmc=", "https://api.scryfall.com/", manaCost);

            return(View(cardItem));
        }
Exemple #9
0
        public async Task <IActionResult> CardPricing(string money)
        {
            Prices cardItem = await ScryfallDAL.GetApiResponse <Prices>("cards", "order?usd=", "https://api.scryfall.com/", money);

            return(View(cardItem));
        }
Exemple #10
0
        public async Task <IActionResult> CardColorList(string cardColor)
        {
            Cardobject cardItem = await ScryfallDAL.GetApiResponse <Cardobject>("cards", "search?order=", "https://api.scryfall.com/", cardColor);

            return(View(cardItem));
        }
Exemple #11
0
        public async Task <IActionResult> CardList(string cardName, DecksTable dName)
        {
            CardsTable            cardTable = new CardsTable();
            ScryfallDAL           dl        = new ScryfallDAL();
            List <CardsTable>     cardList  = new List <CardsTable>();
            CombinedDeckViewModel combo     = new CombinedDeckViewModel();

            var cardId = _context.CardsTable.Where(x => x.Name.Contains(cardName)).FirstOrDefault();

            if (cardId == null)
            {
                CardSearchObject cardItem = await dl.GetListOfCards($"{cardName}+{ RemoveDuplicatesFromEndpoint(dName.DeckName)}");

                if (cardItem.data != null)
                {
                    for (int i = 0; i < cardItem.data.Length; i++)
                    {
                        if (cardItem.data[i].image_uris == null)
                        {
                            cardTable.CardArtUrl = "https://img4.wikia.nocookie.net/__cb20140414012548/villains/images/8/86/Dennis_Nedry.png";
                        }
                        else
                        {
                            cardTable.CardArtUrl = cardItem.data[i].image_uris.normal;
                        }
                        cardTable.CardId     = cardItem.data[i].id;
                        cardTable.Cmc        = cardItem.data[i].cmc;
                        cardTable.ManaCost   = cardItem.data[i].mana_cost;
                        cardTable.Name       = cardItem.data[i].name;
                        cardTable.OracleText = cardItem.data[i].oracle_text;
                        cardTable.TypeLine   = cardItem.data[i].type_line;
                        cardTable.EdhrecRank = cardItem.data[i].edhrec_rank;
                        if (cardItem.data[i].prices == null)
                        {
                            cardItem.data[i].prices.usd      = "0.00";
                            cardItem.data[i].prices.eur      = "0.00";
                            cardItem.data[i].prices.usd_foil = "0.00";
                            cardItem.data[i].prices.tix      = "0.00";
                        }
                        else if (cardItem.data[i].prices.usd == null)
                        {
                            cardItem.data[i].prices.usd = "0.00";
                        }
                        cardTable.CardPrice = decimal.Parse(cardItem.data[i].prices.usd);

                        if (cardItem.data[i].color_identity.Contains("B"))
                        {
                            cardTable.Black = "B";
                        }
                        if (cardItem.data[i].color_identity.Contains("U"))
                        {
                            cardTable.Blue = "U";
                        }
                        if (cardItem.data[i].color_identity.Contains("W"))
                        {
                            cardTable.White = "W";
                        }
                        if (cardItem.data[i].color_identity.Contains("G"))
                        {
                            cardTable.Green = "G";
                        }
                        if (cardItem.data[i].color_identity.Contains("R"))
                        {
                            cardTable.Red = "R";
                        }

                        cardTable.Id = 0;

                        _context.CardsTable.Add(cardTable);
                        _context.SaveChanges();
                    }
                }
                else
                {
                    dName.errorMessage = "Unable to find the requested card";
                    return(RedirectToAction("DeckList", dName));
                }
            }

            //now that the card exists in the card table
            //we need to get the card from the cards table and save
            //first to the cardList then to the combo


            List <DecksTable> deckList = new List <DecksTable>();

            combo.Search     = cardList;
            combo.deckObject = deckList;

            cardList = (from c in _context.CardsTable where c.Name.Contains(cardName) select c).ToList();

            deckList.Add(dName);

            for (int i = 0; i < cardList.Count; i++)
            {
                combo.Search.Add(cardList[i]);
            }

            combo.deckObject = deckList;

            return(View(combo));
        }