/**
 * Turtles!
 */
//Blockly.HSV_SATURATION = 0.523;
//Blockly.HSV_VALUE = 0.847;
var Turtle_HUE = 237;

Blockly.Blocks['turtle_create'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("create new turtle");
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setOutput(false);
    this.setInputsInline(true);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};



Blockly.Blocks['turtle_color'] = {
  init: function() {
    this.appendValueInput("COLOR")
        .setCheck(null)
        .appendField("make turtle color");
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setOutput(false);
    this.setInputsInline(true);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};


Blockly.Blocks['turtle_forward'] = {
  init: function() {
    this.appendValueInput("DISTANCE")
        .setCheck(null)
        .appendField("make turtle move forward by");
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setInputsInline(true);
    this.setOutput(false);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};


Blockly.Blocks['turtle_backward'] = {
  init: function() {
    this.appendValueInput("DISTANCE")
        .setCheck(null)
        .appendField("make turtle move backward by");
    this.setPreviousStatement(true);
    this.setInputsInline(true);
    this.setNextStatement(true);
    this.setOutput(false);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};


Blockly.Blocks['turtle_left'] = {
  init: function() {
    this.appendValueInput("ANGLE")
        .setCheck(null)
        .appendField("make turtle turn left by");
    this.appendDummyInput("")
        .appendField("degree");
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setInputsInline(true);
    this.setOutput(false);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};


Blockly.Blocks['turtle_right'] = {
  init: function() {
    this.appendValueInput("ANGLE")
        .setCheck(null)
        .appendField("make turtle turn right by");
    this.appendDummyInput("")
        .appendField("degree");
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setInputsInline(true);
    this.setOutput(false);
    this.setColour(Turtle_HUE);
    this.setTooltip('');
    this.setHelpUrl('');
  }
};


Blockly.Blocks['turtle_shape'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("make turtle shape")
        .appendField(new Blockly.FieldDropdown([["turtle","turtle"], ["circle","circle"], ["classic","classic"], ["square","square"], ["triangle","triangle"]]), "Shape");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_pen'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("make turtle pen")
        .appendField(new Blockly.FieldDropdown([["up","up"], ["down","down"]]), "Pen");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_circle'] = {
  init: function() {
    this.appendValueInput("RADIUS")
        .setCheck("Number")
        .appendField("make turtle circle with radius:");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_goto'] = {
  init: function() {
    this.appendValueInput("X")
        .setCheck("Number")
        .appendField("make turtle goto location X:");
    this.appendValueInput("Y")
        .setCheck("Number")
        .appendField(",Y:");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_pos'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("pos");
    this.setOutput(true, 'Turtle_Position');
    this.setColour(Turtle_HUE);
    this.setTooltip('Turtle position');
    this.setHelpUrl('');
  }
};




/*PythonToBlocks.KNOWN_ATTR_FUNCTIONS['pos'] = function(func, args, keywords, starargs, kwargs, node) {
  if (args.length != 0) {
      throw new Error("Incorrect number of arguments to turtle.pos!");
  }

    return [block("turtle_pos", {}, {}, {
  }, {"inline": "true"})];
}*/


Blockly.Blocks['turtle_stamp'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("make turtle stamp");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};



Blockly.Blocks['turtle_begin_fill'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("make turtle begin fill");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_end_fill'] = {
  init: function() {
    this.appendDummyInput()
        .appendField("make turtle end fill");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};


Blockly.Blocks['turtle_speed'] = {
  init: function() {
    this.appendValueInput("SPEED")
        .setCheck("Number")
        .appendField("make turtle speed");
    this.setInputsInline(true);
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(Turtle_HUE);
 this.setTooltip("");
 this.setHelpUrl("");
  }
};
