Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove craft "while block ahead" #23502

Merged
merged 2 commits into from Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions apps/src/craft/agent/blocks.js
Expand Up @@ -186,36 +186,6 @@ exports.install = function (blockly, blockInstallOptions) {
return 'destroyBlock(\'block_id_' + this.id + '\');\n';
};

blockly.Blocks.craft_whileBlockAhead = {
helpUrl: '',
init: function () {
var dropdownOptions = keysToDropdownOptions(craftBlockOptions.ifBlockOptions || allDropdownBlocks);
var dropdown = new blockly.FieldDropdown(dropdownOptions);
dropdown.setValue(dropdownOptions[0][1]);

this.setHSV(322, 0.90, 0.95);
this.appendDummyInput()
.appendTitle(i18n.blockWhileXAheadWhile())
.appendTitle(dropdown, 'TYPE')
.appendTitle(i18n.blockWhileXAheadAhead());
this.appendStatementInput('DO')
.appendTitle(i18n.blockWhileXAheadDo());
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};

blockly.Generator.get('JavaScript').craft_whileBlockAhead = function () {
var innerCode = blockly.Generator.get('JavaScript').statementToCode(this, 'DO');
var blockType = this.getTitleValue('TYPE');
return 'whileBlockAhead(\'block_id_' + this.id + '\',\n"' +
blockType + '", ' +
' function() { '+
innerCode +
' }' +
');\n';
};

blockly.Blocks.craft_ifBlockAhead = {
helpUrl: '',
init: function () {
Expand Down
15 changes: 0 additions & 15 deletions apps/src/craft/agent/craft.js
Expand Up @@ -693,22 +693,7 @@ export default class Craft {
destroyBlock: function (blockID) {
appCodeOrgAPI.destroyBlock(studioApp().highlight.bind(studioApp(), blockID), 'PlayerAgent');
},
whilePathAhead: function (blockID, callback) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.whilePathAhead(studioApp().highlight.bind(studioApp(), blockID),
'',
'PlayerAgent',
callback);
},
whileBlockAhead: function (blockID, blockType, callback) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.whilePathAhead(studioApp().highlight.bind(studioApp(), blockID),
blockType,
'PlayerAgent',
callback);
},
ifLavaAhead: function (callback, blockID) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.ifBlockAhead(studioApp().highlight.bind(studioApp(), blockID),
"lava",
'PlayerAgent',
Expand Down
38 changes: 0 additions & 38 deletions apps/src/craft/code-connection/utils.js
Expand Up @@ -187,44 +187,6 @@ const blockConversions = Object.freeze({
`);
},

craft_whileBlockAhead: function (xml) {
const statement = getChildNodeByName(xml, 'statement');
const next = getChildNodeByName(xml, 'next');
const title = getChildNodeByName(xml, 'title');

let blockType = title.textContent;
if (blockTypes[blockType]) {
blockType = blockTypes[blockType];
}

return (`
<block type="controls_whileUntil" inline="false">
<title name="MODE">WHILE</title>
<value name="BOOL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="craft_inspect">
<title name="DIR">forward</title>
</block>
</value>
<value name="B">
<block type="craft_getnameof" inline="false">
<value name="ITEM">
<block type="craft_block">
<title name="BLOCK">${blockType}</title>
</block>
</value>
</block>
</value>
</block>
</value>
${statement ? serialize(statement) : ''}
${next ? serialize(next) : ''}
</block>
`);
},

craft_ifBlockAhead: function (xml) {
const statement = getChildNodeByName(xml, 'statement');
const next = getChildNodeByName(xml, 'next');
Expand Down
30 changes: 0 additions & 30 deletions apps/src/craft/simple/blocks.js
Expand Up @@ -176,36 +176,6 @@ exports.install = function (blockly, blockInstallOptions) {
return 'shear(\'block_id_' + this.id + '\');\n';
};

blockly.Blocks.craft_whileBlockAhead = {
helpUrl: '',
init: function () {
var dropdownOptions = keysToDropdownOptions(craftBlockOptions.ifBlockOptions || allDropdownBlocks);
var dropdown = new blockly.FieldDropdown(dropdownOptions);
dropdown.setValue(dropdownOptions[0][1]);

this.setHSV(322, 0.90, 0.95);
this.appendDummyInput()
.appendTitle(i18n.blockWhileXAheadWhile())
.appendTitle(dropdown, 'TYPE')
.appendTitle(i18n.blockWhileXAheadAhead());
this.appendStatementInput('DO')
.appendTitle(i18n.blockWhileXAheadDo());
this.setPreviousStatement(true);
this.setNextStatement(true);
}
};

blockly.Generator.get('JavaScript').craft_whileBlockAhead = function () {
var innerCode = blockly.Generator.get('JavaScript').statementToCode(this, 'DO');
var blockType = this.getTitleValue('TYPE');
return 'whileBlockAhead(\'block_id_' + this.id + '\',\n"' +
blockType + '", ' +
' function() { '+
innerCode +
' }' +
');\n';
};

blockly.Blocks.craft_ifBlockAhead = {
helpUrl: '',
init: function () {
Expand Down
15 changes: 0 additions & 15 deletions apps/src/craft/simple/craft.js
Expand Up @@ -649,22 +649,7 @@ Craft.executeUserCode = function () {
tillSoil: function (blockID) {
appCodeOrgAPI.tillSoil(studioApp().highlight.bind(studioApp(), blockID), 'Player');
},
whilePathAhead: function (blockID, callback) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.whilePathAhead(studioApp().highlight.bind(studioApp(), blockID),
'',
'Player',
callback);
},
whileBlockAhead: function (blockID, blockType, callback) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.whilePathAhead(studioApp().highlight.bind(studioApp(), blockID),
blockType,
'Player',
callback);
},
ifLavaAhead: function (callback, blockID) {
// if resurrected, move blockID be last parameter to fix "Show Code"
appCodeOrgAPI.ifBlockAhead(studioApp().highlight.bind(studioApp(), blockID),
"lava",
'Player',
Expand Down
31 changes: 1 addition & 30 deletions apps/test/unit/craft/code-connection/utilsTest.js
Expand Up @@ -21,11 +21,6 @@ describe('convertBlocksXml', () => {
<block type="craft_destroyBlock">
</block>
</xml>`,
`<xml>
<block type="craft_whileBlockAhead">
<title name="TYPE">dirt</title>
</block>
</xml>`,
];

const expected = [
Expand All @@ -44,30 +39,6 @@ describe('convertBlocksXml', () => {
<title name="DIR">forward</title>
</block>
</xml>`,
`<xml>
<block type="controls_whileUntil" inline="false">
<title name="MODE">WHILE</title>
<value name="BOOL">
<block type="logic_compare" inline="true">
<title name="OP">EQ</title>
<value name="A">
<block type="craft_inspect">
<title name="DIR">forward</title>
</block>
</value>
<value name="B">
<block type="craft_getnameof" inline="false">
<value name="ITEM">
<block type="craft_block">
<title name="BLOCK">dirt</title>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</xml>`,
];

sources.forEach((source, i) => {
Expand All @@ -93,7 +64,7 @@ describe('convertBlocksXml', () => {
blocks.forEach((block, i) => {
const xml = `
<xml>
<block type="craft_whileBlockAhead">
<block type="craft_ifBlockAhead">
<title name="TYPE">${block}</title>
</block>
</xml>
Expand Down
1 change: 0 additions & 1 deletion dashboard/app/models/levels/craft.rb
Expand Up @@ -610,7 +610,6 @@ def common_blocks(type)
<<-XML.chomp
#{level_specific_blocks}
<category name="Loops">
<block type='craft_whileBlockAhead'></block>
<block type='controls_repeat'>
<title name='TIMES'>5</title>
</block>
Expand Down