Beispiel #1
0
 private void load(String[] cmdArray) {
   if (cmdArray.length < 2) {
     System.out.println("Need filename argument");
     return;
   }
   File file = new File(cmdArray[1]);
   try {
     FileInputStream fileStream = new FileInputStream(file);
     SgfReader reader = new SgfReader(fileStream, file, null, 0);
     String warnings = reader.getWarnings();
     if (warnings != null) System.out.print(warnings);
     GameTree tree = reader.getTree();
     GameInfo info = tree.getGameInfo(tree.getRoot());
     if (info.getHandicap() > 0) {
       System.out.println("Handicap games not supported");
       return;
     }
     if (!newGame(tree.getBoardSize())) return;
     send("komi " + info.getKomi());
     ConstNode node = tree.getRoot();
     while (node != null) {
       for (GoColor c : BLACK_WHITE) {
         for (GoPoint stone : node.getSetup(c)) if (!cmdPlay(c, stone)) return;
       }
       Move move = node.getMove();
       if (move != null && !cmdPlay(move.getColor(), move.getPoint())) return;
       node = node.getChildConst();
     }
     printBoard();
   } catch (FileNotFoundException e) {
     System.out.println("File not found: " + file);
   } catch (SgfError e) {
     System.out.println("Could not read file " + file + ": " + e.getMessage());
   }
 }