예제 #1
0
        public async Task StartGameAsync(Func <BuncoDiceGameSaveInfo, bool, DiceCup <SimpleDice> > loadCup)
        {
            if (await _thisState.CanOpenSavedSinglePlayerGameAsync() == true)
            {
                await ReloadGameAsync(loadCup);

                return;
            }
            _saveRoot            = _container.Resolve <BuncoDiceGameSaveInfo>();
            _saveRoot.PlayOrder  = (PlayOrderClass)_container.Resolve <IPlayOrder>(); //has to be here so they both use the same object.
            _saveRoot.PlayerList = new PlayerCollection <PlayerItem>();
            _saveRoot.PlayerList.LoadPlayers(1, 11);
            _saveRoot.PlayerList.FinishLoading(); //i think we will go ahead and shuffle the players.
            _saveRoot.PlayerList.ForEach(singleInfo =>
            {
                singleInfo.Buncos        = 0;
                singleInfo.Wins          = 0;
                singleInfo.Losses        = 0;
                singleInfo.PlayerNum     = -1;
                singleInfo.Points        = 0;
                singleInfo.WinDetermined = false;
                singleInfo.Acceptable    = false;
                singleInfo.PreviousMate  = -1;
                singleInfo.Team          = 0;
                singleInfo.Table         = 0;
                singleInfo.WonPrevious   = false;
            });
            _saveRoot.WhatSet          = 1;
            _saveRoot.WhatNumber       = 1;
            _saveRoot.ThisStats.Status = "Game In Progress";
            _cup = loadCup.Invoke(_saveRoot, false);
            await Aggregator.SendLoadAsync();

            await StartRoundAsync();
        }
예제 #2
0
        Task IHandleAsync <LoadEventModel> .HandleAsync(LoadEventModel message)
        {
            BuncoDiceGameSaveInfo      thisSave = cons !.Resolve <BuncoDiceGameSaveInfo>();
            BuncoDiceGameMainViewModel mod      = (BuncoDiceGameMainViewModel)DataContext;

            _thisInfo !.DataContext = thisSave.ThisStats;
            _thisScore !.LoadLists(thisSave.PlayerList);
            _thisDice !.LoadDiceViewModel(mod.ThisCup !);
            return(this.RefreshBindingsAsync(_aggregator));
        }
예제 #3
0
        private async Task ReloadGameAsync(Func <BuncoDiceGameSaveInfo, bool, DiceCup <SimpleDice> > loadCup)
        {
            _saveRoot = await _thisState.RetrieveSinglePlayerGameAsync <BuncoDiceGameSaveInfo>();

            _container.ReplaceObject(_saveRoot);                     //this is now the new object.
            _saveRoot.PlayerList.MainContainer = _container;         //has to redo that part.
            _saveRoot.PlayerList.AutoSaved(_saveRoot !.PlayOrder !); //i think this is needed too.
            _cup = loadCup.Invoke(_saveRoot, true);
            await Aggregator.SendLoadAsync();                        //still needed.

            await NewTurnAsync();
        }
예제 #4
0
 public BuncoDiceGameMainGameClass(ISaveSinglePlayerClass thisState,
                                   IEventAggregator aggregator,
                                   IGamePackageResolver container,
                                   RandomGenerator rs,
                                   CommandContainer command,
                                   GlobalClass global
                                   )
 {
     _thisState = thisState;
     Aggregator = aggregator;
     _container = container;
     _rs        = rs;
     _command   = command;
     _global    = global;
     _saveRoot  = container.ReplaceObject <BuncoDiceGameSaveInfo>(); //can't create new one.  because if doing that, then anything that needs it won't have it.
 }
 private DiceCup <SimpleDice> GetLoadedCup(BuncoDiceGameSaveInfo saveRoot, bool autoResume)
 {
     _saveroot = saveRoot; //hopefully this simple (?)
     if (ThisCup != null)
     {
         return(ThisCup);
     }
     ThisCup                    = new DiceCup <SimpleDice>(saveRoot.DiceList, _resolver, CommandContainer);
     ThisCup.HowManyDice        = 3;
     ThisCup.ShowDiceListAlways = true;
     if (autoResume)
     {
         ThisCup.ClearDice();
     }
     else
     {
         ThisCup.CanShowDice = true;
     }
     return(ThisCup);
 }