Пример #1
0
        private string[] downLeft(int now_x, int now_y)
        {
            int counter = 0, i = now_x, j = now_y;

            string[] arr = new String[10];
            int      plus = 1; int minus = -1;
            bool     flag2 = false, firstcome = true;

            if (j == 1)
            {
                if (i == 24)
                {
                    i = 1;
                }
                else
                {
                    i++;
                }

                j++;

                plus = 1;
            }
            else
            {
                if (i == 24)
                {
                    i = 1; j--; plus = -1;
                }
                else                                         /*if (j != 6)*/
                {
                    i++; j--; plus = -1;
                }                                                                                     //else { plus = -1; flag2 = true; }
            }
            minus = 1;
            for (; i != now_x || j != now_y; i += minus, j += plus)
            {
                if (i == now_x && j == now_y)
                {
                    break;
                }
                if (j == 1 && i != now_x)
                {
                    if (i == now_x && j == now_y)
                    {
                        break;
                    }

                    if (counter < 47 && Board.condition_matrix[i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    else if (DieClass.colorCheck(i, j) == color) /* do nothing */; {
                        //home has die but same color
                    }
                    else
                    {
                        arr[counter++] = i + "_" + j; break;
                    }                                        //home has die but different color

                    minus = 1; plus = 1;
                    if (i == 24)
                    {
                        j++; plus = 1;

                        i     = 1;
                        minus = 1;
                    }
                    else
                    {
                        i++; j++;
                        minus = 1; plus = 1;
                    }
                }
                if (j == 6)
                {
                    if (i == now_x && j == now_y)
                    {
                        break;
                    }


                    if (Board.condition_matrix[i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    else if (DieClass.colorCheck(i, j) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = i + "_" + j; break;
                    }                                        //home has die but different color

                    i = nextNumberTopToLeft(i);
                    Debug.Log(i);
                    if (Board.condition_matrix[i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    else if (DieClass.colorCheck(i, j) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = i + "_" + j; break;
                    }                                        //home has die but different color

                    if (i == now_x && j == now_y)
                    {
                        break;
                    }

                    plus = -1; minus = 1;
                }
                else if (i == 24 && j != 6)
                {
                    if (Board.condition_matrix[i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    else if (DieClass.colorCheck(i, j) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = i + "_" + j; break;
                    }                                        //home has die but different color

                    i     = 1;
                    minus = 1;
                    j    += plus;

                    if (j == 1)
                    {
                        plus = 1;
                    }

                    if (i == now_x && j == now_y)
                    {
                        break;
                    }

                    if (Board.condition_matrix[i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    else if (DieClass.colorCheck(i, j) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = i + "_" + j; break;
                    }                                        //home has die but different color
                }
                else if (j != 6 && counter < 47 && Board.condition_matrix[i, j] == DieClass.NO_DIE)
                {
                    arr[counter++] = i + "_" + j;
                }
                else if (DieClass.colorCheck(i, j) == color) //home has die but same color
                {
                    break;
                }
                else
                {
                    arr[counter++] = i + "_" + j; break;
                }                                        //home has die but different color
            }
Пример #2
0
        public String[] showCastleMovementSuggestion(string current_position)
        {
            string[] arr     = new string[58];
            int      counter = 0;
            int      now_x   = Int32.Parse(current_position.Split('_')[0]);
            int      now_y   = Int32.Parse(current_position.Split('_')[1]);

            /*diametery down to up */
            int plus = 1, temp_i = now_x; bool first6 = false;
            int j = now_y; if (j < 6)

            {
                j++;
            }
            else
            {
                first6 = true;
            }

            for (int i = now_x; ; j += plus)
            {
                if (j == 6)
                {
                    if (Board.condition_matrix[i, j] == DieClass.NO_DIE && !first6)
                    {
                        arr[counter++] = i + "_" + j;
                    }
                    // check this
                    else if (DieClass.colorCheck(i, now_y) == color && !first6) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = i + "_" + now_y; break;
                    }                                            //home has die but different color
                    /**/
                    if (i != 12)
                    {
                        temp_i = (now_x + 12) % 24;
                    }
                    else
                    {
                        temp_i = 24;
                    }
                    /**/
                    if (Board.condition_matrix[temp_i, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = temp_i + "_" + j;
                    }

                    else if (DieClass.colorCheck(temp_i, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = temp_i + "_" + now_y; break;
                    }                                                 //home has die but different color

                    plus = -1;
                }
                else if (Board.condition_matrix[temp_i, j] == DieClass.NO_DIE)
                {
                    arr[counter++] = temp_i + "_" + j;
                }
                else if (DieClass.colorCheck(temp_i, now_y) == color) //home has die but same color
                {
                    break;
                }
                else
                {
                    arr[counter++] = temp_i + "_" + now_y; break;
                }                                                 //home has die but different color


                if (i >= 25 || j >= 7 || i <= 0 || j <= 0)
                {
                    break;
                }
            }



            /*diametery up to down */
            plus = -1; temp_i = now_x;
            j    = now_y;

            if (j > 1 && j <= 6)
            {
                j--;

                for (int i = now_x; j != 0; j += plus)
                {
                    if (Board.condition_matrix[now_x, j] == DieClass.NO_DIE)
                    {
                        arr[counter++] = now_x + "_" + j;
                    }
                    else if (DieClass.colorCheck(now_x, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = now_x + "_" + now_y; break;
                    }                                                //home has die but different color


                    if (i >= 25 || j >= 7 || i <= 0 || j <= 0)
                    {
                        break;
                    }
                }
            }


            /*clockwise*/
            int adder = now_x; if (adder == 24)

            {
                adder = 1;
            }
            else
            {
                adder = now_x + 1;
            }

            for (; ; adder++)
            {
                if (adder == 24 && adder != now_x)
                {
                    if (Board.condition_matrix[adder, now_y] == DieClass.NO_DIE)
                    {
                        arr[counter++] = adder + "_" + now_y;
                    }
                    else if (DieClass.colorCheck(adder, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = adder + "_" + now_y; break;
                    }                                                //home has die but different color

                    adder = 1;
                    if (Board.condition_matrix[adder, now_y] == DieClass.NO_DIE && adder != now_x)
                    {
                        arr[counter++] = adder + "_" + now_y;
                    }
                    else if (DieClass.colorCheck(adder, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = adder + "_" + now_y; break;
                    }                                                //home has die but different color
                }
                else if (Board.condition_matrix[adder, now_y] == DieClass.NO_DIE && adder != now_x)
                {
                    arr[counter++] = adder + "_" + now_y;
                }
                else if (DieClass.colorCheck(adder, now_y) == color) //home has die but same color
                {
                    break;
                }
                else
                {
                    arr[counter++] = adder + "_" + now_y; break;
                }                                                //home has die but different color

                if (adder >= 25 || adder <= 0 || adder == now_x)
                {
                    break;
                }
            }

            /*anti-clockwise*/
            int subber = now_x; if (subber == 1)

            {
                subber = 24;
            }
            else
            {
                subber = now_x - 1;
            }

            for (; ; subber--)
            {
                if (subber == 1 && subber != now_x)
                {
                    if (Board.condition_matrix[subber, now_y] == DieClass.NO_DIE)
                    {
                        arr[counter++] = subber + "_" + now_y;
                    }
                    else if (DieClass.colorCheck(subber, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = subber + "_" + now_y; break;
                    }                                                 //home has die but different color

                    subber = 24;
                    if (Board.condition_matrix[subber, now_y] == DieClass.NO_DIE && subber != now_x)
                    {
                        arr[counter++] = subber + "_" + now_y;
                    }
                    else if (DieClass.colorCheck(subber, now_y) == color) //home has die but same color
                    {
                        break;
                    }
                    else
                    {
                        arr[counter++] = subber + "_" + now_y; break;
                    }                                                 //home has die but different color
                }
                else if (Board.condition_matrix[subber, now_y] == DieClass.NO_DIE && subber != now_x)
                {
                    arr[counter++] = subber + "_" + now_y;
                }
                else if (DieClass.colorCheck(subber, now_y) == color) //home has die but same color
                {
                    break;
                }
                else
                {
                    arr[counter++] = subber + "_" + now_y; break;
                }                                                 //home has die but different color

                if (subber >= 25 || subber <= 0 || subber == now_x)
                {
                    break;
                }
            }
            return(arr);
        }