updateSetup method

void updateSetup(
  1. String fen
)

called when the initial board setup is changed with put() or remove(). modifies the SetUp and FEN properties of the header object. if the FEN is equal to the default position, the SetUp and FEN are deleted the setup is only updated if history.length is zero, ie moves haven't been made.

Implementation

void updateSetup(String fen) {
  if (history.length > 0) return;

  if (fen != DEFAULT_POSITION) {
    header['SetUp'] = '1';
    header['FEN'] = fen;
  } else {
    header.remove('SetUp');
    header.remove('FEN');
  }
}