示例#1
0
        public static int CardToTry(ConcentrationMainGameClass mainGame, ConcentrationVMData model)
        {
            DeckRegularDict <RegularSimpleCard> computerList = mainGame.SaveRoot !.ComputerList;
            DeckRegularDict <RegularSimpleCard> output;

            if (computerList.Count == 0)
            {
                output = model.GameBoard1 !.CardsLeft();
                return(output.GetRandomItem().Deck);
            }
            output = PairToTry(computerList);
            if (output.Count == 0)
            {
                output = model.GameBoard1 !.CardsLeft();
                return(output.GetRandomItem().Deck);
            }

            bool rets1 = model.GameBoard1 !.WasSelected(output.First().Deck);
            bool rets2 = model.GameBoard1.WasSelected(output.Last().Deck);

            if (rets1 == true && rets2 == true)
            {
                throw new BasicBlankException("Both items cannot be selected");
            }
            if (rets1 == true)
            {
                return(output.Last().Deck);
            }
            return(output.First().Deck);
        }
示例#2
0
 public ConcentrationMainViewModel(CommandContainer commandContainer,
                                   ConcentrationMainGameClass mainGame,
                                   ConcentrationVMData viewModel,
                                   BasicData basicData,
                                   TestOptions test,
                                   IGamePackageResolver resolver) : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
 {
     _mainGame = mainGame;
     _model    = viewModel;
     viewModel.Deck1.NeverAutoDisable       = true;
     viewModel.GameBoard1.PileClickedAsync += GameBoard1_PileClickedAsync;
 }
        private readonly CommandContainer _command; //most of the time, needs this.  if not needed, take out.

        public ConcentrationMainGameClass(IGamePackageResolver mainContainer,
                                          IEventAggregator aggregator,
                                          BasicData basicData,
                                          TestOptions test,
                                          ConcentrationVMData currentMod,
                                          IMultiplayerSaveState state,
                                          IAsyncDelayer delay,
                                          ICardInfo <RegularSimpleCard> cardInfo,
                                          CommandContainer command,
                                          ConcentrationGameContainer gameContainer)
            : base(mainContainer, aggregator, basicData, test, currentMod, state, delay, cardInfo, command, gameContainer)
        {
            _model   = currentMod;
            _command = command;
        }
        public ConcentrationMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     ConcentrationVMData model
                                     )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _score = new ScoreBoardWPF();
            _board = new BasicMultiplePilesWPF <RegularSimpleCard, ts, DeckOfCardsWPF <RegularSimpleCard> >();
            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(ConcentrationMainViewModel.RestoreScreen)
                };
            }


            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_board);
            mainStack.Children.Add(otherStack);
            _score.AddColumn("Pairs", true, nameof(ConcentrationPlayerItem.Pairs)); //very common.
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(ConcentrationMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(ConcentrationMainViewModel.Status));

            StackPanel finalStack = new StackPanel();

            otherStack.Children.Add(finalStack);
            finalStack.Children.Add(firstInfo.GetContent);
            finalStack.Children.Add(_score);
            if (restoreP != null)
            {
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
        public ConcentrationMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     ConcentrationVMData model
                                     )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            _board = new BasicMultiplePilesXF <RegularSimpleCard, ts, DeckOfCardsXF <RegularSimpleCard> >();
            _score = new ScoreBoardXF();
            _score.AddColumn("Pairs", true, nameof(ConcentrationPlayerItem.Pairs)); //very common.
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(ConcentrationMainViewModel.RestoreScreen));
            }

            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_board);
            mainStack.Children.Add(otherStack);
            _score.AddColumn("Cards Left", false, nameof(ConcentrationPlayerItem.ObjectCount)); //very common.
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(ConcentrationMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(ConcentrationMainViewModel.Status));

            StackLayout finalStack = new StackLayout();

            otherStack.Children.Add(finalStack);
            finalStack.Children.Add(firstInfo.GetContent);
            finalStack.Children.Add(_score);

            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }