Пример #1
0
        public CardDetail GetCardDetail(Guid cardId, ImportCardModel importCardModel)
        {
            //English is the only language for the moment
            var languageId = _languageService.GetLanguageId(TypeOfLanguage.English);

            return(new CardDetail()
            {
                CardDetailId = Guid.NewGuid(),
                CardId = cardId,
                LanguageId = languageId,
                Name = importCardModel.Name,
                Text = importCardModel.Description.Text,
                Effect = importCardModel.Description.Effect,
                ToSolve = importCardModel.Description.ToSolve,
                Reward = importCardModel.Description.Reward,
                FlavorText = importCardModel.FlavorText,
                Illustrator = importCardModel.Artists != null?string.Join(", ", importCardModel.Artists) : null,
                                  Copyright = null, //Copyright isn't maintained in the JSON
                                  CreatedById = Guid.Empty,
                                  CreatedDate = DateTime.UtcNow,
                                  UpdatedById = Guid.Empty,
                                  UpdatedDate = DateTime.UtcNow,
                                  Deleted = false,
            });
        }
Пример #2
0
        public Card GetCard(ImportCardModel importCardModel, string setName, List <SetModel> cardSetCache, List <CardTypeModel> cardTypesCache,
                            List <RarityModel> raritiesCache, List <LessonTypeModel> lessonTypeCache)
        {
            /*
             * As a general rule, each item's (set, type, raritiy), name should match up between the DB and the JSON.
             */

            var cardSet    = cardSetCache.SingleOrDefault(x => x.Name.ToLower() == setName?.ToLower());
            var cardType   = cardTypesCache.SingleOrDefault(x => x.Name.ToLower() == importCardModel.Type?.ToLower());
            var cardRarity = raritiesCache.SingleOrDefault(x => x.Name.ToLower() == importCardModel.Rarity?.ToLower());
            var lessonType = lessonTypeCache.SingleOrDefault(x => x.Name.ToLower() == importCardModel.LessonType?.ToLower());

            //Cards typically cost 1 action. But some cards cost more. From the official game, only adventures and characters
            //cost 2 actions. We don't want to assume the card costs 1 action because someone might screw up and forget to assign
            //a type to a card with more than 1 action. In the website, we'll hide the action cost if it's null.
            int?actionCost = null;

            if (cardType != null)
            {
                var typeOfCard = _cardTypeService.GetTypeOfCard(cardType.CardTypeId);
                if (typeOfCard == TypeOfCard.Adventure || typeOfCard == TypeOfCard.Character)
                {
                    actionCost = 2;
                }
                else
                {
                    actionCost = 1;
                }
            }

            return(new Card()
            {
                CardId = Guid.NewGuid(),
                CardSetId = cardSet?.SetId,
                CardTypeId = cardType?.CardTypeId,
                CardRarityId = cardRarity?.RarityId,
                LessonTypeId = lessonType?.LessonTypeId,
                LessonCost = importCardModel.Cost == null ? null : (int?)Convert.ToInt32(importCardModel.Cost),
                ActionCost = actionCost,
                CardNumber = importCardModel.Number,
                Orientation = "Vertical", //Most cards are vertical. We'll set this to vertical by default and change it manually later
                CreatedById = Guid.Empty,
                CreatedDate = DateTime.UtcNow,
                UpdatedById = Guid.Empty,
                UpdatedDate = DateTime.UtcNow,
                Deleted = false,
            });
        }