Esempio n. 1
0
 void Init()
 {
     dominoes.Clear();
     for (int i = 0; i <= MAXNUM; i++)
     {
         for (int j = i; j <= MAXNUM; j++)
         {
             DominoController temp = (DominoController)Instantiate(exampleDomino);
             temp.SetUpperLowerValues(i, j);
             dominoes.Add(temp);
         }
     }
     ShowTile();
 }
Esempio n. 2
0
 public DominoController DrawCard()
 {
     if (IsDrawable())
     {
         for (int i = 0; i < NUMTILE; i++)
         {
             if (dominoes[i].ownership == GameRole.BoneYard)
             {
                 dominoes[i].ownership = GameRole.Player1;
                 DominoController temp = (DominoController)Instantiate(exampleDomino);
                 temp.ownership = GameRole.Player1;
                 temp.SetUpperLowerValues(dominoes[i].upperValue, dominoes[i].lowerValue);
                 temp.isObservableByAll = true;
                 return(temp);
             }
         }
     }
     return(null);
 }
        private void PlaceDomino(DominoController chosenDomino, DominoController chosenPlace, HistoryController history)
        {
            DominoController clickedDomino = chosenPlace;
            int horizontalLen = history.horizontalDominoes.Count;
            int verticalLen   = history.verticalDominoes.Count;

            if (chosenDomino != null)
            {
                if (chosenPlace != null)
                {
                    if (chosenPlace == history.horizontalDominoes[0])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.upperValue)
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                else
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                }
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.leftValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.leftValue)
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                else
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                }
                                return;
                            }
                        }
                    }
                    if (clickedDomino == history.horizontalDominoes[horizontalLen - 1])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.upperValue)
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                }
                                else
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.rightValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.rightValue || chosenDomino.lowerValue == clickedDomino.rightValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.rightValue)
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                }
                                else
                                {
                                    chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                    }
                    if (verticalLen > 0 && clickedDomino == history.verticalDominoes[0])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.upperValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.upperValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.leftValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                    }
                    if (verticalLen > 0 && clickedDomino == history.verticalDominoes[verticalLen - 1])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.lowerValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.lowerValue || chosenDomino.lowerValue == clickedDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.lowerValue == clickedDomino.lowerValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.lowerValue == clickedDomino.leftValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                return;
                            }
                        }
                    }
                }
                else
                {
                    if (chosenDomino.upperValue != chosenDomino.lowerValue)
                    {
                        chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                    }
                }
            }
        }
Esempio n. 4
0
    public void AIPlaceDomino()
    {
        DominoController clickedDomino = AIchosenplace;
        int horizontalLen = history.horizontalDominoes.Count;
        int verticalLen   = history.verticalDominoes.Count;

        if (AIchosenDomino != null)
        {
            if (clickedDomino != null)
            {
                if (clickedDomino == history.horizontalDominoes[0])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.upperValue || AIchosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
                            else
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_left,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.leftValue && AIchosenDomino.upperValue == AIchosenDomino.lowerValue)
                        {
                            AIchosenplace = clickedDomino;
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_left,h_horizontal,p_special");
                            return;
                        }
                        else if (AIchosenDomino.upperValue == clickedDomino.leftValue || AIchosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.leftValue)
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
                            else
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_left,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
                if (clickedDomino == history.horizontalDominoes[horizontalLen - 1])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.upperValue || AIchosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
                            }
                            else
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_right,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.rightValue && AIchosenDomino.upperValue == AIchosenDomino.lowerValue)
                        {
                            AIchosenplace = clickedDomino;
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_right,h_horizontal,p_special");
                            return;
                        }
                        else if (AIchosenDomino.upperValue == clickedDomino.rightValue || AIchosenDomino.lowerValue == clickedDomino.rightValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.rightValue)
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
                            }
                            else
                            {
                                AIchosenDomino.SetLeftRightValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_right,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
                if (clickedDomino == history.verticalDominoes[0])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.upperValue && AIchosenDomino.upperValue == AIchosenDomino.lowerValue)
                        {
                            AIchosenplace = clickedDomino;
                            AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_top,h_vertical,p_special");
                            return;
                        }
                        else if (AIchosenDomino.upperValue == clickedDomino.upperValue || AIchosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                AIchosenDomino.SetUpperLowerValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_top,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.leftValue || AIchosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.upperValue == clickedDomino.leftValue)
                            {
                                AIchosenDomino.SetUpperLowerValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_top,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
                if (clickedDomino == history.verticalDominoes[verticalLen - 1])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.lowerValue && AIchosenDomino.upperValue == AIchosenDomino.lowerValue)
                        {
                            AIchosenplace = clickedDomino;
                            AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_bottom,h_vertical,p_special");
                            return;
                        }
                        else if (AIchosenDomino.upperValue == clickedDomino.lowerValue || AIchosenDomino.lowerValue == clickedDomino.lowerValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.lowerValue == clickedDomino.lowerValue)
                            {
                                AIchosenDomino.SetUpperLowerValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_bottom,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (AIchosenDomino.upperValue == clickedDomino.leftValue || AIchosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            AIchosenplace = clickedDomino;
                            if (AIchosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                AIchosenDomino.SetUpperLowerValues(AIchosenDomino.lowerValue, AIchosenDomino.upperValue);
                            }
//                            PlayDomino();
//                            AIchosenDomino = null;
//                            AIchosenplace = null;
//                            Debug.Log("excute h_bottom,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
            }
            else
            {
                if (AIchosenDomino.upperValue != AIchosenDomino.lowerValue)
                {
                    AIchosenDomino.SetLeftRightValues(AIchosenDomino.upperValue, AIchosenDomino.lowerValue);
                }
            }
        }
    }
Esempio n. 5
0
    public void DominoOnClick(DominoController clickedDomino)
    {
        //Debug.Log(clickedDomino.upperValue);
        //Debug.Log(clickedDomino.leftValue);
        bool preflag = false;

        readytoplay = false;
        string playerturn = "";

        if (turnText.text.Equals("Player1's turn"))
        {
            playerturn = "player1";
        }
        else
        {
            playerturn = "player2";
        }

        if (!playerturn.Equals(playerName))
        {
            return;
        }

        //set clicked domino
        foreach (DominoController domino in dominoControllers)
        {
            if (domino == clickedDomino)
            {
                preflag = true;
                //move clicked card

                registerDomino();


                if (chosenDomino == null)
                {
                    chosenDomino            = clickedDomino;
                    clickedDomino.isClicked = true;
                    Selecteffect(clickedDomino);
                }
                else if (clickedDomino == chosenDomino)
                {
                    chosenDomino            = null;
                    clickedDomino.isClicked = false;
                    Selecteffect(clickedDomino);
                }
                else if (clickedDomino != chosenDomino)
                {
                    chosenDomino.isClicked = false;
                    Selecteffect(chosenDomino);
                    chosenDomino            = clickedDomino;
                    clickedDomino.isClicked = true;
                    Selecteffect(clickedDomino);
                }
                break;
            }
        }
        if (!preflag && chosenDomino != null)
        {
            readytoplay = true;
            //Debug.Log(playerName);
        }

        if (chosenDomino != null)
        {
            int horizontalLen = history.horizontalDominoes.Count;
            int verticalLen   = history.verticalDominoes.Count;
            if (horizontalLen == 0 && verticalLen == 0)
            {
                chosenPlace = null;
                readytoplay = true;
                if (chosenDomino.upperValue != chosenDomino.lowerValue)
                {
                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                }
                PlayerPlayDomino();
                chosenDomino = null;
            }
            else if (readytoplay)
            {
                if (clickedDomino == history.horizontalDominoes[0])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            PlayerPlayDomino();
                            Debug.Log("excute h_left,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (chosenDomino.upperValue == clickedDomino.leftValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                        {
                            chosenPlace = clickedDomino;
                            PlayerPlayDomino();
                            Debug.Log("excute h_left,h_horizontal,p_special");
                            return;
                        }
                        else if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.leftValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            PlayerPlayDomino();
                            Debug.Log("excute h_left,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
                if (clickedDomino == history.horizontalDominoes[horizontalLen - 1])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            PlayerPlayDomino();
                            Debug.Log("excute h_right,h_vertical,p_normal");
                            return;
                        }
                    }
                    else
                    {
                        if (chosenDomino.upperValue == clickedDomino.rightValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                        {
                            chosenPlace = clickedDomino;
                            PlayerPlayDomino();
                            Debug.Log("excute h_right,h_horizontal,p_special");
                            return;
                        }
                        else if (chosenDomino.upperValue == clickedDomino.rightValue || chosenDomino.lowerValue == clickedDomino.rightValue)
                        {
                            chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.rightValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            PlayerPlayDomino();
                            Debug.Log("excute h_right,h_horizontal,p_normal");
                            return;
                        }
                    }
                }
                // TOFIX System.ArgumentOutOfRangeException
                if (history.verticalDominoes.Count != 0)
                {
                    if (clickedDomino == history.verticalDominoes[0])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.upperValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                PlayerPlayDomino();
                                Debug.Log("excute h_top,h_vertical,p_special");
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.upperValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                PlayerPlayDomino();
                                Debug.Log("excute h_top,h_vertical,p_normal");
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.upperValue == clickedDomino.leftValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                PlayerPlayDomino();
                                Debug.Log("excute h_top,h_horizontal,p_normal");
                                return;
                            }
                        }
                    }
                    if (clickedDomino == history.verticalDominoes[verticalLen - 1])
                    {
                        if (clickedDomino.leftValue == -1)
                        {
                            if (chosenDomino.upperValue == clickedDomino.lowerValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                                PlayerPlayDomino();
                                Debug.Log("excute h_bottom,h_vertical,p_special");
                                return;
                            }
                            else if (chosenDomino.upperValue == clickedDomino.lowerValue || chosenDomino.lowerValue == clickedDomino.lowerValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.lowerValue == clickedDomino.lowerValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                PlayerPlayDomino();
                                Debug.Log("excute h_bottom,h_vertical,p_normal");
                                return;
                            }
                        }
                        else
                        {
                            if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenPlace = clickedDomino;
                                if (chosenDomino.lowerValue == clickedDomino.leftValue)
                                {
                                    chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                                }
                                PlayerPlayDomino();
                                Debug.Log("excute h_bottom,h_horizontal,p_normal");
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 6
0
        private void PlaceDomino(DominoController chosenDomino, DominoController chosenPlace, HistoryController history)
        {
            var clickedDomino = chosenPlace;
            var horizontalLen = history.horizontalDominoes.Count;
            var verticalLen   = history.verticalDominoes.Count;

            if (chosenDomino == default)
            {
                return;
            }

            if (!chosenPlace == default)
            {
                if (chosenPlace == history.horizontalDominoes[0])
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            return;
                        }
                    }
                    else
                    {
                        /*
                         * if (chosenDomino.upperValue == clickedDomino.leftValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                         * {
                         *  //chosenPlace = clickedDomino;
                         *  return;
                         * }
                         */
                        if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.leftValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            return;
                        }
                    }
                }
                if (clickedDomino.Equals(history.horizontalDominoes[horizontalLen - 1]))
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            return;
                        }
                    }
                    else
                    {
                        if (chosenDomino.upperValue == clickedDomino.rightValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                        {
                            //chosenPlace = clickedDomino;
                            return;
                        }
                        if (chosenDomino.upperValue == clickedDomino.rightValue || chosenDomino.lowerValue == clickedDomino.rightValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.rightValue)
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            }
                            else
                            {
                                chosenDomino.SetLeftRightValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            return;
                        }
                    }
                }
                if (verticalLen > 0 && clickedDomino.Equals(history.verticalDominoes[0]))
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.upperValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                        {
                            //chosenPlace = clickedDomino;
                            chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            return;
                        }
                        if (chosenDomino.upperValue == clickedDomino.upperValue || chosenDomino.lowerValue == clickedDomino.upperValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.upperValue)
                            {
                                chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            return;
                        }
                    }
                    else
                    {
                        if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.upperValue == clickedDomino.leftValue)
                            {
                                chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                            return;
                        }
                    }
                }
                if (verticalLen > 0 && clickedDomino.Equals(history.verticalDominoes[verticalLen - 1]))
                {
                    if (clickedDomino.leftValue == -1)
                    {
                        if (chosenDomino.upperValue == clickedDomino.lowerValue && chosenDomino.upperValue == chosenDomino.lowerValue)
                        {
                            //chosenPlace = clickedDomino;
                            chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                            return;
                        }
                        if (chosenDomino.upperValue == clickedDomino.lowerValue || chosenDomino.lowerValue == clickedDomino.lowerValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.lowerValue == clickedDomino.lowerValue)
                            {
                                chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                        }
                    }
                    else
                    {
                        if (chosenDomino.upperValue == clickedDomino.leftValue || chosenDomino.lowerValue == clickedDomino.leftValue)
                        {
                            //chosenPlace = clickedDomino;
                            if (chosenDomino.lowerValue == clickedDomino.leftValue)
                            {
                                chosenDomino.SetUpperLowerValues(chosenDomino.lowerValue, chosenDomino.upperValue);
                            }
                        }
                    }
                }
            }
            else
            {
                if (chosenDomino.upperValue != chosenDomino.lowerValue)
                {
                    chosenDomino.SetLeftRightValues(chosenDomino.upperValue, chosenDomino.lowerValue);
                }
            }
        }