コード例 #1
0
        public async Task OnPostAsync(bool ShowAll)
        {
            this.ShowAll = ShowAll;
            var cards = from c in _context.CfgCard select c;

            cards = cards.OrderBy(c => c.Race).ThenBy(c => c.Star).ThenBy(c => c.Revision).ThenBy(c => c.Name);

            cards = cards.Where(c => c.Id == c.Root_card_id);
            IList <CfgCard> AllCards = await cards.ToListAsync();

            if (!string.IsNullOrEmpty(SearchName))
            {
                string sn = SearchName.ToLower();
                AllCards = AllCards.Where(c => c.GetName().ToLower().Contains(sn) || c.Name.ToLower().Contains(sn)).ToList();
            }

            if (ShowAll)
            {
                IList <CfgCard> UnobCards = AllCards.Where(c => !c.In_book).ToList();
                foreach (var card in UnobCards)
                {
                    RaceCardList rcl = GetRace(card.Race);
                    rcl.UnobtainableCards.Add(CfgCardWeb.Create(_context, card.Id));
                }
            }

            AllCards = AllCards.Where(c => c.In_book).ToList();
            foreach (var card in AllCards)
            {
                RaceCardList rcl = GetRace(card.Race);
                rcl.Cards.Add(CfgCardWeb.Create(_context, card.Id));
            }
        }
コード例 #2
0
        public async Task OnGetAsync(string name)
        {
            this.Name = name;
            if (string.IsNullOrEmpty(name))
            {
                // TODO: Update that part of code.
                var cards = from c in _context.CfgCard select c;
                cards = cards.OrderBy(c => c.Race).ThenBy(c => c.Star).ThenBy(c => c.Revision).ThenBy(c => c.Name);

                cards = cards.Where(c => c.Id == c.Root_card_id);
                IList <CfgCard> AllCards = await cards.ToListAsync();

                if (!string.IsNullOrEmpty(SearchName))
                {
                    string sn = SearchName.ToLower();
                    AllCards = AllCards.Where(c => c.GetName().ToLower().Contains(sn) || c.Name.ToLower().Contains(sn)).ToList();
                }

                if (ShowAll)
                {
                    IList <CfgCard> UnobCards = AllCards.Where(c => !c.In_book).ToList();
                    foreach (var card in UnobCards)
                    {
                        RaceCardList rcl = GetRace(card.Race);
                        rcl.UnobtainableCards.Add(CfgCardWeb.Create(_context, card.Id));
                    }
                }

                AllCards = AllCards.Where(c => c.In_book).ToList();
                foreach (var card in AllCards)
                {
                    RaceCardList rcl = GetRace(card.Race);
                    rcl.Cards.Add(CfgCardWeb.Create(_context, card.Id));
                }
            }
            else
            {
                CfgCardWeb UsedCard;

                int ID = 0;
                if (int.TryParse(Name, out ID))
                {
                    // ID was parsed.
                    UsedCard = CfgCardWeb.Create(_context, ID);
                }
                else
                {
                    // ID was not parsed. Probably a name.
                    UsedCard = CfgCardWeb.Create(_context, Name);
                }

                Card = UsedCard;

                /*
                 * var cards = from c in _context.CfgCard select c;
                 * CfgCard UsedCard = null;
                 *
                 * int ID = 0;
                 * if (int.TryParse(Name, out ID))
                 * {
                 *  cards = cards.Where(c => c.Id == ID);
                 * }
                 * else
                 * {
                 *  cards = cards.Where(c => c.Name == Name && c.In_book && c.Id == c.Root_card_id);
                 * }
                 * IList<CfgCard> tcardList = await cards.ToListAsync();
                 * if (tcardList.Count > 0)
                 *  UsedCard = tcardList.First();
                 *
                 * if (UsedCard != null)
                 * {
                 *  Card = new DetailedHeroInfo();
                 *  Card.Context = _context;
                 *  var skills = from s in _context.CfgSkill select s;
                 *  skills = skills.Where(s =>
                 *      (s.Id == (long)UsedCard.Skill1 || s.Id == (long)UsedCard.Skill2 ||
                 *       s.Id == (long)UsedCard.Skill3 ||
                 *       s.Id == (long)UsedCard.Skill4) && s.Id != 0);
                 *
                 *  var gifts = from s in _context.CfgSkill select s;
                 *  gifts = gifts.Where(g => g.Id == (long)UsedCard.Skill_gift && g.Id != 0);
                 *
                 *  var cardsQuerry = from c in _context.CfgCard select c;
                 *  cardsQuerry = cardsQuerry.Where(c => c.Root_card_id == UsedCard.Id).OrderBy(c => c.Star);
                 *
                 *  Card.RootCard = UsedCard;
                 *  List<CfgSkill> tskills = await skills.ToListAsync();
                 *
                 *  foreach (var skill in tskills)
                 *  {
                 *      string[] effects = skill.GetSkillEffects();
                 *      var db_effects = from s in _context.CfgSkillEffect select s;
                 *      db_effects = db_effects.Where(s => effects.Contains(s.Id.ToString()));
                 *      foreach (var effect in db_effects)
                 *      {
                 *          if (skill.Effects == null)
                 *              skill.Effects = new List<CfgSkillEffect>();
                 *          skill.Effects.Add(effect);
                 *      }
                 *  }
                 *
                 *  CfgSkill[] tSkillArray = new CfgSkill[4];
                 *  foreach (var skill in tskills)
                 *  {
                 *      if (skill.Id == UsedCard.Skill1)
                 *          tSkillArray[0] = skill;
                 *      else if (skill.Id == UsedCard.Skill2)
                 *          tSkillArray[1] = skill;
                 *      else if (skill.Id == UsedCard.Skill3)
                 *          tSkillArray[2] = skill;
                 *      else if (skill.Id == UsedCard.Skill4)
                 *          tSkillArray[3] = skill;
                 *  }
                 *
                 *  Card.Skills = tSkillArray.Where(t => t != null).ToList();
                 *
                 *  IList<CfgSkill> giftList = await gifts.ToListAsync();
                 *  if (giftList.Count > 0)
                 *  {
                 *      Card.Gift = giftList.First();
                 *      var db_effects = from s in _context.CfgSkillEffect select s;
                 *      db_effects = db_effects.Where(s => s.Id == Card.Gift.Id);
                 *      foreach (var effect in db_effects)
                 *      {
                 *          if (Card.Gift.Effects == null)
                 *              Card.Gift.Effects = new List<CfgSkillEffect>();
                 *          Card.Gift.Effects.Add(effect);
                 *      }
                 *  }
                 *
                 *  Card.AllCards = cardsQuerry.ToList();
                 *
                 *  int a = 0;
                 * }
                 * else
                 * {
                 *  // Redirect to where ever.
                 * }
                 *
                 */
            }
        }