js/decklist/main.js
// note: does not duplicate entries found in both arrays; combines them instead
does not duplicate entries found in both arrays; combines them instead
does not duplicate entries found in both arrays ; combines them instead
function mainAndSide() {
  combined = $.extend(true,[],maindeck);
  sideQuants = $.extend(true,[],sideboard);
  combined.map(addSideQuants);
  combined = combined.concat(sideQuants);
  return combined;
  function addSideQuants(element) {
    foundSideElement = false;
    for (i = 0; i < sideQuants.length && sideQuants.length && foundSideElement === false; i++) {
      if (sideQuants[i][0] === element[0]) {
        foundSideElement = i;
      }
    }
    if (typeof foundSideElement === 'number') {
      element[1] = (parseInt(element[1]) + parseInt(sideQuants[foundSideElement][1])).toString();
      sideQuants.splice(foundSideElement, 1);
    }
    return element;
  }
}
function mainAndSide ( ) { combined = $ . extend ( true , [ ] , maindeck ) ; sideQuants = $ . extend ( true , [ ] , sideboard ) ; combined . map ( addSideQuants ) ; combined = combined . concat ( sideQuants ) ; return combined ; function addSideQuants ( element ) { foundSideElement = false ; for ( i = 0 ; i < sideQuants . length && sideQuants . length && foundSideElement === false ; i ++ ) { if ( sideQuants [ i ] [ 0 ] === element [ 0 ] ) { foundSideElement = i ; } } if ( typeof foundSideElement === 'number' ) { element [ 1 ] = ( parseInt ( element [ 1 ] ) + parseInt ( sideQuants [ foundSideElement ] [ 1 ] ) ) . toString ( ) ; sideQuants . splice ( foundSideElement , 1 ) ; } return element ; } }
note: does not duplicate entries found in both arrays; combines them instead
note : does not duplicate entries found in both arrays ; combines them instead
// make deep copies by value of the maindeck and sideboard // combine the cards! // mapping function; adds quantities of identical names in main/side // and removes those matching cards from sideQuants