Exemplo n.º 1
0
 public void UpdateUI(TTBoard board)
 {
     for (int row = 0; row < board.Height; row++)
     {
         for (int col = 0; col < board.Width; col++)
         {
             slotUIs[row, col].UpdateUI(board.GetCardAt(row, col));
         }
     }
 }
Exemplo n.º 2
0
        public void ApplyRuleOnMove(TTBoard board, int movedPlayerId, int indexOfRow, int indexOfColumn)
        {
            TTCard movedCard = board.GetCardAt(indexOfRow, indexOfColumn);

            foreach (Direction direction in System.Enum.GetValues(typeof(Direction)))
            {
                TTCard adjacentCard = board.GetCardAt(indexOfRow, indexOfColumn, direction);
                if (adjacentCard != null && (adjacentCard.belongPlayerId != movedPlayerId))
                {
                    int  movedCardRank    = movedCard.GetRankOf(direction);
                    int  adjacentCardRank = adjacentCard.GetOppositeRankOf(direction);
                    bool canTurnCard      = CompareRank(movedCardRank, adjacentCardRank) > 0;
                    if (canTurnCard)
                    {
                        adjacentCard.belongPlayerId = movedPlayerId;
                    }
                }
            }
        }