public void notifyMoveUndone(ImmutablePosition position) { if (DEBUG) System.out.println("ChGame: move taken back in position"); if (!m_ignoreNotifications) { m_cur = m_moves.goBack(m_cur, true); } }
private int getNumOfPliesToRoot(int node) { int plies = 0; while (node > 0) { node = m_moves.goBack(node, true); plies++; } return plies; }
private boolean goBackInLine(boolean silent) { if (DEBUG) System.out.println("goBackInLine"); int index = m_moves.goBack(m_cur, false); if (index != -1) { m_cur = index; // needs to be set before undoing the move to allow listeners to check for curNode m_ignoreNotifications = true; if (silent) m_position.setNotifyListeners(false); m_position.undoMove(); if (silent) m_position.setNotifyListeners(true); m_ignoreNotifications = false; return true; } else { return false; } }
private boolean goBack(boolean silent) { if (DEBUG) System.out.println("goBack"); int index = m_moves.goBack(m_cur, true); if (index != -1) { // if (m_position.canUndoMove()) { // do not rely on position since in silent mode it // is not updated // m_cur = m_moves.goBack(m_cur, true); m_cur = index; m_ignoreNotifications = true; if (silent) m_position.setNotifyListeners(false); m_position.undoMove(); if (silent) m_position.setNotifyListeners(true); m_ignoreNotifications = false; return true; } else { return false; } }
private int[] getNodesToRoot(int node) { int[] nodes; int i = 0; if (m_moves.getMove(node) != GameMoveModel.NO_MOVE) { nodes = new int[getNumOfPliesToRoot(node) + 1]; nodes[0] = node; i = 1; } else { nodes = new int [getNumOfPliesToRoot( node)]; // if we stand on a line end, don't include node in nodes to root i = 0; } for (; i < nodes.length; i++) { node = m_moves.goBack(node, true); nodes[i] = node; } return nodes; }