public void ResetScores()
 {
     if (_tempList.Count == 0)
     {
         return; //already done.
     }
     _tempList.Clear();
     ScoreList.Clear();
     OnPropertyChanged(nameof(TotalScore));
 }
 public void ClearPiles()
 {
     _previouslyPlayed.Clear();
     CardPiles.ClearBoard();
     SafetyList.Clear();
     CurrentCard   = null;
     HowMany200S   = 0;
     Miles         = 0;
     Wrongs        = 0;
     CurrentHazard = EnumHazardType.None;
     CurrentSpeed  = false;
     Update200Data();
 }
 public CheckersChessBaseBoard(IGamePackageResolver mainContainer, CommandContainer command) : base(mainContainer)
 {
     _thisGame = GetGame();
     PrivateSpaceList.Clear(); //try this too.
     if ((int)_thisGame == (int)EnumGame.Chess)
     {
         OriginalSize = new SKSize(320, 320); // will be 40 by 40 for each space
     }
     else
     {
         OriginalSize = new SKSize(500, 500);// can experiment.
     }
     _command = command;
 }
        Task IHandleAsync <LoadEventModel> .HandleAsync(LoadEventModel message)
        {
            if (_didLoad)
            {
                return(Task.CompletedTask);
            }
            GamePackageViewModelBinder.ManuelElements.Clear(); //often times i have to add manually.
            _boardList.Clear();
            _diceControl !.LoadDiceViewModel(_model.Cup !);

            _didLoad = true;
            _playerStack.Orientation = Orientation.Horizontal;
            _playerStack.Margin      = new Thickness(5, 5, 5, 5);
            //self goes on top.
            //however, if its pass and play, then 1 then 2.
            CountdownPlayerItem player;

            if (_gameContainer.BasicData.MultiPlayer == false)
            {
                player = _gameContainer.PlayerList ![1];
        Task IHandleAsync <LoadEventModel> .HandleAsync(LoadEventModel message)
        {
            GamePackageViewModelBinder.ManuelElements.Clear();                   //often times i have to add manually.

            MillebournesSaveInfo save = cons !.Resolve <MillebournesSaveInfo>(); //usually needs this part for multiplayer games.

            _score !.LoadLists(save.PlayerList);
            _playerHandWPF !.LoadList(_model.PlayerHand1 !, ""); // i think
            _discardGPile !.Init(_model.Pile2 !, "");            // may have to be here (well see)
            _discardGPile.StartListeningDiscardPile();           // its the main one.

            _deckGPile !.Init(_model.Deck1 !, "");               // try here.  may have to do something else as well (?)
            _deckGPile.StartListeningMainDeck();

            _newCard !.Init(_model.Pile1 !, "");
            _disList.ForEach(thisD => thisD.Unregister());
            _disList.Clear();
            SetUpTeamPiles();


            return(this.RefreshBindingsAsync(_aggregator));
        }
示例#6
0
        //will attempt without the manuel feature.  if we need the manuel feature back, will do.



        //attempt to copy/paste from wpf and make necessary changes.  taking lots of risks here.
        /// <summary>
        /// this is the process that needs to hook up the proper parent control
        /// not only to add to proper control
        /// but also to hook up to parent container so it can be removed later.
        /// </summary>
        /// <param name="parentViewModel"></param>
        /// <param name="parentViewScreen"></param>
        /// <param name="childViewModel"></param>
        public static void HookParentContainers(object parentViewModel, BindableObject parentViewScreen, IScreen childViewModel, IUIView childViewScreen)
        {
            //if (StopRun)
            //{
            //    return;
            //}
            //CustomBasicList<FrameworkElement> controls = FindVisualChildren(parentViewScreen).ToCustomBasicList();
            //CustomBasicList<VisualElement> controls = new CustomBasicList<VisualElement>();

            //if (parentvi)

            //GetChildren(parentViewScreen); //hopefully this simple.

            _controls.Clear(); //i think.
            if (parentViewScreen is VisualElement vv)
            {
                GetChildren(vv);
            }
            if (_controls.Count == 0)
            {
                throw new BasicBlankException("No controls was found when trying to hook up parent to start with");
            }
            _controls.KeepConditionalItems(x =>
            {
                if (string.IsNullOrWhiteSpace(x.GetName()) == true)
                {
                    return(false);
                }
                Type type = x.GetType();
                if (typeof(IContentControl).IsAssignableFrom(type))
                {
                    return(true);
                }
                return(false);
            });


            if (_controls.Count == 0)
            {
                throw new BasicBlankException("There was no container controls");
            }



            Type type       = parentViewModel.GetType();
            var  properties = type.GetProperties().ToCustomBasicList();

            CustomBasicList <IContentControl> parents = new CustomBasicList <IContentControl>();
            bool isGuarantee = false;

            if (typeof(IConductorGuarantee).IsAssignableFrom(type))
            {
                isGuarantee = true;
            }


            //i think if there is no match, needs to raise exception for sure.
            foreach (var control in _controls)
            {
                var property = properties.Where(x => x.Name == control.GetName()).SingleOrDefault();
                if (property == null)
                {
                    throw new BasicBlankException($"Parent container with the name of {control.GetName()} could not be found.  Rethink");
                }
                IContentControl?fins = (IContentControl)control;
                if (fins == null)
                {
                    throw new BasicBlankException("Was not parent.  Rethink");
                }
                else
                if (isGuarantee)
                {
                    parents.Add(fins);
                }
                else
                {
                    object thisObj = property.GetValue(parentViewModel, null) !;
                    if (thisObj != null)
                    {
                        if (!(thisObj is IMainScreen))
                        {
                            string name = control.GetName();
                            throw new BasicBlankException($"The control with the name of {name} was wrong because the control did not implement IMainScreen");
                        }
                        Type testType  = thisObj.GetType();
                        Type childType = childViewModel.GetType();

                        if (testType.Name == childType.Name)
                        {
                            if (fins is ParentSingleUIContainer parent)
                            {
                                if (parent.Children.Count == 0)
                                {
                                    parents.Add(fins);
                                }
                            }
                            else
                            {
                                parents.Add(fins);
                            }
                        }
                    }

                    //object thisObj = property.GetValue(parentViewModel, null)!;
                    //if (thisObj != null)
                    //{
                    //    Type testType = thisObj.GetType();
                    //    Type childType = childViewModel.GetType();

                    //    if (testType.Name == childType.Name)
                    //        parents.Add(fins);

                    //}
                }
            }
            if (parents.Count == 0)
            {
                throw new BasicBlankException("There was no parent controls found for hooking up the child");
            }
            if (parents.Count == 1)
            {
                childViewModel.ParentContainer = parents.Single();
                childViewModel.ParentContainer.Add(childViewScreen);
            }
        }
示例#7
0
        public DeckRegularDict <MexicanDomino> GetTrainList(DeckObservableDict <MexicanDomino> piecesCollection, int givenNumber)
        {
            DeckRegularDict <MexicanDomino> output;
            Dictionary <int, MexicanDomino> matchingPieces = new Dictionary <int, MexicanDomino>();
            List <int> Positions = new List <int>();
            DeckObservableDict <MexicanDomino> TempList = new DeckObservableDict <MexicanDomino>();

            foreach (var currentPiece in piecesCollection)
            {
                TempList.Add(currentPiece);
            }
            bool     anyPieceMatch = false;
            int      count         = 1;
            DateTime newTime;

            newTime = DateTime.Now.AddSeconds(5);
            foreach (var currentPiece in piecesCollection)
            {
                if ((currentPiece.CurrentFirst == givenNumber) | (currentPiece.CurrentSecond == givenNumber))
                {
                    MexicanDomino newPiece = new MexicanDomino();
                    newPiece.CurrentFirst  = currentPiece.CurrentFirst;
                    newPiece.CurrentSecond = currentPiece.CurrentSecond;
                    newPiece.Deck          = currentPiece.Deck;
                    newPiece.CurrentFirst  = currentPiece.CurrentFirst;
                    newPiece.Keeps         = currentPiece.Keeps;
                    newPiece.CurrentSecond = currentPiece.CurrentSecond;
                    newPiece.Status        = currentPiece.Status;
                    newPiece.Train         = currentPiece.Train;
                    Positions.Add(count);
                    matchingPieces.Add(count, newPiece);
                    anyPieceMatch = true;
                }
                count += 1;
            }
            if (anyPieceMatch == false)
            {
                return(new DeckRegularDict <MexicanDomino>());
            }
            CustomBasicList <CustomBasicList <MexicanDomino> > allTrains = new CustomBasicList <CustomBasicList <MexicanDomino> >();

            count = 1;
            // Searching for Trains
            foreach (var currentPiece in matchingPieces.Values)
            {
                // Searching for Train
                CustomBasicList <MexicanDomino> train = new CustomBasicList <MexicanDomino>();
                if (currentPiece.CurrentFirst != givenNumber)
                {
                    ReplacePieceFirstSecond(currentPiece);
                }
                train.Add(currentPiece);
                // All Pieces Clone with Removing the first matched
                var allPieces = CloneList(TempList);
                allPieces.RemoveAt(Positions[count - 1] - 1); // 0 based
                int           i        = 1;
                MexicanDomino trainEnd = currentPiece;
                CustomBasicList <CustomBasicList <MexicanDomino> > trainPieceList  = new CustomBasicList <CustomBasicList <MexicanDomino> >();
                CustomBasicList <CustomBasicList <MexicanDomino> > trainSecondList = new CustomBasicList <CustomBasicList <MexicanDomino> >();
                CustomBasicList <MexicanDomino> trainDominoList = new CustomBasicList <MexicanDomino>();
                CustomBasicList <int>           trainIndexList  = new CustomBasicList <int>();
                while (i <= allPieces.Count)
                {
                    MexicanDomino piece;
                    piece = allPieces[i - 1]; // because 0 based
                    if (piece.CurrentFirst == trainEnd.CurrentSecond)
                    {
                        trainPieceList.Add(CloneList(allPieces));
                        trainSecondList.Add(CloneList(train));
                        trainDominoList.Add(CloneDominoPiece(trainEnd));
                        train.Add(piece);
                        allPieces.RemoveAt(i - 1); // 0 based
                        trainEnd = piece;
                        i        = 1;
                    }
                    else if (piece.CurrentSecond == trainEnd.CurrentSecond)
                    {
                        trainPieceList.Add(CloneList(allPieces));
                        trainSecondList.Add(CloneList(train));
                        trainDominoList.Add(CloneDominoPiece(trainEnd));
                        trainIndexList.Add(i + 1);
                        ReplacePieceFirstSecond(piece);
                        train.Add(piece);
                        allPieces.RemoveAt(i - 1); // 0 based
                        trainEnd = piece;
                        i        = 1;
                    }
                    else
                    {
                        if (i < allPieces.Count)
                        {
                            i += 1;
                        }
                        else if ((trainPieceList.Count > 0) & (i >= allPieces.Count) & trainIndexList.Count > 0)
                        {
                            allTrains.Add(CloneList(train));
                            if (allPieces.Count == 0)
                            {
                                throw new BasicBlankException("allpieces has nothing left");
                            }
                            allPieces = trainPieceList.First();
                            trainPieceList.RemoveAt(0);
                            if (trainSecondList.Count == 0)
                            {
                                throw new BasicBlankException("trainsecondlist has nothing left");
                            }
                            train = trainSecondList.First();
                            trainSecondList.RemoveAt(0);
                            if (trainDominoList.Count == 0)
                            {
                                throw new BasicBlankException("traindominolist has nothing left");
                            }
                            trainEnd = trainDominoList.First();
                            trainDominoList.RemoveAt(0);
                            if (trainIndexList.Count == 0)
                            {
                                i++;
                            }
                            else
                            {
                                i = trainIndexList.First();
                                trainIndexList.RemoveAt(0);
                            }
                        }
                        else
                        {
                            // Saves the current list
                            allTrains.Add(CloneList(train));

                            // No more List possible
                            break;
                        }
                        if (DateTime.Now > newTime)
                        {
                            // MsgBox("taking too long")
                            break;
                        }
                    }
                }
                if (train.Count > 0)
                {
                    allTrains.Add(CloneList(train));
                }
                if (DateTime.Now > newTime)
                {
                    break;
                }
                count += 1;
            }
            int  j                   = 1;
            int  piecesCount         = 0;
            bool multiplePiecesCount = false;
            CustomBasicList <int> piecesPositions = new CustomBasicList <int>();

            while (j <= allTrains.Count)
            {
                CustomBasicList <MexicanDomino> currentTrain;
                currentTrain = allTrains[j - 1]; // 0 based
                if (currentTrain.Count > piecesCount)
                {
                    piecesCount         = currentTrain.Count;
                    multiplePiecesCount = false;
                    piecesPositions.Clear();
                    piecesPositions.Add(j);
                }
                else if (currentTrain.Count == piecesCount)
                {
                    multiplePiecesCount = true;
                    piecesPositions.Add(j);
                }
                j += 1;
            }
            CustomBasicList <MexicanDomino> tempCol;

            if (!multiplePiecesCount)
            {
                tempCol = allTrains[piecesPositions[0] - 1]; // try 0 based here
                output  = new DeckRegularDict <MexicanDomino>();
                MexicanDomino newDomino;
                foreach (var thisDomino in tempCol)
                {
                    newDomino = piecesCollection.GetSpecificItem(thisDomino.Deck);
                    newDomino.CurrentFirst  = thisDomino.CurrentFirst;
                    newDomino.CurrentSecond = thisDomino.CurrentSecond;
                    piecesCollection.RemoveObjectByDeck(newDomino.Deck); // try this way
                    output.Add(newDomino);
                }
                return(output);
            }
            else
            {
                int points;
                int bestPoints   = 0;
                int bestPosition = 0;
                var loopTo       = piecesPositions.Count - 1;
                for (points = 0; points <= loopTo; points++)
                {
                    int totalPoints = 0;
                    CustomBasicList <MexicanDomino> currentTrain = allTrains[piecesPositions[points] - 1]; // 0 based
                    foreach (var piece in currentTrain)
                    {
                        totalPoints += piece.Points;
                    }

                    if (totalPoints > bestPoints)
                    {
                        bestPosition = points;
                    }
                }
                tempCol = allTrains[piecesPositions[bestPosition] - 1]; // 0 based
                output  = new DeckRegularDict <MexicanDomino>();
                MexicanDomino NewDomino;
                foreach (var ThisDomino in tempCol)
                {
                    NewDomino = piecesCollection.GetSpecificItem(ThisDomino.Deck);
                    NewDomino.CurrentFirst  = ThisDomino.CurrentFirst;
                    NewDomino.CurrentSecond = ThisDomino.CurrentSecond;
                    piecesCollection.RemoveSpecificItem(NewDomino); // try this way
                    output.Add(NewDomino);
                }
                return(output);
            }
        }
示例#8
0
 public void ClearLists()
 {
     _commandList.Clear();
     _openList.Clear();
     _controlList.Clear();
 }
 public void UpdatePlayer(CountdownPlayerItem thisPlayer)
 {
     _thisPlayer = thisPlayer;
     _thisList.Clear();
     CreateSpaces(); //try to create spaces again.
 }