Exemplo n.º 1
0
        public async Task AnimateMoveAsync(bool useSecond)
        {
            PayDaysPassed = 0;
            int currentPosition = _gameContainer.SingleInfo !.Position;

            if (currentPosition == 147 || NewPosition == 0)
            {
                return;
            }
            if (NewPosition > 147)
            {
                throw new BasicBlankException("The highest supported for new position is 147");
            }
            SpaceInfo thisSpace;

            _gameContainer.GameStatus   = EnumWhatStatus.MakingMove;
            GameBoardGraphicsCP.GoingTo = NewPosition;
            int x = 0;

            _gameContainer.CurrentSelected = 0;
            do
            {
                x++;
                //there was a case where the position went from 47 to 50.
                //somehow no 48 and no 49.

                if (x > 16)
                {
                    throw new BasicBlankException("Can't move more than 16 spaces.  This means its hosed."); //if testing, rethink
                }
                if (currentPosition == 0 && _gameContainer.SingleInfo.OptionChosen == EnumStart.Career)
                {
                    currentPosition = 12;
                }
                else if (currentPosition == 0 && _gameContainer.SingleInfo.OptionChosen == EnumStart.College)
                {
                    currentPosition = 1;
                }
                else if (currentPosition == 0)
                {
                    throw new BasicBlankException("Current position cannot be 0 if not choosing college or career");
                }
                else if (currentPosition >= 48 && useSecond && currentPosition < 56)
                {
                    currentPosition = 56;
                }
                else if (currentPosition >= 84 && useSecond && currentPosition < 92)
                {
                    currentPosition = 92;
                }
                else if (x == 1 && _stops.Any(items => items == currentPosition))
                {
                    currentPosition++;
                }
                else
                {
                    currentPosition = NextAvailableSpace(currentPosition);
                }
                _gameContainer.SingleInfo.Distance++;
                thisSpace = _gameContainer.SpaceList ![currentPosition - 1]; //because 0 based;
Exemplo n.º 2
0
        public void LoadNumberList(CustomBasicList <int> thisList)
        {
            if (thisList.Any(Items => Items < 0))
            {
                throw new BasicBlankException("You should not be allowed to use less than 0.  If that is needed, then rethinking is required");
            }
            CustomBasicList <NumberPieceCP> tempList = new CustomBasicList <NumberPieceCP>();

            thisList.ForEach(items =>
            {
                NumberPieceCP ThisNumber = new NumberPieceCP();
                ThisNumber.NumberValue   = items;
                tempList.Add(ThisNumber);
            });
            NumberList.ReplaceRange(tempList);
        }
        public async Task SendMessageAsync(string tempMessage)
        {
            string         errorMessage = "";
            ConnectionInfo thisInfo;
            NetworkMessage thisMessage = await js.DeserializeObjectAsync <NetworkMessage>(tempMessage);

            if (_playerList.Count == 0)
            {
                await SendErrorAsync("There are no players to send messages to");

                return;
            }
            if (thisMessage.SpecificPlayer != "")
            {
                if (_playerList.ContainsKey(thisMessage.SpecificPlayer) == false)
                {
                    errorMessage = $"{thisMessage.SpecificPlayer} was not even registered to receive messages";
                }
                thisInfo = _playerList[thisMessage.SpecificPlayer];
                if (thisInfo.IsConnected == false)
                {
                    errorMessage = $"{thisMessage.SpecificPlayer} was disconnected even though it showed it was registered";
                }
                if (errorMessage != "")
                {
                    await SendErrorAsync(errorMessage);

                    return;
                }
                await Clients.Client(thisInfo.ConnectionID).SendAsync("ReceiveMessage", thisMessage.Message);

                return; //i think
            }
            CustomBasicList <ConnectionInfo> SendTo = _playerList.Where(Items => Items.Key != thisMessage.YourNickName).Select(Temps => Temps.Value).ToCustomBasicList();

            if (SendTo.Any(Items => Items.IsConnected == false))
            {
                await SendErrorAsync("Somebody got disconnected when trying to send a message.");

                return;
            }
            await SendTo.ForEachAsync(async Items =>
            {
                await Clients.Client(Items.ConnectionID).SendAsync("ReceiveMessage", thisMessage.Message);
            });
        }
        public bool PlayedAtLeastOneFromHand()
        {
            CustomBasicList <int> tempList = new CustomBasicList <int>();

            SetList.ForEach(thisTemp =>
            {
                thisTemp.HandList.ForEach(thisTile =>
                {
                    tempList.Add(thisTile.Deck);
                });
            });
            TileRummySaveInfo saveRoot = cons !.Resolve <TileRummySaveInfo>();

            foreach (var thisIndex in saveRoot.YourTiles)
            {
                if (tempList.Any(items => items == thisIndex))
                {
                    return(true);
                }
            }
            return(false);
        }
        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;
                }
            }
        }
Exemplo n.º 6
0
 private bool ContainsCurrentPlayer(CustomBasicList <HandObservable <KeeperCard> > thisList)
 {
     return(thisList.Any(items => GetPlayerOfKeeperHand(items) == GameContainer.WhoTurn));
 }
Exemplo n.º 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;
                }
            }
        }