Ejemplo n.º 1
0
        private void RemoveCommandExecute(object o)
        {
            HierarchicalResultViewModel vm = Hierarchical.Selected;

            if (vm == null)
            {
                return;
            }

            ICardCollection sourceCollection = _magicDatabase.GetAllCollections().First(cc => cc.Name == Hierarchical.Name);

            InputViewModel questionViewModel = InputViewModelFactory.Instance.CreateQuestionViewModel("Remove", string.Format("Remove selected from {0}?", sourceCollection.Name));

            OnInputRequested(questionViewModel);

            if (questionViewModel.Result == true)
            {
                using (_magicDatabaseForCardInCollection.BatchMode())
                {
                    foreach (ICardInCollectionCount cicc in GetCardInCollectionInSelected(vm, sourceCollection))
                    {
                        ICardCount cardCount = new CardCount();
                        foreach (KeyValuePair <ICardCountKey, int> kv in cicc.GetCardCount())
                        {
                            cardCount.Add(kv.Key, -kv.Value);
                        }

                        _magicDatabaseForCardInCollection.InsertOrUpdateCardInCollection(sourceCollection.Id, cicc.IdGatherer, cicc.IdLanguage, cardCount);
                    }
                }

                LoadCardsHierarchy();
            }
        }
Ejemplo n.º 2
0
        public void Return_work_in_process_for_a_given_day()
        {
            var dateTime = new DateTime(2017, 10, 03);

            var workInProcess = new CardCount(_card, _tellTheTime).GetInWorkInProcessCountFor(dateTime);

            Assert.That(workInProcess, Is.EqualTo(7));
        }
Ejemplo n.º 3
0
        public void Return_card_count_by_status()
        {
            var countByStatus = new CardCount(_card, _tellTheTime).GetCountByStatus();

            Assert.That(countByStatus[CardStatus.Status.Todo], Is.EqualTo(4));
            Assert.That(countByStatus[CardStatus.Status.Doing], Is.EqualTo(2));
            Assert.That(countByStatus[CardStatus.Status.Done], Is.EqualTo(4));
            Assert.That(countByStatus[CardStatus.Status.Unassigned], Is.EqualTo(1));
        }
Ejemplo n.º 4
0
        protected override IImportExportCardCount ParseLine(string line)
        {
            Match m = _regLine.Match(line);

            if (!m.Success)
            {
                return(new ErrorImportExportCardInfo(line, "Can't parse line"));
            }

            int count     = 0;
            int foilCount = 0;

            if (!int.TryParse(m.Groups["Count"].Value, out int tmpcount) || tmpcount <= 0)
            {
                return(new ErrorImportExportCardInfo(line, "Invalid value for count"));
            }

            if (m.Groups["Foil"].Value.ToUpper() == "TRUE")
            {
                foilCount = tmpcount;
            }
            else
            {
                count = tmpcount;
            }


            ICard card = MagicDatabase.GetCard(m.Groups["Name"].Value, null);

            if (card == null)
            {
                return(new ErrorImportExportCardInfo(line, string.Format("Can't find card named {0}", m.Groups["Name"].Value)));
            }

            IEdition edition = MagicDatabase.GetEditionFromCode(m.Groups["Edition"].Value);

            if (edition == null)
            {
                return(new ErrorImportExportCardInfo(line, string.Format("Can't find edition named {0}", m.Groups["Edition"].Value)));
            }

            int idGatherer = MagicDatabase.GetIdGatherer(card, edition);

            if (idGatherer == 0)
            {
                return(new ErrorImportExportCardInfo(line, string.Format("Can't find gatherer id for card {0} edition {1}", card, edition)));
            }

            CardCount cardCount = new CardCount
            {
                { CardCountKeys.Standard, count },
                { CardCountKeys.Foil, foilCount }
            };

            return(new ImportExportCardInfo(idGatherer, cardCount, 0));
        }
    void createAllCardDrawCntList(ref CardCount[] newList)
    {
        newList = new CardCount[allCards.Length];

        for (int i = 0; i < allCards.Length; i++)
        {
            newList [i]        = new CardCount();
            newList[i].drawCnt = new int[allCards[i].groupCards.Length];
        }
    }
Ejemplo n.º 6
0
        protected override IImportExportCardCount ParseLine(string line)
        {
            Match m = _regLine.Match(line);

            if (!m.Success)
            {
                return(new ErrorImportExportCardInfo(line, "Can't parse line"));
            }
            if (!int.TryParse(m.Groups["IdGatherer"].Value, out int idGatherer) || MagicDatabase.GetCard(idGatherer) == null)
            {
                return(new ErrorImportExportCardInfo(line, "Invalid IdGatherer"));
            }
            if (!int.TryParse(m.Groups["Count"].Value, out int count) || count < 0)
            {
                return(new ErrorImportExportCardInfo(line, "Invalid Count"));
            }
            if (!int.TryParse(m.Groups["FoilCount"].Value, out int foilCount) || foilCount < 0)
            {
                return(new ErrorImportExportCardInfo(line, "Invalid FoilCount"));
            }
            int    altArtCount  = 0;
            string sAltArtCount = m.Groups["AltArtCount"].Value;

            if (!string.IsNullOrWhiteSpace(sAltArtCount))
            {
                if (!int.TryParse(m.Groups["AltArtCount"].Value, out altArtCount) || altArtCount < 0)
                {
                    return(new ErrorImportExportCardInfo(line, "Invalid AltArtCount"));
                }
            }
            int    foilAltArtCount  = 0;
            string sFoilAltArtCount = m.Groups["FoilAltArtCount"].Value;

            if (!string.IsNullOrWhiteSpace(sFoilAltArtCount))
            {
                if (!int.TryParse(m.Groups["FoilAltArtCount"].Value, out foilAltArtCount) || foilAltArtCount < 0)
                {
                    return(new ErrorImportExportCardInfo(line, "Invalid FoilAltArtCount"));
                }
            }
            if (!int.TryParse(m.Groups["Language"].Value, out int idLanguage) || MagicDatabase.GetLanguages(idGatherer).All(l => l.Id != idLanguage))
            {
                return(new ErrorImportExportCardInfo(line, "Invalid idLanguage"));
            }

            CardCount cardCount = new CardCount
            {
                { CardCountKeys.Standard, count },
                { CardCountKeys.Foil, foilCount },
                { CardCountKeys.AltArt, altArtCount },
                { CardCountKeys.FoilAltArt, foilAltArtCount }
            };

            return(new ImportExportCardInfo(idGatherer, cardCount, idLanguage));
        }
Ejemplo n.º 7
0
        private void AddNewCard()
        {
            CardCount cardCount = new CardCount
            {
                { new CardCountKey(IsFoil, IsAltArt), Count }
            };

            ICardAllDbInfo cardAllDbInfo = _allCardInfos.First(cadi => cadi.Edition == EditionSelected && cadi.Card == _cardSelected);

            _magicDatabase.InsertOrUpdateCardInCollection(CardCollection.Id, cardAllDbInfo.IdGatherer, LanguageSelected.Id, cardCount);
        }
Ejemplo n.º 8
0
    public void initializeCard(Card c, int num)
    {
        Image childImg = makeChild(image) as Image;

        childImg.color = c.color;

        Text childText = makeChild(text) as Text;

        childText.text = num.ToString();

        deck [c] = new CardCount(childText, num);
    }
Ejemplo n.º 9
0
        public ICardCount GetCardCount()
        {
            CardCount cardCount = new CardCount
            {
                { CardCountKeys.Standard, Number },
                { CardCountKeys.Foil, FoilNumber },
                { CardCountKeys.AltArt, AltArtNumber },
                { CardCountKeys.FoilAltArt, FoilAltArtNumber }
            };

            return(cardCount);
        }
Ejemplo n.º 10
0
        protected override void OkCommandExecute(object o)
        {
            foreach (CardCollectionInputGraphicViewModel card in _cards.Where(c => c.ChangedCount != 0))
            {
                CardCount cardCount = new CardCount();
                cardCount.Add(new CardCountKey(Foil, AltArt), card.ChangedCount);

                _magicDatabase.InsertOrUpdateCardInCollection(CardCollection.Id, card.Card.IdGatherer, InputLanguage.Id, cardCount);
            }

            RefreshDisplayedData(true);
            HasChange = false;
        }
Ejemplo n.º 11
0
        public void Return_collection_of_count_by_day_for_all_cards()
        {
            var countByDays = new CardCount(_card, _tellTheTime).GetCardCountByDayFrom(4);

            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 01)).Total, Is.EqualTo(4));
            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 02)).Total, Is.EqualTo(9));
            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 03)).Total, Is.EqualTo(11));

            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 01)).DoneTotal, Is.EqualTo(3));
            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 02)).DoneTotal, Is.EqualTo(3));
            Assert.That(countByDays.First(c => c.Date == new DateTime(2017, 10, 03)).DoneTotal, Is.EqualTo(4));

            Assert.That(countByDays.All(c => c.Date != new DateTime(2017, 10, 06)));
        }
Ejemplo n.º 12
0
        private void RemoveCardCommandExecute(object o)
        {
            if (Hierarchical.Selected is not HierarchicalResultNodeViewModel nodeViewModel)
            {
                return;
            }

            var vm = new CardRemoveViewModel(Hierarchical.Name, nodeViewModel.Card.Card);

            OnDialogWanted(vm);

            if (vm.Result == true)
            {
                CardCount cardCount = new CardCount
                {
                    { new CardCountKey(vm.Source.IsFoil, vm.Source.IsAltArt), -vm.Source.Count }
                };

                _magicDatabaseForCardInCollection.InsertOrUpdateCardInCollection(vm.SourceCollection.Id, _magicDatabase.GetIdGatherer(vm.Source.Card, vm.Source.EditionSelected), vm.Source.LanguageSelected.Id, cardCount);
                LoadCardsHierarchy();
            }
        }
    void resizeAllCardDrawCnt()
    {
        //Test, if the size of the group list changed.
        bool listSizeChanged = false;

        if (allCards.Length != cardDrawCount.cnt.Length)
        {
            listSizeChanged = true;
        }
        else
        {
            //even if the upper list is constant, the sub-list have to be tested
            for (int i = 0; i < allCards.Length; i++)
            {
                if (allCards [i].groupCards.Length != cardDrawCount.cnt [i].drawCnt.Length)
                {
                    listSizeChanged = true;
                }
            }
        }

        //if a change was detected
        if (listSizeChanged == true)
        {
            //create a new list (temporary)
            CardCount[] tmpList = new CardCount[0];
            createAllCardDrawCntList(ref tmpList);
            //copy actual list to temporary list
            copyAllCardDrawCntlist(cardDrawCount.cnt, ref tmpList);
            //create a new main list
            createAllCardDrawCntList(ref cardDrawCount.cnt);
            //copy the values back to main list
            copyAllCardDrawCntlist(tmpList, ref cardDrawCount.cnt);

            //save the list
            saveDrawCnt();
        }
    }
Ejemplo n.º 14
0
 void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 15
0
 internal ImportExportCardInfo(int idGatherer, ICardCount cardCount, int idLanguage)
 {
     IdGatherer = idGatherer;
     IdLanguage = idLanguage;
     _cardCount = new CardCount(cardCount);
 }
        public JsonResult GetCardChartDataFor(int numberOfDays)
        {
            var cardCounts = new CardCount(_card, _tellTheTime).GetCardCountByDayFrom(numberOfDays);

            return(Json(cardCounts));
        }