/**
 * @license Licensed under the Apache License, Version 2.0 (the "License"):
 *          http://www.apache.org/licenses/LICENSE-2.0
 */

/**
 * @fileoverview Block for the Arduino map functionality.
 *     The Arduino built in functions syntax can be found at:
 *     http://arduino.cc/en/Reference/HomePage
 *
 * TODO: This block can be improved to set the new range properly.
 */
'use strict';

goog.require('Blockly.Blocks');
goog.require('Blockly.Types');


/** Common HSV hue for all blocks in this category. */
Blockly.Blocks.variables.HUE = 330;

Blockly.Blocks['define'] = {
  // init: function() {
  //   this.appendValueInput("define_init")
  //       .setCheck("define_var")
  //       .appendField("define");
  //   this.appendDummyInput()
  //       .appendField("for");
  //   this.appendValueInput("define_variable")

  //       // .setCheck(["Number", "String"]);
  //       // .setCheck(["Number", Blockly.Types.TEXT.checkList.concat('Array')]);
  //       // .setCheck(Blockly.Types.TEXT.checkList.concat('Array');
  //       // .setCheck(Blockly.Types.TEXT);
  
  //   this.setPreviousStatement(true, null);
  //   this.setNextStatement(true, null);
  //   this.setColour(255);
  //   this.setTooltip('LE');
  //   this.setHelpUrl('');
  // }

  init: function() {
    this.appendValueInput("define_init")
        .setCheck("define_var")
        .appendField("define");
    this.appendDummyInput();
    this.appendValueInput("define_variable")
        .setCheck(["String", "Number"])
        .appendField("for");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(255);
    this.setTooltip('LE');
    this.setHelpUrl('');
  }
};

Blockly.Blocks['define_var'] = {
  init: function() {
    this.appendDummyInput()
        .appendField(new Blockly.FieldVariable("item"), "define_variable");
    this.setOutput(true, null);
    this.setColour(210);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};