async Task IHandleAsync <NextScreenEventModel> .HandleAsync(NextScreenEventModel message)
        {
            await CloseStartingScreensAsync();

            switch (message.Screen)
            {
            case BeginningClasses.EnumNextScreen.Advanced:
                AdvancedScreen = MainContainer.Resolve <AdvancedOptionsViewModel>();
                await LoadScreenAsync(AdvancedScreen);

                break;

            case BeginningClasses.EnumNextScreen.Cards:
                CardsScreen = MainContainer.Resolve <CardsPlayerViewModel>();
                await LoadScreenAsync(CardsScreen);

                break;

            case BeginningClasses.EnumNextScreen.Finished:
                await StartNewGameAsync();     //hopefully this simple.

                //if there is anything else that has to happen at this stage, this can do it.
                break;

            default:
                throw new BasicBlankException("Next screen not supported");
            }
        }
Пример #2
0
        private async Task LoadGameScreenAsync()
        {
            if (_mainGame == null)
            {
                _mainGame = MainContainer.Resolve <IBasicGameProcesses <P> >();
            }
            if (_mainGame.CanMakeMainOptionsVisibleAtBeginning)
            {
                ClearSubscriptions(); //try this too.
                await StartNewGameAsync();

                if (_test.AlwaysNewGame)
                {
                    NewGameScreen = MainContainer.Resolve <INewGameVM>();
                    await LoadScreenAsync(NewGameScreen);
                }
                return;
            }


            //only host or single player game gets to this part.
            await GetStartingScreenAsync();

            if (_test.AlwaysNewGame)
            {
                NewGameScreen = MainContainer.Resolve <INewGameVM>();
                await LoadScreenAsync(NewGameScreen);
            }
        }
        private int BonusPoints(RackoPlayerItem thisPlayer)
        {
            RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> thisInfo = new RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation>();

            thisInfo.HasSecond = false;
            thisInfo.HasWild   = false;
            thisInfo.NeedMatch = false; //try this too.
            thisInfo.LowNumber = 1;
            RackoDeckCount temps = MainContainer.Resolve <RackoDeckCount>();

            thisInfo.HighNumber = temps.GetDeckCount();
            DeckRegularDict <RackoCardInformation> tempCol = thisPlayer.MainHandList.ToRegularDeckDict();
            var newColls = thisInfo.WhatNewRummy(tempCol, 6, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true);

            if (newColls.Count > 0)
            {
                return(400);
            }
            newColls = thisInfo.WhatNewRummy(tempCol, 5, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true);
            if (newColls.Count > 0)
            {
                return(200);
            }
            newColls = thisInfo.WhatNewRummy(tempCol, 4, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true);
            if (newColls.Count > 0)
            {
                return(100);
            }
            newColls = thisInfo.WhatNewRummy(tempCol, 3, RummyProcesses <EnumSuitList, EnumSuitList, RackoCardInformation> .EnumRummyType.Runs, true);
            if (newColls.Count > 0)
            {
                return(50);
            }
            return(0);
        }
Пример #4
0
        async Task IHandleAsync <RestoreEventModel> .HandleAsync(RestoreEventModel message)
        {
            await RestoreAsync();

            IRestoreMultiPlayerGame restore = MainContainer.Resolve <IRestoreMultiPlayerGame>();
            await restore.RestoreGameAsync();
        }
Пример #5
0
        async Task IRestoreNM.RestoreMessageAsync(string payLoad)
        {
            await RestoreAsync();

            IClientUpdateGame client = MainContainer.Resolve <IClientUpdateGame>();
            await client.UpdateGameAsync(payLoad);
        }
        public override async Task SetUpGameAsync(bool isBeginning)
        {
            LoadControls();
            if (FinishUpAsync == null)
            {
                throw new BasicBlankException("The loader never set the finish up code.  Rethink");
            }

            if (BasicData.MultiPlayer == false)
            {
                SaveRoot.Level = EnumLevel.Hard;
                IShuffleTiles tiles = MainContainer.Resolve <IShuffleTiles>();
                await tiles.StartShufflingAsync(this);
            }
            else
            {
                SaveRoot.Level    = EnumLevel.None;
                SaveRoot.CanStart = false;
                _model.PlayerWon  = "";
                await LoadStartOptionsAsync();
            }
            //hopefully will be this simple this time (?)

            await FinishUpAsync(isBeginning);
        }
Пример #7
0
        protected override Task PrepNewGameAsync()
        {
            IEraseColors erase = MainContainer.Resolve <IEraseColors>();

            erase.EraseColors();
            return(Task.CompletedTask);
        }
        //the old screens should be closed first before this runs.

        //private async Task GetNextScreenAsync()
        //{
        //    //this should figure out the first screen or future screens.  in this case, this works well.
        //    ThreeLetterFunSaveInfo saveroot = MainContainer.Resolve<ThreeLetterFunSaveInfo>();

        //    if (saveroot.CanStart)
        //    {
        //        //this will load the main screen now.
        //        await StartNewGameAsync();
        //        return; //hopefully other rethinking is not required.  if so, do rethink.
        //    }

        //    if (saveroot.Level == EnumLevel.None)
        //    {
        //        //this means needs to load the first screen.  you have to first choose level.
        //        FirstScreen = MainContainer.Resolve<FirstOptionViewModel>();
        //        await LoadScreenAsync(FirstScreen);
        //        return;
        //    }
        //}


        //decided that to begin with, if you close out before choosing options, you start over again.
        //otherwise, a person would have to remember what they chose previously.
        protected override async Task GetStartingScreenAsync()
        {
            //await GetNextScreenAsync();

            FirstScreen = MainContainer.Resolve <FirstOptionViewModel>();
            await LoadScreenAsync(FirstScreen);
        }
        private async Task LoadActionScreenAsync(ActionContainer actionContainer)
        {
            if (ActionScreen != null)
            {
                throw new BasicBlankException("Previous action was not loaded.  Rethink");
            }
            await CloseMainAsync();
            await CloseKeeperScreenAsync();

            //much harder to figure out which screen to load.
            switch (actionContainer.ActionCategory)
            {
            case EnumActionCategory.None:
                break;

            case EnumActionCategory.Rules:
                break;

            case EnumActionCategory.Directions:
                break;

            case EnumActionCategory.DoAgain:
                break;

            case EnumActionCategory.TradeHands:
                break;

            case EnumActionCategory.UseTake:
                break;

            case EnumActionCategory.Everybody1:
                break;

            case EnumActionCategory.DrawUse:
                break;

            case EnumActionCategory.FirstRandom:
                break;

            default:
                break;
            }

            ActionScreen = actionContainer.ActionCategory switch
            {
                EnumActionCategory.Rules => MainContainer.Resolve <ActionDiscardRulesViewModel>(),
                EnumActionCategory.Directions => MainContainer.Resolve <ActionDirectionViewModel>(),
                EnumActionCategory.DoAgain => MainContainer.Resolve <ActionDoAgainViewModel>(),
                EnumActionCategory.DrawUse => MainContainer.Resolve <ActionDrawUseViewModel>(),
                EnumActionCategory.Everybody1 => MainContainer.Resolve <ActionEverybodyGetsOneViewModel>(),
                EnumActionCategory.FirstRandom => MainContainer.Resolve <ActionFirstCardRandomViewModel>(),
                EnumActionCategory.TradeHands => MainContainer.Resolve <ActionTradeHandsViewModel>(),
                EnumActionCategory.UseTake => MainContainer.Resolve <ActionTakeUseViewModel>(),
                _ => throw new BasicBlankException("Cannot figure out action screen.  Rethink")
            };
            await LoadScreenAsync(ActionScreen);

            RefreshEnables();
        }
Пример #10
0
        async Task IHandleAsync <StartAutoresumeMultiplayerGameEventModel> .HandleAsync(StartAutoresumeMultiplayerGameEventModel message)
        {
            await CloseOpenScreenAsync("Start autoresume multiplayer game");

            //await LoadGameScreenAsync(); //forgot here too.
            IStartMultiPlayerGame <P> starts = MainContainer.Resolve <IStartMultiPlayerGame <P> >();
            await starts.LoadSavedGameAsync();
        }
        protected override async Task OpenStartingScreensAsync()
        {
            OpeningScreen = MainContainer.Resolve <SpiderSolitaireOpeningViewModel>(); //i think has to be this way so its fresh everytime.
            await LoadScreenAsync(OpeningScreen);                                      //try this way.
            await ShowNewGameAsync();

            FinishInit();
        }
Пример #12
0
        async Task IHandleAsync <StartMultiplayerGameEventModel <P> > .HandleAsync(StartMultiplayerGameEventModel <P> message)
        {
            await CloseOpenScreenAsync("Start new multiplayer game");

            //await LoadGameScreenAsync(); //forgot here too.
            IStartMultiPlayerGame <P> starts = MainContainer.Resolve <IStartMultiPlayerGame <P> >();
            await starts.LoadNewGameAsync(message.PlayerList);
        }
Пример #13
0
        //private static async Task<bool> TryActivateItemAsync(object parentViewModel, IUIView? parentViewScreen, object childViewModel)
        //{
        //    if (UIPlatform.ViewLocator is null)
        //        return false;
        //    if (UIPlatform.ScreenLoader is null)
        //        return false;


        //    IUIView childview = await UIPlatform.ViewLocator.LocateViewAsync(childViewModel)!;
        //    if (childview == null)
        //        throw new BasicBlankException("No view was found when trying to active an item.  Rethink");
        //    if (parentViewScreen == null)
        //        throw new BasicBlankException("Has to have an active view in order to activate another screen");
        //    //we need a method that will do the rest of what is needed.  probably another interface.
        //    await UIPlatform.ScreenLoader.LoadScreenAsync(parentViewModel, parentViewScreen, childViewModel, childview);
        //    if (childViewModel is IScreen screens)
        //    {
        //        if (parentViewModel is IHaveActiveViewModel active)
        //            active.ActiveViewModel = screens;
        //        await screens.ActivateAsync(childview);
        //    }
        //    else
        //    {
        //        await childview.TryActivateAsync(); //to do extra things whatever is needed that is actually async.
        //        //should not activate twice.
        //    }

        //    return true;
        //}


        //private async Task ExperimentAsync(object vm)
        //{
        //    //this time, has to do lots of copy/paste to see what the problem is this time.
        //    //return ConductorBehavior.TryActivateItemAsync(this, MainScreen, viewModel!);
        //    await TryActivateItemAsync(this, MainScreen, vm);
        //}

        protected async Task ShowNewGameAsync()
        {
            NewGameVM = MainContainer.Resolve <INewGameVM>();

            //await ExperimentAsync(NewGameVM);

            await LoadScreenAsync(NewGameVM);
        }
Пример #14
0
        protected async Task ShowNewGameAsync()
        {
            NewGameScreen = MainContainer.Resolve <INewGameVM>();
            await LoadScreenAsync(NewGameScreen);

            CommandContainer.IsExecuting  = true;
            CommandContainer.ManuelFinish = true;
        }
 private void LoadControls()
 {
     if (IsLoaded == true)
     {
         return;
     }
     _graphics = MainContainer.Resolve <TicTacToeGraphicsCP>();
     IsLoaded  = true; //i think needs to be here.
 }
Пример #16
0
 Task IHandleAsync <NewRoundEventModel> .HandleAsync(NewRoundEventModel message)
 {
     if (TempScreen != null)
     {
         throw new BasicBlankException("The screen was never closed out.  Rethink");
     }
     TempScreen = MainContainer.Resolve <BuncoNewRoundViewModel>();
     return(LoadScreenAsync(TempScreen));
 }
Пример #17
0
 private async Task LoadBidAsync()
 {
     if (BidScreen != null)
     {
         await CloseSpecificChildAsync(BidScreen);
     }
     BidScreen = MainContainer.Resolve <PickelBidViewModel>();
     await LoadScreenAsync(BidScreen);
 }
Пример #18
0
 private async Task LoadGenderAsync()
 {
     if (GenderScreen != null)
     {
         throw new BasicBlankException("Cannot load gender because its already there.  Rethink");
     }
     GenderScreen = MainContainer.Resolve <ChooseGenderViewModel>();
     await LoadScreenAsync(GenderScreen);
 }
Пример #19
0
        //still needs to be able to override it.
        //so for game of life, has the option for another screen.
        protected override async Task GetStartingScreenAsync()
        {
            if (ColorScreen != null)
            {
                await CloseSpecificChildAsync(ColorScreen);
            }

            ColorScreen = MainContainer.Resolve <IBeginningColorViewModel>();
            await LoadScreenAsync(ColorScreen);
        }
Пример #20
0
        async Task INewGameNM.NewGameReceivedAsync(string data)
        {
            if (OpeningScreen != null)
            {
                throw new BasicBlankException("The opening screen should have been closed.  Rethink");
            }
            await RestoreAsync(); //take a risk here.

            IClientUpdateGame clientUpdate = MainContainer.Resolve <IClientUpdateGame>();
            await clientUpdate.UpdateGameAsync(data);
        }
 private void LoadControls()
 {
     if (IsLoaded == true)
     {
         return;
     }
     ScoreSheets = MainContainer.Resolve <BowlingScoresCP>();
     DiceBoard   = MainContainer.Resolve <BowlingDiceSet>();
     DiceBoard.FirstLoad(); //forgot this.
     IsLoaded = true;       //i think needs to be here.
 }
Пример #22
0
        async Task IHandleAsync <RoundOverEventModel> .HandleAsync(RoundOverEventModel message)
        {
            NewRoundScreen = MainContainer.Resolve <INewRoundVM>();
            await LoadScreenAsync(NewRoundScreen);

            CommandContainer.ManuelFinish = true;
            CommandContainer.IsExecuting  = true;
            //i think this may be it (?)
            //CommandContainer.ManuelFinish = false;
            //CommandContainer.IsExecuting = false;
        }
        public async Task LoadBidScreenAsync()
        {
            if (BidScreen != null)
            {
                return;
            }
            await CloseMainAsync("Already closed main to load bidding.  Rethink");

            BidScreen = MainContainer.Resolve <RageBiddingViewModel>();
            await LoadScreenAsync(BidScreen);
        }
 private void SetObjects()
 {
     if (_deckInfo != null)
     {
         return;
     }
     PopulateContainer(this);
     _deckInfo   = MainContainer !.Resolve <ThreeLetterFunDeckInfo>(); //need the full one.
     _thisGlobal = MainContainer.Resolve <GlobalHelpers>();
     _mainGame   = MainContainer.Resolve <ThreeLetterFunMainGameClass>();
 }
        public async Task LoadColorScreenAsync()
        {
            if (ColorScreen != null)
            {
                return;
            }
            await CloseMainAsync("Already closed main to load colors.  Rethink");

            ColorScreen = MainContainer.Resolve <RageColorViewModel>();
            await LoadScreenAsync(ColorScreen);
        }
        private async Task LoadMainGameAsync()
        {
            if (FaceoffScreen == null)
            {
                throw new BasicBlankException("Faceoff should have been loaded first.  Rethink");
            }
            await CloseSpecificChildAsync(FaceoffScreen);

            FaceoffScreen = null;
            MainVM        = MainContainer.Resolve <BladesOfSteelMainViewModel>();
            await LoadScreenAsync(MainVM);
        }
Пример #27
0
        private async Task LoadMainScreenAsync()
        {
            if (FirstScreen == null)
            {
                return; //because main screen is already loaded.
            }
            await CloseSpecificChildAsync(FirstScreen);

            FirstScreen = null;
            MainVM      = MainContainer.Resolve <GolfCardGameMainViewModel>();
            await LoadScreenAsync(MainVM);
        }
Пример #28
0
        protected override async Task GetStartingScreenAsync()
        {
            LifeBoardGameSaveInfo saveRoot = MainContainer.Resolve <LifeBoardGameSaveInfo>();

            if (saveRoot.GameStatus == EnumWhatStatus.NeedChooseGender)
            {
                await LoadGenderAsync();

                return;
            }
            await base.GetStartingScreenAsync();
        }
Пример #29
0
 public int GetDeckCount()
 {
     if (_deckCount == null)
     {
         PopulateContainer(this);
         _deckCount = MainContainer !.Resolve <IDeckCount>(); //i think
         if (MainContainer.RegistrationExist <INewCard <D> >())
         {
             _newCard = MainContainer.Resolve <INewCard <D> >();
         }
     }
     return(_deckCount.GetDeckCount());
 }
Пример #30
0
        async Task IHandleAsync <NewRoundEventModel> .HandleAsync(NewRoundEventModel message)
        {
            ClearSubscriptions();
            await CloseMainAsync("The main screen should have been not null when choosing new round.  Rethink");
            await CloseRoundAsync();
            await NewGameOrRoundRequestedAsync();

            //await LoadGameScreenAsync();
            IRequestNewGameRound gameRound = MainContainer.Resolve <IRequestNewGameRound>();
            await gameRound.RequestNewRoundAsync();

            //hint:  either another message or somebody else would send the same message for the client.
        }