Esempio n. 1
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View view = convertView;
   if (view == null) {
     view = new ImageView(Model.getInstance().getClientCommand().getContext());
   }
   switch (checkersField[(int) position / 8][(int) position % 8]) {
     case 1:
       {
         ((ImageView) view).setImageResource(R.drawable.white11);
         break;
       }
     case 2:
       {
         ((ImageView) view).setImageResource(R.drawable.black11);
         break;
       }
     case 11:
       {
         ((ImageView) view).setImageResource(R.drawable.white21);
         break;
       }
     case 22:
       {
         ((ImageView) view).setImageResource(R.drawable.black21);
         break;
       }
     case 0:
       {
         ((ImageView) view).setImageResource(R.drawable.blackcell1);
         break;
       }
     case -1:
       {
         ((ImageView) view).setImageResource(R.drawable.whitecell1);
         break;
       }
     case 101:
       {
         ((ImageView) view).setImageResource(R.drawable.white11_1);
         break;
       }
     case 102:
       {
         ((ImageView) view).setImageResource(R.drawable.black11_1);
         break;
       }
     case 111:
       {
         ((ImageView) view).setImageResource(R.drawable.white21_1);
         break;
       }
     case 122:
       {
         ((ImageView) view).setImageResource(R.drawable.black21_1);
         break;
       }
     default:
       {
         break;
       }
   }
   return view;
 }
Esempio n. 2
0
 public void clientTurn(int row, int column) {
   if (!firstTurn) {
     firstTurn = isSelected(row, column);
   } else {
     if (checkersField[firstRow][firstColumn] >= 100) checkersField[firstRow][firstColumn] -= 100;
     if (noMulti && !checkToKillAll() && turn(row, column)) {
       setChips(row, column);
       model
           .getClient()
           .sendMessage(
               "@turn;"
                   + firstRow
                   + ";"
                   + firstColumn
                   + ";"
                   + row
                   + ";"
                   + column
                   + ";"
                   + checkersField[row][column]
                   + ";");
       firstTurn = false;
       turn = false;
     } else if (noMulti
         && (checkersField[row][column] == chip || checkersField[row][column] == chip * 10 + 1)) {
       firstTurn = isSelected(row, column);
     } else if (killTurn(row, column)) {
       if (checkersField[firstRow][firstColumn] == chip) {
         row = firstRow + 2 * killRow;
         column = firstColumn + 2 * killColumn;
       }
       setChips(row, column);
       checkersField[firstRow + killRow][firstColumn + killColumn] = 0;
       if (checkToKill(row, column)) {
         model
             .getClient()
             .sendMessage(
                 "@kill;"
                     + firstRow
                     + ";"
                     + firstColumn
                     + ";"
                     + row
                     + ";"
                     + column
                     + ";"
                     + killRow
                     + ";"
                     + killColumn
                     + ";"
                     + "noend;"
                     + checkersField[row][column]
                     + ";");
         noMulti = false;
         firstRow = row;
         firstColumn = column;
         checkersField[firstRow][firstColumn] += 100;
         turn = true;
       } else {
         model
             .getClient()
             .sendMessage(
                 "@kill;"
                     + firstRow
                     + ";"
                     + firstColumn
                     + ";"
                     + row
                     + ";"
                     + column
                     + ";"
                     + killRow
                     + ";"
                     + killColumn
                     + ";"
                     + "end;"
                     + checkersField[row][column]
                     + ";");
         noMulti = true;
         firstTurn = false;
         turn = false;
       }
     }
   }
 }