예제 #1
0
  public ArrayList<Position> getMoves(Position p) {
    String e = ask("moves:" + p.getX() + ":" + p.getY() + ";");
    ArrayList<Position> m = new ArrayList<Position>();

    String[] o = e.split(":");
    for (int i = 0; i < o.length; i = i + 2) {
      m.add(new Position(Integer.parseInt(o[i]), Integer.parseInt(o[i + 1])));
    }

    return m;
  }
예제 #2
0
 public void move(Piece p, Position pos) {
   String s =
       ask(
           "move:"
               + p.getPos().getX()
               + ":"
               + p.getPos().getY()
               + ":"
               + pos.getX()
               + ":"
               + pos.getY()
               + ";");
   System.out.println(s);
 }
예제 #3
0
  // board stuff
  public Piece getNet(Position p) {
    Piece tmp = null;

    String b = ask("get:" + p.getX() + ":" + p.getY() + ";");
    String[] cms = b.split(":");

    if (cms[0].equals("n")) {
      return tmp;
    }
    char[] chr = cms[0].toCharArray();
    char c = chr[0];
    Player s = new Player(cms[2].equals("b"), null);
    int l = Integer.parseInt(cms[1]);

    if (c == 'P') tmp = new Pawn(p, l, s);
    else if (c == 'R') tmp = new Rook(p, l, s);
    else if (c == 'K') tmp = new Knight(p, l, s);
    else if (c == 'B') tmp = new Bishop(p, l, s);
    else if (c == 'Q') tmp = new Queen(p, l, s);
    else if (c == '!') tmp = new King(p, l, s);

    return tmp;
  }