コード例 #1
0
        public void PutTrain(int player, PlayerCollection <DominosMexicanTrainPlayerItem> players)
        {
            if (player == players.Count() + 1)
            {
                return;
            }
            var thisTrain = GetTrain(player);

            thisTrain.TrainUp = true;
            NewestTrain       = player;
            RepaintBoard();
        }
コード例 #2
0
        public void RemoveTrain(int player, PlayerCollection <DominosMexicanTrainPlayerItem> players)
        {
            if (player == players.Count() + 1)
            {
                return;
            }
            var thisTrain = GetTrain(player);

            thisTrain.TrainUp = false;
            if (NewestTrain == player)
            {
                NewestTrain = 0;
            }
            RepaintBoard();
        }
コード例 #3
0
        public bool CanFillPrevious(PlayerCollection <DominosMexicanTrainPlayerItem> players, int turn) //try this way.
        {
            if (CanEndEarly() == false)
            {
                return(false);
            }
            if (Satisfy > 0)
            {
                return(true);
            }
            var  thisCol = FindAvailablePlays(turn);
            bool rets    = thisCol.Count < players.Count() + 1;

            return(!rets);
        }
        Task IOpeningMessenger.HostConnectedAsync(IMessageChecker thisCheck)
        {
            _data.Client        = false;
            thisCheck.IsEnabled = true;                       //so it can process the message from client;
            OpeningStatus       = EnumOpeningStatus.HostingWaitingForAtLeastOnePlayer;
            _playerList         = new PlayerCollection <P>(); //i think here too.
            P thisPlayer = new P();

            thisPlayer.NickName       = _data.NickName;
            thisPlayer.IsHost         = true;
            thisPlayer.Id             = 1;
            thisPlayer.InGame         = true; //you have to show you are in game obviously to start with.
            thisPlayer.PlayerCategory = EnumPlayerCategory.OtherHuman;
            _playerList.AddPlayer(thisPlayer);

            if (_saveList != null)
            {
                PreviousNonComputerNetworkedPlayers = _saveList.Count() - 1; //i think
            }
            CommandContainer.OpenBusy = false;                               //because you may decide to cancel.

            return(Task.CompletedTask);
        }
コード例 #5
0
 public void LoadBoard(PlayerCollection <SequenceDicePlayerItem> playerList, TestOptions thisTest, SequenceDiceVMData model)
 {
     //has to be done this way so it can figure out what it needs.
     _model = model;
     if (_didInit == true)
     {
         return;
     }
     if (playerList.Count() == 2)
     {
         _winList = _privateBoard.GetPossibleCombinations(6);
     }
     else if (playerList.Count() == 3)
     {
         _winList = _privateBoard.GetPossibleCombinations(5);
     }
     else
     {
         throw new BasicBlankException("Should have been 2 or 3 players.  Rethink");
     }
     _privateBoard.MainObjectSelector = Items => Items.Player;
     _didInit = true;
     //_thisMod = thisMod;
     _thisTest = thisTest;
     if (_autoResume == true)
     {
         return;
     }
     _privateBoard.ForEach(thisSpace =>
     {
         //populate the numbers.  that is needed for lots of things.
         if (thisSpace.Vector.Row == 1 & thisSpace.Vector.Column == 1 |
             thisSpace.Vector.Row == 6 & thisSpace.Vector.Column == 6 |
             thisSpace.Vector.Row == 1 & thisSpace.Vector.Column == 6 |
             thisSpace.Vector.Row == 6 & thisSpace.Vector.Column == 1)
         {
             thisSpace.Number = 2;
         }
         else if (((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 3;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 4)))
         {
             thisSpace.Number = 4;
         }
         else if (((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 3)))
         {
             thisSpace.Number = 5;
         }
         else if (((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 1)) |
                  ((thisSpace.Vector.Row == 1) & (thisSpace.Vector.Column == 5)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 6)) |
                  ((thisSpace.Vector.Row == 6) & (thisSpace.Vector.Column == 2)))
         {
             thisSpace.Number = 6;
         }
         else if (((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 5)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 7;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 8;
         }
         else if (((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 2)) |
                  ((thisSpace.Vector.Row == 2) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 5) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 5)))
         {
             thisSpace.Number = 9;
         }
         else if (((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 3)) |
                  ((thisSpace.Vector.Row == 3) & (thisSpace.Vector.Column == 4)) |
                  ((thisSpace.Vector.Row == 4) & (thisSpace.Vector.Column == 4)))
         {
             thisSpace.Number = 12;
         }
         else
         {
             throw new BasicBlankException($"Cannnot find a space for {thisSpace.Vector.Row} row, {thisSpace.Vector.Column} column");
         }
     });
 }
コード例 #6
0
        public void LoadLists <P>(PlayerCollection <P> thisList) where P : class, IPlayerItem, new()
        {
            int x = 0;
            int y;

            //co.VisibilityConverter thisV = new co.VisibilityConverter();
            GridHelper.AddAutoRows(_mainGrid !, thisList.Count());
            co.TrueFalseConverter thisT = null !;
            co.CurrencyConverter  thisC = null !;
            if (_rowList.Any(Items => Items.UseTrueFalseConverter == true))
            {
                thisT        = new co.TrueFalseConverter();
                thisT.UseAbb = UseAbbreviationForTrueFalse;
            }
            if (_rowList.Any(Items => Items.UseCurrencyConverter == true))
            {
                thisC = new co.CurrencyConverter();
            }
            foreach (var thisItem in thisList)
            {
                x += 1;
                y  = 0;
                foreach (var thisBind in _rowList !)
                {
                    TextBlock thisLabel = new TextBlock();
                    thisLabel.DataContext = thisItem;
                    thisLabel.Foreground  = Brushes.Aqua;
                    if (thisBind.UseTrueFalseConverter == true)
                    {
                        Binding tss = new Binding(thisBind.MainPath);
                        tss.Converter = thisT;
                        thisLabel.SetBinding(TextBlock.TextProperty, tss);
                    }
                    else if (thisBind.UseCurrencyConverter == true)
                    {
                        Binding css = new Binding(thisBind.MainPath);
                        css.Converter = thisC;
                        thisLabel.SetBinding(TextBlock.TextProperty, css);
                    }
                    else
                    {
                        thisLabel.SetBinding(TextBlock.TextProperty, new Binding(thisBind.MainPath));
                    }
                    if (thisBind.VisiblePath != "")
                    {
                        Binding otherBind = new Binding(thisBind.VisiblePath);
                        otherBind.Converter = new BooleanToVisibilityConverter(); //because of what i discovered.  hopefully no problem (?)
                        thisLabel.SetBinding(VisibilityProperty, otherBind);
                    }
                    if (thisBind.RightMargin > 0)
                    {
                        thisLabel.Margin = new Thickness(0, 0, thisBind.RightMargin, 0);
                    }
                    else
                    {
                        thisLabel.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    GridHelper.AddControlToGrid(_mainGrid !, thisLabel, x, y);
                    y += 1;
                }
            }
        }
コード例 #7
0
        public void LoadLists <P>(PlayerCollection <P> thisList) where P : class, IPlayerItem, new()
        {
            int x = 0;
            int y;

            GridHelper.AddAutoRows(_mainGrid !, thisList.Count());
            co.TrueFalseConverter thisT = null !;
            co.CurrencyConverter  thisC = null !;
            if (_rowList.Any(Items => Items.UseTrueFalseConverter == true))
            {
                thisT        = new co.TrueFalseConverter();
                thisT.UseAbb = UseAbbreviationForTrueFalse;
            }
            if (_rowList.Any(Items => Items.UseCurrencyConverter == true))
            {
                thisC = new co.CurrencyConverter();
            }
            foreach (var thisItem in thisList)
            {
                x += 1;
                y  = 0;
                foreach (var thisBind in _rowList !)
                {
                    Label thisLabel = new Label();
                    thisLabel.BindingContext = thisItem;
                    thisLabel.TextColor      = Color.Aqua;
                    if (thisBind.UseTrueFalseConverter == true)
                    {
                        Binding tss = new Binding(thisBind.MainPath);
                        tss.Converter = thisT;
                        thisLabel.SetBinding(Label.TextProperty, tss);
                    }
                    else if (thisBind.UseCurrencyConverter == true)
                    {
                        Binding css = new Binding(thisBind.MainPath);
                        css.Converter = thisC;
                        thisLabel.SetBinding(Label.TextProperty, css);
                    }
                    else
                    {
                        thisLabel.SetBinding(Label.TextProperty, new Binding(thisBind.MainPath));
                    }
                    if (thisBind.VisiblePath != "")
                    {
                        Binding otherBind = new Binding(thisBind.VisiblePath);
                        thisLabel.SetBinding(IsVisibleProperty, otherBind);
                    }
                    if (thisBind.RightMargin > 0)
                    {
                        thisLabel.Margin = new Thickness(0, 0, thisBind.RightMargin, 0);
                    }
                    else
                    {
                        thisLabel.HorizontalOptions       = LayoutOptions.Start;
                        thisLabel.HorizontalTextAlignment = TextAlignment.Start;
                    }
                    GridHelper.AddControlToGrid(_mainGrid !, thisLabel, x, y);
                    y += 1;
                }
            }
        }