Skip to content

Commit 5022aad

Browse files
committed
Merge pull request code-dot-org#5441 from code-dot-org/hoc2015moreedits
hoc2015: more level work. And progressConditions for specific item types
2 parents b25e159 + 96617e1 commit 5022aad

File tree

4 files changed

+107
-35
lines changed

4 files changed

+107
-35
lines changed

apps/i18n/studio/en_us.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"calloutPlaceTwoWhenTauntaun": "Can you make two Mynocks appear when you get a Tauntaun?",
3939
"calloutSetDroidAndSpeed": "Set your droid and its speed",
4040
"calloutFinishButton": "Click here when you are ready to share your game",
41+
"calloutBlocklyCategories": "You can click on Commands to see all your commands and Events to see all the events",
4142
"catActions": "Actions",
4243
"catCommands": "Commands",
4344
"catControl": "Loops",
@@ -173,7 +174,7 @@
173174
"hoc2015_add_characters_instructions": "\"I'm seeing signs of increased activity on this planet.\"",
174175
"hoc2015_add_characters_instructions2": "Add three Puffer Pigs to the planet. Then, go get them.",
175176
"hoc2015_multiply_characters_instructions": "\"They're multiplying!\"",
176-
"hoc2015_multiply_characters_instructions2": "Can you make two or more Mouse Droids appear every time R2-D2 gets one Mouse Droid? Get 20 Mouse Droids and score 2000 points.",
177+
"hoc2015_multiply_characters_instructions2": "Can you make two or more Mouse Droids appear every time R2-D2 gets one Mouse Droid? Get 20 Mouse Droids.",
177178
"hoc2015_chain_characters2_instructions": "\"It's up to you, R2-D2!\"",
178179
"hoc2015_chain_characters2_instructions2": "When you get a Tauntaun, make two or more Mynocks appear. Get 8 Mynocks.",
179180
"hoc2015_change_setting_instructions": "\"Time to visit another planet.\"",
@@ -714,7 +715,8 @@
714715
"failedChainCharactersTimeout": "You need to get 8 Mynocks. Can you make two (or more) of them appear every time you get a Tauntaun? Make it easier by adding more Mynocks.",
715716
"failedChainCharactersTimeoutGotSome": "Congratulations, you added code to make Mynocks. You can go to the next puzzle or try again to get 8 of them.",
716717
"failedMultiplyCharactersTimeout": "You need to get 20 Mouse Droids. Make sure you add two or more Mouse Droids every time you get one.",
718+
"failedMultiplyCharactersTimeoutBlockly": "You need to get 20 Mouse Droids. Use the \"add a Mouse Droid\" command inside the \"when get Mouse Droid\" event to add two or more Mouse Droids every time you get one.",
717719
"failedMultiplyCharactersTimeoutGotSome": "Congratulations, you added code to make Mouse Droids. You can go to the next puzzle or try again to get 20 Mouse Droids. Try making it easier by adding more of them! (Press and hold the keys on your keyboard (or screen) to move faster.)",
718720
"failedChangeSettingTimeout": "Get three Rebel Pilots to move on.",
719-
"failedChangeSettingSettings": "Make the game your own. To pass this puzzle, you need to change your droid and set the speed."
721+
"failedChangeSettingSettings": "Make the game your own. To pass this puzzle, you need to change your droid and set its speed."
720722
}

apps/src/studio/Item.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ var Item = function (options) {
2121
this.height = options.height || 50;
2222
this.width = options.width || 50;
2323

24+
this.className = options.className;
25+
26+
if (Studio.trackedBehavior.createdItems[this.className] === undefined) {
27+
Studio.trackedBehavior.createdItems[this.className] = 0;
28+
}
29+
Studio.trackedBehavior.createdItems[this.className]++;
30+
2431
this.spritesCounterclockwise = options.spritesCounterclockwise || false;
2532

2633
/**
@@ -62,8 +69,8 @@ Item.prototype.getDirectionFrame = function() {
6269
}
6370
}
6471

65-
var frameDirTable = this.spritesCounterclockwise ?
66-
constants.frameDirTableWalkingWithIdleCounterclockwise :
72+
var frameDirTable = this.spritesCounterclockwise ?
73+
constants.frameDirTableWalkingWithIdleCounterclockwise :
6774
constants.frameDirTableWalkingWithIdleClockwise;
6875

6976
return frameDirTable[this.displayDir];
@@ -87,7 +94,7 @@ Item.prototype.createElement = function (parentElement) {
8794
* options.
8895
*/
8996
Item.prototype.update = function () {
90-
97+
9198
// Do we have an active location in grid coords? If not, determine it.
9299
if (this.gridX === undefined) {
93100
this.gridX = Math.floor(this.x / Studio.SQUARE_SIZE);
@@ -110,10 +117,10 @@ Item.prototype.update = function () {
110117
if (this.destGridX !== undefined) {
111118
// Draw the item's destination grid square.
112119
Studio.drawDebugRect(
113-
"roamGridDest",
114-
this.destGridX * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
115-
this.destGridY * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
116-
Studio.SQUARE_SIZE,
120+
"roamGridDest",
121+
this.destGridX * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
122+
this.destGridY * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
123+
Studio.SQUARE_SIZE,
117124
Studio.SQUARE_SIZE);
118125
}
119126

@@ -152,10 +159,10 @@ Item.prototype.update = function () {
152159
var bufferDistance = 60;
153160

154161
// The item can just go up/down/left/right.. no diagonals.
155-
var candidateGridLocations = [
156-
{row: -1, col: 0},
162+
var candidateGridLocations = [
163+
{row: -1, col: 0},
157164
{row: +1, col: 0},
158-
{row: 0, col: -1},
165+
{row: 0, col: -1},
159166
{row: 0, col: +1}];
160167

161168
for (var candidateIndex = 0; candidateIndex < candidateGridLocations.length; candidateIndex++) {
@@ -199,10 +206,10 @@ Item.prototype.update = function () {
199206

200207
if (candidate.score > 0) {
201208
Studio.drawDebugRect(
202-
"roamGridPossibleDest",
203-
candidateX * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
204-
candidateY * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
205-
Studio.SQUARE_SIZE,
209+
"roamGridPossibleDest",
210+
candidateX * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
211+
candidateY * Studio.SQUARE_SIZE + Studio.HALF_SQUARE,
212+
Studio.SQUARE_SIZE,
206213
Studio.SQUARE_SIZE);
207214
}
208215
candidates.push(candidate);
@@ -298,7 +305,13 @@ Item.prototype.beginRemoveElement = function () {
298305
*/
299306
Item.prototype.removeElement = function() {
300307
this.animation_.removeElement();
308+
301309
Studio.trackedBehavior.removedItemCount++;
310+
311+
if (Studio.trackedBehavior.removedItems[this.className] === undefined) {
312+
Studio.trackedBehavior.removedItems[this.className] = 0;
313+
}
314+
Studio.trackedBehavior.removedItems[this.className]++;
302315
};
303316

304317
/**

apps/src/studio/levels.js

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,7 @@ levels.js_hoc2015_score =
23172317
},
23182318
'codeFunctions': {
23192319
'playSound': null,
2320-
'addPoints': { params: ["300"] },
2320+
'addPoints': { params: ["100"] },
23212321

23222322
'whenGetRebelPilot': null
23232323
},
@@ -2374,16 +2374,7 @@ levels.js_hoc2015_score =
23742374
{ required: { 'timedOut': true, 'allGoalsVisited': false },
23752375
result: { success: false, message: msg.failedScoreTimeout() } },
23762376

2377-
// got all of the goals, and at least one point
2378-
{ required: { 'allGoalsVisited': true, 'currentPointsAtOrAbove': 1 },
2379-
result: {
2380-
success: false,
2381-
message: msg.failedScoreGoals(), // JS: points done in wrong place
2382-
blocklyMessage: msg.failedScoreScoreBlockly()
2383-
}
2384-
},
2385-
2386-
// got all the goals, but 0 points
2377+
// got all the goals, but not enough points
23872378
{ required: { 'allGoalsVisited': true },
23882379
result: {
23892380
success: false,
@@ -2637,6 +2628,7 @@ levels.js_hoc2015_chain_characters = {
26372628
'playSound': null,
26382629

26392630
'whenGetTauntaun': null,
2631+
'whenGetMynock': null,
26402632
},
26412633
'startBlocks': [
26422634
'addCharacter("Tauntaun");',
@@ -2681,10 +2673,15 @@ levels.js_hoc2015_chain_characters = {
26812673
'timeoutFailureTick': 1800, // 60 seconds
26822674
'showTimeoutRect': true,
26832675
'progressConditions' : [
2684-
{ required: { 'collectedItemsAtOrAbove': 8 },
2676+
{ required: { 'collectedSpecificItemsAtOrAbove': { className: "mynock", count: 8 } },
26852677
result: { success: true, message: msg.successCharacter1() } },
2686-
{ required: {'timedOut': true, collectedItemsAtOrAbove: 5 },
2678+
{ required: {'timedOut': true, collectedSpecificItemsAtOrAbove: { className: "mynock", count: 5 } },
26872679
result: { success: false, canPass: true, message: msg.failedChainCharactersTimeoutGotSome() } },
2680+
{ required: {
2681+
'collectedSpecificItemsAtOrAbove': { className: "tauntaun", count: 4 },
2682+
'createdSpecificItemsBelow': { className: "mynock", count: 5 }
2683+
},
2684+
result: { success: false, message: msg.failedChainCharactersTimeout() } },
26882685
{ required: { 'timedOut': true },
26892686
result: { success: false, message: msg.failedChainCharactersTimeout() } },
26902687
],
@@ -2758,10 +2755,20 @@ levels.js_hoc2015_multiply_characters = {
27582755
'progressConditions' : [
27592756
{ required: { 'collectedItemsAtOrAbove': 20 },
27602757
result: { success: true, message: msg.successCharacter1() } },
2758+
{ required: {
2759+
'collectedSpecificItemsAtOrAbove': { className: "mousedroid", count: 1 },
2760+
'createdSpecificItemsBelow': { className: "mousedroid", count: 2 }
2761+
},
2762+
result: { success: false, message: msg.failedMultiplyCharactersTimeout() } },
27612763
{ required: { 'timedOut': true, 'collectedItemsAtOrAbove': 2},
27622764
result: { success: false, canPass: true, message: msg.failedMultiplyCharactersTimeoutGotSome() } },
27632765
{ required: { 'timedOut': true },
2764-
result: { success: false, message: msg.failedMultiplyCharactersTimeout() } },
2766+
result: {
2767+
success: false,
2768+
message: msg.failedMultiplyCharactersTimeout(),
2769+
blocklyMessage: msg.failedMultiplyCharactersTimeoutBlockly()
2770+
}
2771+
},
27652772
],
27662773
'callouts': [
27672774
{
@@ -3203,7 +3210,7 @@ levels.hoc2015_blockly_9 = utils.extend(levels.js_hoc2015_score, {
32033210
</next></block>',
32043211
toolbox:
32053212
tb('<block type="studio_playSound"></block> \
3206-
<block type="studio_addPoints"><title name="VALUE">300</title></block>'),
3213+
<block type="studio_addPoints"><title name="VALUE">100</title></block>'),
32073214
requiredBlocks: [
32083215
// TODO: addPoints
32093216
],
@@ -3345,14 +3352,15 @@ levels.hoc2015_blockly_12 = utils.extend(levels.js_hoc2015_chain_characters, {
33453352
<block type="studio_addPoints"><title name="VALUE">100</title></block> \
33463353
<block type="studio_removePoints"><title name="VALUE">100</title></block> \
33473354
<block type="studio_playSound"></block> \
3348-
<block type="studio_whenGetCharacter"><title name="VALUE">tauntaun</title></block>'),
3355+
<block type="studio_whenGetCharacter"><title name="VALUE">tauntaun</title></block> \
3356+
<block type="studio_whenGetCharacter"><title name="VALUE">mynock</title></block>'),
33493357
requiredBlocks: [
33503358
// TODO: addCharacter (check for mouse param?), addPoints
33513359
],
33523360
callouts: [
33533361
{
33543362
id: 'playlab:hoc2015_blockly_12:calloutPlaceTwoWhenTauntaun',
3355-
element_id: '[block-id="11"]',
3363+
element_id: '[block-id="12"]',
33563364
hide_target_selector: '.blocklyDraggable',
33573365
qtip_config: {
33583366
content: {
@@ -3536,6 +3544,23 @@ levels.hoc2015_blockly_15 = utils.extend(levels.js_hoc2015_event_free, {
35363544
at: 'bottom right',
35373545
}
35383546
}
3539-
}
3547+
},
3548+
{
3549+
id: 'playlab:hoc2015_blockly_15:categories',
3550+
element_id: '.blocklyTreeRoot',
3551+
qtip_config: {
3552+
content: {
3553+
text: msg.calloutBlocklyCategories(),
3554+
},
3555+
position: {
3556+
my: 'top left',
3557+
at: 'bottom right',
3558+
'adjust': {
3559+
'x': -10,
3560+
'y': 0
3561+
}
3562+
}
3563+
}
3564+
},
35403565
]
35413566
});

apps/src/studio/studio.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ function handleActorCollisionsWithCollidableList (
12061206

12071207
if (list.length === 1) {
12081208
callHandler('whenGetAllItems');
1209+
Studio.trackedBehavior.gotAllItems = true;
12091210
}
12101211

12111212
var className = collidable.className;
@@ -2105,7 +2106,10 @@ Studio.reset = function(first) {
21052106
hasWonGame: false,
21062107
hasLostGame: false,
21072108
allGoalsVisited: false,
2108-
timedOut: false
2109+
timedOut: false,
2110+
gotAllItems: false,
2111+
removedItems: {},
2112+
createdItems: {}
21092113
};
21102114

21112115
// Reset the record of the last direction that the user moved the sprite.
@@ -5307,6 +5311,34 @@ Studio.conditionSatisfied = function(required) {
53075311
return false;
53085312
}
53095313

5314+
if (valueName === 'collectedSpecificItemsAtOrAbove' &&
5315+
(tracked.removedItems[value.className] === undefined ||
5316+
tracked.removedItems[value.className] < value.count)) {
5317+
return false;
5318+
}
5319+
5320+
if (valueName == 'collectedSpecificItemsBelow' &&
5321+
tracked.removedItems[value.className] !== undefined &&
5322+
tracked.removedItems[value.className] >= value.count) {
5323+
return false;
5324+
}
5325+
5326+
if (valueName === 'createdSpecificItemsAtOrAbove' &&
5327+
(tracked.createdItems[value.className] === undefined ||
5328+
tracked.createdItems[value.className] < value.count)) {
5329+
return false;
5330+
}
5331+
5332+
if (valueName == 'createdSpecificItemsBelow' &&
5333+
tracked.createdItems[value.className] !== undefined &&
5334+
tracked.createdItems[value.className] >= value.count) {
5335+
return false;
5336+
}
5337+
5338+
if (valueName == 'gotAllItems' && tracked.gotAllItems !== value) {
5339+
return false;
5340+
}
5341+
53105342
if (valueName === 'touchedHazardsAtOrAbove' && tracked.touchedHazardCount < value) {
53115343
return false;
53125344
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy