public CousinRummyMainViewModel(CommandContainer commandContainer,
                                        CousinRummyMainGameClass mainGame,
                                        CousinRummyVMData viewModel,
                                        BasicData basicData,
                                        TestOptions test,
                                        IGamePackageResolver resolver,
                                        CousinRummyGameContainer gameContainer
                                        )
            : base(commandContainer, mainGame, viewModel, basicData, test, resolver)
        {
            _mainGame      = mainGame;
            _model         = viewModel;
            _gameContainer = gameContainer;
            _model.Deck1.NeverAutoDisable = false;
            _model.PlayerHand1.AutoSelect = HandObservable <RegularRummyCard> .EnumAutoType.SelectAsMany;
            var player = _mainGame.PlayerList.GetSelf();

            mainGame.Aggregator.Subscribe(player); //hopefully this works now.
            _model.TempSets.Init(this);
            _model.TempSets.ClearBoard();          //try this too.
            _model.TempSets.SetClickedAsync += TempSets_SetClickedAsync;
            _model.MainSets.SetClickedAsync += MainSets_SetClickedAsync;
            _model.MainSets.SendEnableProcesses(this, () =>
            {
                if (_mainGame !.OtherTurn > 0)
                {
                    return(false);
                }
                return(_mainGame.SingleInfo !.LaidDown);
            });
Exemple #2
0
 public CousinRummyMainGameClass(IGamePackageResolver mainContainer,
                                 IEventAggregator aggregator,
                                 BasicData basicData,
                                 TestOptions test,
                                 CousinRummyVMData currentMod,
                                 IMultiplayerSaveState state,
                                 IAsyncDelayer delay,
                                 ICardInfo <RegularRummyCard> cardInfo,
                                 CommandContainer command,
                                 CousinRummyGameContainer gameContainer)
     : base(mainContainer, aggregator, basicData, test, currentMod, state, delay, cardInfo, command, gameContainer)
 {
     _model                     = currentMod;
     _command                   = command;
     _gameContainer             = gameContainer;
     _gameContainer.ModifyCards = ModifyCards;
     _rummys                    = new RummyProcesses <EnumSuitList, EnumColorList, RegularRummyCard>();
 }
Exemple #3
0
        public CousinRummyMainView(IEventAggregator aggregator,
                                   TestOptions test,
                                   CousinRummyVMData model
                                   )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckXF <RegularRummyCard, ts, DeckOfCardsXF <RegularRummyCard> >();
            _discardGPile  = new BasePileXF <RegularRummyCard, ts, DeckOfCardsXF <RegularRummyCard> >();
            _score         = new ScoreBoardXF();
            _playerHandWPF = new BaseHandXF <RegularRummyCard, ts, DeckOfCardsXF <RegularRummyCard> >();
            _tempG         = new TempRummySetsXF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsXF <RegularRummyCard> >();
            _mainG         = new MainRummySetsXF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsXF <RegularRummyCard>, PhaseSet, SavedSet>();

            ParentSingleUIContainer?restoreP = null;

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

            Grid buyGrid = new Grid();

            AddAutoColumns(buyGrid, 2);
            AddAutoRows(buyGrid, 1);
            AddPixelRow(buyGrid, 100);
            var button = GetSmallerButton("Pass", nameof(CousinRummyMainViewModel.PassAsync));

            AddControlToGrid(buyGrid, button, 0, 0);
            button = GetSmallerButton("Buy", nameof(CousinRummyMainViewModel.BuyAsync));
            AddControlToGrid(buyGrid, button, 0, 1);
            AddControlToGrid(buyGrid, _deckGPile, 1, 0);
            AddControlToGrid(buyGrid, _discardGPile, 1, 1);

            Grid gameGrid = new Grid();

            AddLeftOverRow(gameGrid, 45); // try that
            AddAutoRows(gameGrid, 1);
            AddLeftOverRow(gameGrid, 30);
            var otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_tempG);
            AddControlToGrid(gameGrid, otherStack, 0, 0);

            _score.AddColumn("Cards Left", false, nameof(CousinRummyPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Tokens Left", false, nameof(CousinRummyPlayerItem.TokensLeft));
            _score.AddColumn("Current Score", false, nameof(CousinRummyPlayerItem.CurrentScore), rightMargin: 5);
            _score.AddColumn("Total Score", false, nameof(CousinRummyPlayerItem.TotalScore));
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Normal Turn", nameof(CousinRummyMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(CousinRummyMainViewModel.Status));
            firstInfo.AddRow("Other Turn", nameof(CousinRummyMainViewModel.OtherLabel));
            firstInfo.AddRow("Phase", nameof(CousinRummyMainViewModel.PhaseData));


            otherStack.Children.Add(_score);
            Grid bottomGrid = new Grid();

            AddLeftOverColumn(bottomGrid, 30);
            AddLeftOverColumn(bottomGrid, 70);
            otherStack = new StackLayout();
            button     = GetSmallerButton("Lay Down Initial Sets", nameof(CousinRummyMainViewModel.FirstSetsAsync));
            otherStack.Children.Add(button);
            button = GetSmallerButton("Lay Down Other Sets", nameof(CousinRummyMainViewModel.OtherSetsAsync)); // i think its othersets commands (?)
            otherStack.Children.Add(button);

            if (restoreP != null)
            {
                otherStack.Children.Add(restoreP); //default add to grid but does not have to.
            }

            AddControlToGrid(bottomGrid, otherStack, 0, 0);
            AddControlToGrid(bottomGrid, _mainG, 0, 1);
            AddControlToGrid(gameGrid, bottomGrid, 2, 0);
            otherStack                       = new StackLayout();
            otherStack.Orientation           = StackOrientation.Horizontal;
            _playerHandWPF.HorizontalOptions = LayoutOptions.StartAndExpand;
            otherStack.Children.Add(buyGrid);
            StackLayout tempStack = new StackLayout();

            tempStack.Children.Add(_playerHandWPF);
            tempStack.Children.Add(firstInfo.GetContent);
            otherStack.Children.Add(tempStack);
            AddControlToGrid(gameGrid, otherStack, 1, 0);

            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);


            Content = gameGrid;
        }
Exemple #4
0
        public CousinRummyMainView(IEventAggregator aggregator,
                                   TestOptions test,
                                   CousinRummyVMData model
                                   )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);

            _deckGPile     = new BaseDeckWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _discardGPile  = new BasePileWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _score         = new ScoreBoardWPF();
            _playerHandWPF = new BaseHandWPF <RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();

            _tempG = new TempRummySetsWPF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard> >();
            _mainG = new MainRummySetsWPF <EnumSuitList, EnumColorList, RegularRummyCard, ts, DeckOfCardsWPF <RegularRummyCard>, PhaseSet, SavedSet>();


            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

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

            Grid buyGrid = new Grid();

            AddAutoColumns(buyGrid, 2);
            AddAutoRows(buyGrid, 2);
            Button button;

            button = GetGamingButton("Pass", nameof(CousinRummyMainViewModel.PassAsync));
            AddControlToGrid(buyGrid, button, 0, 0);
            button = GetGamingButton("Buy", nameof(CousinRummyMainViewModel.BuyAsync));
            AddControlToGrid(buyGrid, button, 0, 1);
            Grid gameGrid = new Grid();

            AddLeftOverColumn(gameGrid, 1); // try that
            AddAutoColumns(gameGrid, 1);
            AddAutoRows(gameGrid, 1);
            AddPixelRow(gameGrid, 450);
            _deckGPile.HorizontalAlignment = HorizontalAlignment.Left;
            _deckGPile.VerticalAlignment   = VerticalAlignment.Top;
            AddControlToGrid(buyGrid, _deckGPile, 1, 0);
            _discardGPile.HorizontalAlignment = HorizontalAlignment.Left;
            _discardGPile.VerticalAlignment   = VerticalAlignment.Top;
            AddControlToGrid(buyGrid, _discardGPile, 1, 1);
            StackPanel otherStack = new StackPanel();

            otherStack.Children.Add(_playerHandWPF);
            button = GetGamingButton("Lay Down Initial Sets", nameof(CousinRummyMainViewModel.FirstSetsAsync));
            otherStack.Children.Add(button);
            button = GetGamingButton("Lay Down Other Sets", nameof(CousinRummyMainViewModel.OtherSetsAsync)); // i think its othersets commands (?)
            otherStack.Children.Add(button);
            AddControlToGrid(gameGrid, otherStack, 0, 0);
            _tempG.Height = 400;
            AddControlToGrid(gameGrid, _tempG, 0, 1);
            AddControlToGrid(gameGrid, _mainG, 1, 0);
            Grid.SetColumnSpan(_mainG, 2);
            _score.AddColumn("Cards Left", false, nameof(CousinRummyPlayerItem.ObjectCount)); //very common.
            _score.AddColumn("Tokens Left", false, nameof(CousinRummyPlayerItem.TokensLeft));
            _score.AddColumn("Current Score", false, nameof(CousinRummyPlayerItem.CurrentScore), rightMargin: 5);
            _score.AddColumn("Total Score", false, nameof(CousinRummyPlayerItem.TotalScore));
            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Normal Turn", nameof(CousinRummyMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(CousinRummyMainViewModel.Status));
            firstInfo.AddRow("Other Turn", nameof(CousinRummyMainViewModel.OtherLabel));
            firstInfo.AddRow("Phase", nameof(CousinRummyMainViewModel.PhaseData));
            var tempStack = new StackPanel();

            tempStack.Orientation = Orientation.Horizontal;
            tempStack.Children.Add(_score);
            tempStack.Children.Add(buyGrid);
            tempStack.Children.Add(firstInfo.GetContent);
            otherStack.Children.Add(tempStack);
            mainStack.Children.Add(gameGrid);



            _deckGPile.Margin = new Thickness(5, 5, 5, 5);

            _discardGPile.Margin = new Thickness(5, 5, 5, 5);


            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;
        }