public IBoosterPack Create()
        {
            // booster pack has 6 common, 3 uncommon, 1 rare or legendary
            var counter = 1;

            var booster = Generate(RarityEnum.Common, 6)
                          .Concat(Generate(RarityEnum.Uncommon, 3))
                          .Concat(Generate(RarityEnum.Rare, 1))
                          .ToList()
                          .AsReadOnly();

            return(new BoosterPack(booster));

            IEnumerable <ICard> Generate(RarityEnum rarity, int number)
            {
                for (int i = 0; i < number; i++)
                {
                    if (rarity == RarityEnum.Rare)
                    {
                        var rand = new Random();
                        rarity = rand.Next(0, 100) > 50 ? RarityEnum.Legendary : RarityEnum.Rare;
                    }

                    yield return(cardFactory.Create($"{counter++}", rarity));
                }
            }
        }
Exemplo n.º 2
0
        public GameField Create(int rowCount, int columnCount)
        {
            var cardCount = rowCount * columnCount;
            var content   = new List <ICard>();

            var cards = _cardFactory.Create(cardCount);

            content.AddRange(cards);

            var gameField = new GameField()
            {
                TurnsLeft = TurnCount,
            };

            gameField.SetCards(content.ToArray());

            return(gameField);
        }
Exemplo n.º 3
0
        /// <summary>
        /// The GenerateRandomProgram.
        /// </summary>
        /// <returns>The <see cref="ObservableCollection{ICard}"/>.</returns>
        private ObservableCollection <ICard?> GenerateRandomProgram()
        {
            string[] titleArray = { "PolyLine 3D", "Area", "Move", "Line", "PolyLine", "Arc", "Spiral", "Rectangular Sprial", "Dot", "Part Presense Check" };

            BitmapImage?image = new BitmapImage(new Uri(Environment.CurrentDirectory + "\\Modules\\TestImages\\FID.bmp", UriKind.RelativeOrAbsolute));

            ObservableCollection <ICard?> cards = new ObservableCollection <ICard?>();

            if (_mediationService.CurrentProgram !.ProgramName == "Manual Placement Simulation")
            {
                ICard manualCard = _cardFactory.Create();
                manualCard.CardSubSteps?.Add(_cardSubStepFactory.Create("Place Product", new string[] { string.Empty }));
                manualCard.StepTitle                        = "Place Product";
                manualCard.StepImage                        = _mediationService.CurrentProgram.ProductImage;
                manualCard.StepModalData                    = _modalService.CreateModalData();
                manualCard.StepModalData !.CanAbort         = true;
                manualCard.StepModalData !.CanContinue      = true;
                manualCard.StepModalData !.CanRetry         = false;
                manualCard.StepModalData !.Card             = null;
                manualCard.StepModalData !.Instructions     = "Place Product and press 'Continue' to begin" + Environment.NewLine + "Press 'Abort' to exit path playback";
                manualCard.StepModalData !.InstructionImage = _mediationService.CurrentProgram.ProductImage;
                manualCard.StepModalData !.IsError          = false;
                cards.Add(manualCard);
            }

            ICard fiducialCard = _cardFactory.Create();

            fiducialCard.CardSubSteps?.Add(_cardSubStepFactory.Create("Fiducial A", RandomCoordinates()));
            fiducialCard.CardSubSteps?.Add(_cardSubStepFactory.Create("Fiducial B", RandomCoordinates()));
            fiducialCard.StepTitle                        = "Fiducial Check";
            fiducialCard.StepImage                        = image;
            fiducialCard.StepModalData                    = _modalService.CreateModalData();
            fiducialCard.StepModalData !.CanAbort         = true;
            fiducialCard.StepModalData !.CanContinue      = true;
            fiducialCard.StepModalData !.CanRetry         = true;
            fiducialCard.StepModalData !.Card             = null;
            fiducialCard.StepModalData !.Instructions     = "Fiducials Failed, Select an option below";
            fiducialCard.StepModalData !.InstructionImage = image;
            fiducialCard.StepModalData !.IsError          = true;
            cards.Add(fiducialCard);
            int randSize = new Random().Next(1, 8);

            ICard surfaceCard = _cardFactory.Create();

            for (int i = 0; i < randSize; i++)
            {
                surfaceCard.CardSubSteps?.Add(_cardSubStepFactory.Create("Surface " + (i + 1).ToString(), RandomCoordinates()));
            }

            surfaceCard.StepTitle                    = "Surface Height Check";
            surfaceCard.StepModalData                = _modalService.CreateModalData();
            surfaceCard.StepModalData !.CanAbort     = true;
            surfaceCard.StepModalData !.CanRetry     = true;
            surfaceCard.StepModalData !.Card         = null;
            surfaceCard.StepModalData !.Instructions = "Surface Height Checks failed, Select an option below";
            surfaceCard.StepModalData !.IsError      = true;
            cards.Add(surfaceCard);

            randSize = new Random().Next(10, 24);
            for (int i = 0; i < randSize; i++)
            {
                int    randSteps = new Random().Next(1, 8);
                string stepTitle = titleArray[new Random().Next(titleArray.Length)];
                ICard  card      = _cardFactory.Create();
                card.StepTitle = stepTitle;
                for (int j = 0; j < randSteps; j++)
                {
                    card.CardSubSteps?.Add(_cardSubStepFactory.Create(stepTitle + " " + (j + 1).ToString(), RandomCoordinates()));
                }

                if (new Random().Next(0, 4) == 1)
                {
                    card.StepImage = ChooseRandomImage();
                }

                if (stepTitle == "Part Presence Check")
                {
                    card.StepModalData                = _modalService.CreateModalData();
                    card.StepModalData !.CanAbort     = true;
                    card.StepModalData !.CanContinue  = true;
                    card.StepModalData !.CanRetry     = true;
                    card.StepModalData !.Card         = null;
                    card.StepModalData !.Instructions = "Part Presence Check failed, Select an option below";
                    card.StepModalData !.IsError      = true;
                }

                cards.Add(card);
            }

            return(cards);
        }