public function findProblem(SlotCollectionProviderInterface $deck)
 {
     $slots = $deck->getSlots();
     $plotDeck = $slots->getPlotDeck();
     $plotDeckSize = $plotDeck->countCards();
     /* @var integer $expectedPlotDeckSize Expected number of plots */
     $expectedPlotDeckSize = 7;
     foreach ($slots->getAgendas() as $agenda) {
         if ($agenda->getCard()->getCode() === '05045') {
             $expectedPlotDeckSize = 12;
         }
     }
     if ($plotDeckSize > $expectedPlotDeckSize) {
         return 'too_many_plots';
     }
     if ($plotDeckSize < $expectedPlotDeckSize) {
         return 'too_few_plots';
     }
     /* @var integer $expectedPlotDeckSpread Expected number of different plots */
     $expectedPlotDeckSpread = $expectedPlotDeckSize - 1;
     if (count($plotDeck) < $expectedPlotDeckSpread) {
         return 'too_many_different_plots';
     }
     $expectedMaxAgendaCount = 1;
     if ($slots->isAlliance()) {
         $expectedMaxAgendaCount = 3;
     }
     if ($slots->getAgendas()->countCards() > $expectedMaxAgendaCount) {
         return 'too_many_agendas';
     }
     if ($slots->getDrawDeck()->countCards() < 60) {
         return 'too_few_cards';
     }
     foreach ($slots->getCopiesAndDeckLimit() as $cardName => $value) {
         if ($value['copies'] > $value['deck_limit']) {
             return 'too_many_copies';
         }
     }
     if (!empty($this->getInvalidCards($deck))) {
         return 'invalid_cards';
     }
     foreach ($slots->getAgendas() as $slot) {
         $valid_agenda = $this->validateAgenda($slots, $slot->getCard());
         if (!$valid_agenda) {
             return 'agenda';
         }
     }
     return null;
 }
 public function findProblem(SlotCollectionProviderInterface $deck)
 {
     $slots = $deck->getSlots();
     $agenda = $slots->getAgenda();
     $plotDeck = $slots->getPlotDeck();
     $plotDeckSize = $plotDeck->countCards();
     //check plot size only if no agenda is used or this agenda is not Rains of Castamere
     if (!$agenda || $agenda->getCode() != '05045') {
         if ($plotDeckSize > 7) {
             return 'too_many_plots';
         }
         if ($plotDeckSize < 7) {
             return 'too_few_plots';
         }
     }
     if (count($plotDeck) < 6) {
         return 'too_many_different_plots';
     }
     if ($slots->getAgendas()->countCards() > 1) {
         return 'too_many_agendas';
     }
     if ($slots->getDrawDeck()->countCards() < 60) {
         return 'too_few_cards';
     }
     foreach ($slots->getCopiesAndDeckLimit() as $cardName => $value) {
         if ($value['copies'] > $value['deck_limit']) {
             return 'too_many_copies';
         }
     }
     if (!empty($this->getInvalidCards($deck))) {
         return 'invalid_cards';
     }
     if ($agenda) {
         switch ($agenda->getCode()) {
             case '01198':
             case '01199':
             case '01200':
             case '01201':
             case '01202':
             case '01203':
             case '01204':
             case '01205':
                 $minorFactionCode = $this->agenda_helper->getMinorFactionCode($agenda);
                 $totalCards = $slots->getDrawDeck()->filterByFaction($minorFactionCode)->countCards();
                 if ($totalCards < 12) {
                     return 'agenda';
                 }
                 break;
             case '01027':
                 $drawDeck = $slots->getDrawDeck();
                 $count = 0;
                 foreach ($drawDeck as $slot) {
                     if ($slot->getCard()->getFaction()->getCode() === 'neutral') {
                         $count += $slot->getQuantity();
                     }
                 }
                 if ($count > 15) {
                     return 'agenda';
                 }
                 break;
             case '04037':
             case '04038':
                 $trait = $this->translator->trans('decks.problems_info.traits.' . ($agenda->getCode() == '04037' ? 'winter' : 'summer'));
                 $totalPlots = $plotDeck->filterByTrait($trait)->countCards();
                 if ($totalPlots > 0) {
                     return 'agenda';
                 }
                 break;
             case '05045':
                 $trait = $this->translator->trans('decks.problems_info.traits.scheme');
                 $totalPlots = $plotDeck->filterByTrait($trait)->countCards();
                 if ($plotDeckSize != 12 || $totalPlots != 5) {
                     return 'agenda';
                 }
                 break;
         }
     }
     return null;
 }