makeHtml() {
    const gameBoard = $('#game-board'); // Get the game-board div
    gameBoard.svg(); // Attach svg canvas
    const svg = gameBoard.svg('get'); // Get the svg canvas
    // Inline svg will occupy container width, so no need to set width and
    // height attributes here.
    svg.configure({viewBox: '0 0 160 144'}, true);
    const grp = svg.group('theBoard');
    switch (this.boardType) {
      case 'Triangle':
      default:
        const pitchX = 30;
        const pitchY = 26; // (pitchY/pitchX = sin(60deg))
        const radius = 10;
        for (let i=0; i<this.numPegs; i++) {
          const curPeg = this.pegs[i];
          const left = 80 - (pitchX/2)*curPeg.row;
          const cy = 20 + pitchY*curPeg.row;
          const cx = left + pitchX*curPeg.col;
          // const curCircle = $('<circle></circle>');
          const pegState = curPeg.isEmpty ? 'empty':'occupied';
          const pegId = curPeg.id;
          const txtId = pegId +'-txt';
          const pegIndex = curPeg.index;
          svg.circle(grp, cx, cy, radius,
              {id: pegId, index: pegIndex, state: pegState});
          svg.text(grp, cx, cy, pegId,
              {id: txtId, index: pegIndex, state: pegState,
                stroke: 'white', textAnchor: 'middle'});
        }
        break;
    }
    const movesLog = $('<p></p>');
    movesLog.attr('id', 'move-log');
    movesLog.text('Moves:');
    gameBoard.append(movesLog);
  }
/** Render the HTML for the board */
Render the HTML for the board
Render the HTML for the board
makeHtml() {
    const gameBoard = $('#game-board'); 
    gameBoard.svg(); 
    const svg = gameBoard.svg('get'); 
    svg.configure({viewBox: '0 0 160 144'}, true);
    const grp = svg.group('theBoard');
    switch (this.boardType) {
      case 'Triangle':
      default:
        const pitchX = 30;
        const pitchY = 26; 
        const radius = 10;
        for (let i=0; i<this.numPegs; i++) {
          const curPeg = this.pegs[i];
          const left = 80 - (pitchX/2)*curPeg.row;
          const cy = 20 + pitchY*curPeg.row;
          const cx = left + pitchX*curPeg.col;
          const pegState = curPeg.isEmpty ? 'empty':'occupied';
          const pegId = curPeg.id;
          const txtId = pegId +'-txt';
          const pegIndex = curPeg.index;
          svg.circle(grp, cx, cy, radius,
              {id: pegId, index: pegIndex, state: pegState});
          svg.text(grp, cx, cy, pegId,
              {id: txtId, index: pegIndex, state: pegState,
                stroke: 'white', textAnchor: 'middle'});
        }
        break;
    }
    const movesLog = $('<p></p>');
    movesLog.attr('id', 'move-log');
    movesLog.text('Moves:');
    gameBoard.append(movesLog);
  }
makeHtml ( ) { const gameBoard = $ ( '#game-board' ) ; gameBoard . svg ( ) ; const svg = gameBoard . svg ( 'get' ) ; svg . configure ( { viewBox : '0 0 160 144' } , true ) ; const grp = svg . group ( 'theBoard' ) ; switch ( this . boardType ) { case 'Triangle' : default : const pitchX = 30 ; const pitchY = 26 ; const radius = 10 ; for ( let i = 0 ; i < this . numPegs ; i ++ ) { const curPeg = this . pegs [ i ] ; const left = 80 - ( pitchX / 2 ) * curPeg . row ; const cy = 20 + pitchY * curPeg . row ; const cx = left + pitchX * curPeg . col ; const pegState = curPeg . isEmpty ? 'empty' : 'occupied' ; const pegId = curPeg . id ; const txtId = pegId + '-txt' ; const pegIndex = curPeg . index ; svg . circle ( grp , cx , cy , radius , { id : pegId , index : pegIndex , state : pegState } ) ; svg . text ( grp , cx , cy , pegId , { id : txtId , index : pegIndex , state : pegState , stroke : 'white' , textAnchor : 'middle' } ) ; } break ; } const movesLog = $ ( '<p></p>' ) ; movesLog . attr ( 'id' , 'move-log' ) ; movesLog . text ( 'Moves:' ) ; gameBoard . append ( movesLog ) ; }
Render the HTML for the board
Render the HTML for the board
// Get the game-board div // Attach svg canvas // Get the svg canvas // Inline svg will occupy container width, so no need to set width and // height attributes here. // (pitchY/pitchX = sin(60deg)) // const curCircle = $('<circle></circle>');