Ejemplo n.º 1
0
        public int SinglePileSelected()
        {
            int counts = PileList.Count(items => items.IsSelected);

            if (counts == 0)
            {
                return(-1);
            }
            if (counts > 1)
            {
                throw new BasicBlankException("More than one pile is selected.  Find out what happened");
            }
            var tempPile = PileList.Single(items => items.IsSelected);

            return(PileList.IndexOf(tempPile));
        }
Ejemplo n.º 2
0
        public static int DominoToPlay(out int whichOne, DominosRegularMainGameClass mainGame, GameBoardCP gameboard)
        {
            whichOne = 0; //until proven otherwise.
            CustomBasicList <MoveInfo> moveList = new CustomBasicList <MoveInfo>();

            mainGame.SingleInfo !.MainHandList.ForEach(thisDomino =>
            {
                for (int x = 1; x <= 2; x++)
                {
                    if (gameboard.IsValidMove(x, thisDomino))
                    {
                        MoveInfo thisMove = new MoveInfo();
                        thisMove.Deck     = thisDomino.Deck;
                        thisMove.WhichOne = x;
                        thisMove.Points   = thisDomino.Points;
                        moveList.Add(thisMove);
                    }
                }
            });
            if (moveList.Count == 0)
            {
                return(0);
            }
            moveList.Sort();
            var finalMove = moveList.First();
            int howMany   = moveList.Count(items => items.Deck == finalMove.Deck);

            if (howMany == 1)
            {
                whichOne = finalMove.WhichOne;
                return(finalMove.Deck);
            }
            RandomGenerator rs = mainGame.MainContainer.Resolve <RandomGenerator>();

            whichOne = rs.GetRandomNumber(2);
            return(finalMove.Deck);
        }
Ejemplo n.º 3
0
        public static void Bind(object viewModel, BindableObject view, BindableObject?content = null)
        {
            //if (StopRun)
            //{
            //    return;
            //}
            Type type = viewModel.GetType();

            if (!(view is VisualElement element))
            {
                return;
            }
            var viewType   = viewModel.GetType();
            var properties = viewType.GetProperties();
            var methods    = viewType.GetMethods().ToCustomBasicList();

            _controls.Clear();
            if (view is VisualElement ee)
            {
                GetChildren(ee);
            }

            if (_controls.Count() == 0 && content is VisualElement vv)
            {
                GetChildren(vv);
            }
            _controls.AddRange(ManuelElements);

            if (_controls.Count == 0)
            {
                return;
            }


            if (_controls.Count == 1 && _controls.Single() == null)
            {
                return;
            }

            BindProperties(_controls, type, properties);
            var pList = methods.Where(x => x.Name.StartsWith("Can")).ToCustomBasicList();

            methods.KeepConditionalItems(x => x.HasCommandAttribute()); //because only
            if (methods.Any(x =>
            {
                if (x.ReturnType.Name != "Task" && x.ReturnType.Name != "Void")
                {
                    return(true);
                }
                return(false);
            }))
            {
                throw new BasicBlankException("Cannot put as command if the return type of any is not void or task.  Rethink");
            }



            BindStandardCommands(_controls, viewModel, methods, properties, pList);
            //do a separate one for combo boxes.  not enough in common with text boxes to do interfaces.
            //too many specialized stuff.
            //if i do right, combo may be easier to use than ever (well see).
        }
 public int HowManyHit()
 {
     return(DiceList.Count(items => items.DidHit == true));
 }
 public int SongsSoFar()
 {
     return(_rList.Count());
 }
Ejemplo n.º 6
0
 private int HowManyFound(CustomBasicList <ICard> cardList, int number, EnumColor color)
 {
     return(cardList.Count(items => HasSpecificCard(items, number, color)));
 }