private MahJongSolitaireTilesWPF?GetControl(MahjongSolitaireTileInfo thisTile) { if (_thisGrid.Children.Count == 0) { throw new BasicBlankException("Can't get control because grid had 0 children"); } foreach (var thisFirst in _thisGrid.Children) { var thisGraphics = (MahJongSolitaireTilesWPF)thisFirst !; var thisFin = (MahjongSolitaireTileInfo)thisGraphics.DataContext; if (thisGraphics != _newOne) { if (thisFin.Deck == thisTile.Deck) { if (thisFin.Equals(thisTile) == false) { thisGraphics.DataContext = thisTile; thisGraphics.CommandParameter = thisTile; } return(thisGraphics); } } } return(null); }
private void AddCardToBoard(BoardInfo thisBoard, int whichOne) { MahjongSolitaireTileInfo thisTile = _customGlobal.TileList.GetIndexedTile(whichOne); thisBoard.TileList.Add(thisTile); thisTile.IsEnabled = false; }
public void Handle(TileChosenEventModel message) { if (message.Deck > 0) { MahjongSolitaireTileInfo thisTile = new MahjongSolitaireTileInfo(); thisTile.Populate(message.Deck); thisTile.Top = 715; thisTile.Left = 1000; thisTile.Visible = false; //for now, unable to show what you selected. if i need this for tablet, rethink. if (_newOne.BindingContext == null) { _newOne.SendSize("", thisTile); } else { _newOne.BindingContext = null; _newOne.BindingContext = thisTile; // to refresh just in case. } _newOne.IsVisible = true; _newOne.IsVisible = false; //because does not work right for positioning. } else { _newOne.IsVisible = false; } }
private void RemoveTile(BoardInfo thisBoard, MahjongSolitaireTileInfo thisTile) { thisBoard.TileList.RemoveSpecificItem(thisTile); if (_customGlobal.CanShowTiles == true) { thisTile.Visible = false;// making visible false means no subscriptions needed } }
private void UpdateTile(MahjongSolitaireTileInfo thisTile) { if (_customGlobal.CanShowTiles == true) { thisTile.IsEnabled = true; thisTile.Drew = true; } if (ValidList.ObjectExist(thisTile.Deck) == false) { ValidList.Add(thisTile); // needs to be added to get hints even if not auto. } //because it could go to more than one thing. }
public MahJongSolitaireGameBoardCP(MahJongSolitaireSaveInfo saveRoot, BaseMahjongGlobals customGlobal , MahJongSolitaireModGlobal mainGlobal, IProportionImage thisP, BasicData data) { _saveRoot = saveRoot; //if this causes too many problems, has to resolve later. _customGlobal = customGlobal; _mainGlobal = mainGlobal; _data = data; _sizeUsed = MahjongSolitaireTileInfo.GetDefaultSize().GetSizeUsed(thisP.Proportion); if (saveRoot.BoardList.Count > 0) { throw new BasicBlankException("The saveroot should have cleared out every game. Rethink"); } FirstLoad(); }
public bool IsValidMove() { MahjongSolitaireTileInfo firstTile = _customGlobal.TileList.GetSpecificItem(_saveRoot !.FirstSelected); MahjongSolitaireTileInfo secondTile = _customGlobal.TileList.GetSpecificItem(_customGlobal.SecondSelected); if (firstTile.WhatNumber != BasicMahjongTile.EnumNumberType.IsNoNumber && secondTile.WhatNumber != BasicMahjongTile.EnumNumberType.IsNoNumber) { return(firstTile.NumberUsed == secondTile.NumberUsed && firstTile.WhatNumber == secondTile.WhatNumber); } if (firstTile.WhatBonus != BasicMahjongTile.EnumBonusType.IsNoBonus && secondTile.WhatBonus != BasicMahjongTile.EnumBonusType.IsNoBonus) { return(firstTile.WhatBonus == secondTile.WhatBonus); } if (firstTile.WhatColor != BasicMahjongTile.EnumColorType.IsNoColor && secondTile.WhatColor != BasicMahjongTile.EnumColorType.IsNoColor) { return(firstTile.WhatColor == secondTile.WhatColor); } if (firstTile.WhatDirection != BasicMahjongTile.EnumDirectionType.IsNoDirection && secondTile.WhatDirection != BasicMahjongTile.EnumDirectionType.IsNoDirection) { return(firstTile.WhatDirection == secondTile.WhatDirection); } return(false); }
private void RemoveSpecificTile(MahjongSolitaireTileInfo thisTile) { // i have an idea (hopefully won't cause more problems). foreach (var thisBoard in _saveRoot.BoardList) { if (thisBoard.TileList.Count >= 2) { if (thisBoard.TileList.First().Deck == thisTile.Deck) { } if (thisBoard.TileList.First().Deck == thisTile.Deck) { thisBoard.FrontTaken += 1; RemoveTile(thisBoard, thisBoard.TileList.First()); return; } if (thisBoard.TileList.Last().Deck == thisTile.Deck) { thisBoard.BackTaken += 1; RemoveTile(thisBoard, thisBoard.TileList.Last()); return; } } else if (thisBoard.TileList.Count == 1) { if (thisBoard.TileList.Single().Deck == thisTile.Deck) { RemoveTile(thisBoard, thisBoard.TileList.Single()); return; } } } if (_customGlobal.CanShowTiles == true) { throw new BasicBlankException("No tile to remove"); } }
//not sure if we needed the undo event now. //public void Handle(UndoEventModel message) //{ // foreach (var firstBoard in _thisMod.MainGame!.SaveRoot!.BoardList) // { // foreach (var firstCard in firstBoard.TileList) // GetControl(firstCard);// hopefully this simple. // } // var thisList = message.PreviousList; // CustomBasicList<MahJongSolitaireTilesWPF> nextList = new CustomBasicList<MahJongSolitaireTilesWPF>(); // MahJongSolitaireTilesWPF graphicsCard; // foreach (var thisCard in thisList!) // { // var newItem = GetControl(thisCard); // if (newItem != null) // { // _thisGrid.Children.Remove(newItem); // } // graphicsCard = new MahJongSolitaireTilesWPF(); // graphicsCard.SendSize("", thisCard); // graphicsCard.Margin = new Thickness(0, 0, 0, 0); // Binding ThisBind = new Binding(nameof(MahJongSolitaireViewModel.TileSelectedCommand)); // ThisBind.Source = _thisMod; // graphicsCard.SetBinding(MahJongSolitaireTilesWPF.CommandProperty, ThisBind); // graphicsCard.CommandParameter = thisCard; // i think // nextList.Add(graphicsCard); // } // if (nextList.Count == 0) // return;// there was no new items // foreach (var ThisGR in nextList) // _thisGrid.Children.Add(ThisGR); // return; //} //public void Handle(StartNewGameEventModel message) //{ // _thisGrid.Children.Clear(); // _newOne.Visibility = Visibility.Collapsed; // _thisGrid.Children.Add(_newOne); //} public void Handle(TileChosenEventModel message) { if (message.Deck > 0) { MahjongSolitaireTileInfo thisTile = new MahjongSolitaireTileInfo(); thisTile.Populate(message.Deck); thisTile.Top = 715; thisTile.Left = 1000; if (_newOne.DataContext == null) { _newOne.SendSize("", thisTile); } else { _newOne.DataContext = null; _newOne.DataContext = thisTile; // to refresh just in case. } _newOne.Visibility = Visibility.Visible; } else { _newOne.Visibility = Visibility.Collapsed; } }