class TutorialModDialogsBlocks { constructor (runtime) { /** * The runtime instantiating this block package. * @type {Runtime} */ this.runtime = runtime; } /** * Retrieve the block primitives implemented by this package. * @return {object.} Mapping of opcode to Function. */ getPrimitives () { return { dialogs_alert: this.alertBlock, dialogs_prompt: this.promptBlock, dialogs_confirm: this.confirmBlock, dialogs_whileconfirmed: this.whileConfirmedBlock, dialogs_randomchoice: this.randomChoice }; } alertBlock (args, util) { // eslint-disable-next-line alert(args.MESSAGE); } promptBlock (args, util) { // eslint-disable-next-line return prompt(args.MESSAGE); } confirmBlock (args, util) { // eslint-disable-next-line return confirm(args.MESSAGE); } whileConfirmedBlock (args, util) { // eslint-disable-next-line if (confirm(args.MESSAGE)) { util.startBranch(1, true); } } randomChoice (args, util) { const randomValue = Math.floor((Math.random() * 3) + 1); util.startBranch(randomValue, false); } } module.exports = TutorialModDialogsBlocks;