示例#1
0
        private async void EditBtn_Click(object sender, RoutedEventArgs e)
        {
            CardQueryOption query = Query.toModel();
            await masterViewModel.FilterCardsAsync(query);

            Frame.Navigate(typeof(SetCardDetailPage));
        }
示例#2
0
        public async Task refreshPageAsync()
        {
            if ((Cards.Count == 0) ||
                (Cards[0].cost != _cost) ||
                (Cards.Exists(p => p.playerClass != _class)))
            {
                var option = new CardQueryOption();
                option.AddHero(_class);
                // Neutral
                option.AddHero("None");
                option.AddCost(_cost);

                await CardData.GetCards(Cards, option);
            }

            AbstractCard empty = new AbstractCard();

            Board.Clear();

            for (int i = 0; i < Cards.Count; i++)
            {
                FindCardImage(Cards[i]);
                Board.Add(new DetailViewModel(Cards[i]));
            }

            OnPropertyChanged(nameof(this.Board));
        }
示例#3
0
        public async Task FilterCardsAsync(string setName)
        {
            var option = new CardQueryOption();

            option.AddExpansion(setName);

            await CardData.GetCards(Cards, option);

            Cards.ForEach(p => FindCardImage(p));
        }
示例#4
0
        public CardQueryOption toModel()
        {
            CardQueryOption result = new CardQueryOption();

            result.name = name;
            for (int i = 0; i < heroClassList.Count(); i++)
            {
                if (heroClassList[i])
                {
                    result.heroClassList.Add(heroClassString[i]);
                }
            }
            for (int i = 0; i < costList.Count(); i++)
            {
                if (costList[i])
                {
                    result.costList.Add(costListString[i]);
                }
            }
            for (int i = 0; i < cardTypeList.Count(); i++)
            {
                if (cardTypeList[i])
                {
                    result.cardTypeList.Add(cardTypeListString[i]);
                }
            }
            for (int i = 0; i < cardRarityList.Count(); i++)
            {
                if (cardRarityList[i])
                {
                    result.cardRarityList.Add(cardRarityListString[i]);
                }
            }
            for (int i = 0; i < modeList.Count(); i++)
            {
                if (modeList[i])
                {
                    result.modeList.Add(modeListString[i]);
                }
            }
            for (int i = 0; i < expansionList.Count(); i++)
            {
                if (expansionList[i])
                {
                    result.expansionList.Add(expansionListString[i]);
                }
            }
            return(result);
        }
示例#5
0
        public async static Task GetCards(List <AbstractCard> cards, CardQueryOption option)
        {
            var uri        = new Uri("ms-appx:///Assets/cards.json");
            var sampleFile = await StorageFile.GetFileFromApplicationUriAsync(uri);

            UnicodeEncoding encoding = new UnicodeEncoding();
            string          text     = await FileIO.ReadTextAsync(sampleFile, Windows.Storage.Streams.UnicodeEncoding.Utf8);

            var readFromFile = text;

            var jsonMessage = readFromFile;


            var          serializer = new DataContractJsonSerializer(typeof(CardSets));
            MemoryStream ms         = new MemoryStream(Encoding.UTF8.GetBytes(jsonMessage));

            CardSets F**k = (CardSets)serializer.ReadObject(ms);

            cards.Clear();
            List <AbstractCard> tempCards = new List <AbstractCard>();

            F**k.Basic.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "BASIC";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });
            F**k.Classic.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "BASIC";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });
            F**k.Naxxramas.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "NAX";
                aCard.mode         = "Wild";
                tempCards.Add(aCard);
            });
            F**k.GoblinsvsGnomes.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "GVG";
                aCard.mode         = "Wild";
                tempCards.Add(aCard);
            });
            F**k.BlackrockMountain.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "BRM";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });
            F**k.TheGrandTournament.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "AT";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });
            F**k.TheLeagueofExplorers.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "LOE";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });
            F**k.WhispersoftheOldGods.ForEach(p => {
                AbstractCard aCard = new AbstractCard();
                aCard.cardId       = p.cardId;
                aCard.collectable  = p.collectible;
                aCard.cost         = p.cost;
                aCard.attack       = p.attack;
                aCard.health       = p.health;
                aCard.name         = p.name;
                aCard.cardSet      = p.cardSet;
                aCard.type         = p.type;
                aCard.race         = p.race;
                aCard.rarity       = p.rarity;
                aCard.text         = p.text;
                aCard.playerClass  = p.playerClass == null ? "None" : p.playerClass;
                aCard.img          = p.img;
                aCard.flavor       = p.flavor;
                aCard.artist       = p.artist;
                aCard.cardSetName  = "OG";
                aCard.mode         = "Standard";
                tempCards.Add(aCard);
            });

            tempCards.RemoveAll(p => p.img == null || (p.collectable.GetValueOrDefault() == false) || p.type == "Hero");
            if (option.heroClassList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.heroClassList.Contains(p.playerClass));
            }
            if (option.costList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.costList.Contains(p.cost < 7 ? p.cost.ToString() : "7"));
            }
            if (option.expansionList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.expansionList.Contains(p.cardSetName));
            }
            if (option.cardTypeList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.cardTypeList.Contains(p.type));
            }
            if (option.modeList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.modeList.Contains(p.mode));
            }
            if (option.cardRarityList.Count != 0)
            {
                tempCards.RemoveAll(p => !option.cardRarityList.Contains(p.rarity));
            }

            cards.AddRange(tempCards.OrderBy(p => p.cost));

            cards.ForEach(p =>
            {
                uri      = new Uri(String.Format("ms-appx:///Assets/bars/{0}.png", p.cardId));
                var img  = new BitmapImage(uri);
                p.sImage = img;
            });
        }
示例#6
0
        public async Task FilterCardsAsync(CardQueryOption option)
        {
            await CardData.GetCards(Cards, option);

            Cards.ForEach(p => FindCardImage(p));
        }