import { ApiHelpers } from "../../../../interpreters/ApiHelpers.js";

export const setupAspiradorAPI = (scene, config) => {
  const delay = (config && config.animationSpeed) || 100;

  return function(interpreter, globalScope) {
    // Registra como funções globais para o aluno usar mover() em vez de Robo.mover()
    ApiHelpers.registerFunction(interpreter, globalScope, "mover", 
      ApiHelpers.createActionWrapper(scene, "mover", delay), true);

    ApiHelpers.registerFunction(interpreter, globalScope, "virar", 
      ApiHelpers.createActionWrapper(scene, "virar", delay), true);

    ApiHelpers.registerFunction(interpreter, globalScope, "caminhoBloqueado", 
      ApiHelpers.createConditionWrapper(scene, "checarBloqueio"), false);

    ApiHelpers.registerFunction(interpreter, globalScope, "aindaTemSujeira", 
      ApiHelpers.createConditionWrapper(scene, "aindaTemSujeira"), false);
      
    // Necessário para o highlight do Blockly
    ApiHelpers.registerFunction(interpreter, globalScope, "highlightBlock", 
      ApiHelpers.createHighlightWrapper(scene), false);
  };
};