|
8 | 8 | "name": "ObjectStack", |
9 | 9 | "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Line Hero Pack/Master/SVG/Videogames/Videogames_cards_game_solitaire_poker_blackjack_casino.svg", |
10 | 10 | "shortDescription": "An ordered list of objects and a shuffle action.", |
11 | | - "version": "0.0.8", |
| 11 | + "version": "0.1.0", |
12 | 12 | "description": [ |
13 | 13 | "It provides:", |
14 | 14 | "* Actions to modify a stack of objects", |
|
19 | 19 | "* Card games", |
20 | 20 | "* Fair randomness (for instance, to create a stack of predetermined bonus and randomize the order they appear)", |
21 | 21 | "", |
22 | | - "2 examples use it:", |
23 | | - "* A card system demonstration ([open the project online](https://editor.gdevelop.io/?project=example://card-system))", |
24 | | - "* A Klondike solitaire ([open the project online](https://editor.gdevelop.io/?project=example://klondike-solitaire))" |
| 22 | + "3 examples use it:", |
| 23 | + "* a card system demonstration ([open the project online](https://editor.gdevelop.io/?project=example://card-system))", |
| 24 | + "* a Klondike solitaire ([open the project online](https://editor.gdevelop.io/?project=example://klondike-solitaire))", |
| 25 | + "* a Zuma-like ([open the project online](https://editor.gdevelop.io/?project=example://smoothy))" |
25 | 26 | ], |
26 | 27 | "origin": { |
27 | 28 | "identifier": "ObjectStack", |
|
40 | 41 | "dependencies": [], |
41 | 42 | "eventsFunctions": [ |
42 | 43 | { |
43 | | - "description": "Check if the stack contains the object between a range.", |
| 44 | + "description": "Check if the stack contains the object between a range. The lower and upper bounds are included.", |
44 | 45 | "fullName": "Contain between a range", |
45 | 46 | "functionType": "Condition", |
46 | 47 | "name": "ContainsBetween", |
|
110 | 111 | ], |
111 | 112 | "objectGroups": [] |
112 | 113 | }, |
| 114 | + { |
| 115 | + "description": "Check if the stack contains the object at a height.", |
| 116 | + "fullName": "Contain at", |
| 117 | + "functionType": "Condition", |
| 118 | + "name": "ContainsAt", |
| 119 | + "sentence": "_PARAM3_ is into the stack of _PARAM1_ at _PARAM4_ ", |
| 120 | + "events": [ |
| 121 | + { |
| 122 | + "type": "BuiltinCommonInstructions::JsCode", |
| 123 | + "inlineCode": [ |
| 124 | + "const stackBehaviorName = eventsFunctionContext.getBehaviorName(\"Behavior\");", |
| 125 | + "/** @type {Hashtable<gdjs.RuntimeObject[]>} */", |
| 126 | + "const stackObjectsLists = eventsFunctionContext.getObjectsLists(\"Object\");", |
| 127 | + "/** @type {Hashtable<gdjs.RuntimeObject[]>} */", |
| 128 | + "const elementObjectsLists = eventsFunctionContext.getObjectsLists(\"Element\");", |
| 129 | + "", |
| 130 | + "// This code is duplicated from ContainsBetween because the picking wouldn't pass from one function to the other.", |
| 131 | + "const lowerBound = Math.max(0, eventsFunctionContext.getArgument(\"Height\"));", |
| 132 | + "let upperBound = eventsFunctionContext.getArgument(\"Height\");", |
| 133 | + "", |
| 134 | + "eventsFunctionContext.returnValue = gdjs.evtTools.object.twoListsTest(", |
| 135 | + " (stackObject, element, stackBehaviorName) => {", |
| 136 | + " const behavior = stackObject.getBehavior(stackBehaviorName);", |
| 137 | + " /** @type {gdjs.RuntimeObject[]} */", |
| 138 | + " const stack = behavior.objectStack;", |
| 139 | + " let found = false;", |
| 140 | + " upperBound = Math.min(upperBound, stack.length - 1);", |
| 141 | + " for (let i = lowerBound; i <= upperBound && !found; i++) {", |
| 142 | + " found = stack[i] === element;", |
| 143 | + " }", |
| 144 | + " return found;", |
| 145 | + " },", |
| 146 | + " stackObjectsLists,", |
| 147 | + " elementObjectsLists,", |
| 148 | + " false,", |
| 149 | + " stackBehaviorName", |
| 150 | + ");" |
| 151 | + ], |
| 152 | + "parameterObjects": "Object", |
| 153 | + "useStrict": true, |
| 154 | + "eventsSheetExpanded": true |
| 155 | + } |
| 156 | + ], |
| 157 | + "parameters": [ |
| 158 | + { |
| 159 | + "description": "Stack", |
| 160 | + "name": "Object", |
| 161 | + "type": "objectList" |
| 162 | + }, |
| 163 | + { |
| 164 | + "description": "Stack behavior", |
| 165 | + "name": "Behavior", |
| 166 | + "supplementaryInformation": "ObjectStack::ObjectStack", |
| 167 | + "type": "behavior" |
| 168 | + }, |
| 169 | + { |
| 170 | + "description": "Element", |
| 171 | + "name": "Element", |
| 172 | + "type": "objectList" |
| 173 | + }, |
| 174 | + { |
| 175 | + "description": "Height", |
| 176 | + "name": "Height", |
| 177 | + "type": "expression" |
| 178 | + } |
| 179 | + ], |
| 180 | + "objectGroups": [] |
| 181 | + }, |
113 | 182 | { |
114 | 183 | "description": "Check if an object is on the stack top.", |
115 | 184 | "fullName": "Stack top", |
|
399 | 468 | "/** @type {Map<gdjs.RuntimeObject> */", |
400 | 469 | "const objectSet = behavior.objectSet;", |
401 | 470 | "if (height < 0 || height > stack.length) {", |
402 | | - " log.error(`Tried to insert in the stack at ${height} where the stack is ${stack.length} height.`);", |
| 471 | + " console.error(`Tried to insert in the stack at ${height} where the stack is ${stack.length} height.`);", |
403 | 472 | " return;", |
404 | 473 | "}", |
405 | 474 | "for (const element of elements) {", |
|
548 | 617 | "fullName": "Move into the stack", |
549 | 618 | "functionType": "Action", |
550 | 619 | "name": "MoveInto", |
551 | | - "sentence": "Move the object of the stack of _PARAM3_ from:_PARAM5_ to:_PARAM6_ into the stack of _PARAM0_ at height: _PARAM2_", |
| 620 | + "sentence": "Move the objects of the stack of _PARAM3_ from:_PARAM5_ to:_PARAM6_ into the stack of _PARAM0_ at height: _PARAM2_", |
552 | 621 | "events": [ |
553 | 622 | { |
554 | 623 | "type": "BuiltinCommonInstructions::JsCode", |
|
572 | 641 | " /** @type {Map<gdjs.RuntimeObject> */", |
573 | 642 | " const objectSet = behavior.objectSet;", |
574 | 643 | " if (insertHeight < 0 || insertHeight > stack.length) {", |
575 | | - " log.error(`Tried to insert in the stack at ${insertHeight} where the stack is ${stack.length} height.`);", |
| 644 | + " console.error(`Tried to insert in the stack at ${insertHeight} where the stack is ${stack.length} height.`);", |
576 | 645 | " return;", |
577 | 646 | " }", |
578 | 647 | " upperBound = Math.min(upperBound, otherStack.length - 1);", |
|
636 | 705 | ], |
637 | 706 | "objectGroups": [] |
638 | 707 | }, |
| 708 | + { |
| 709 | + "description": "Move all the object from a stack into another.", |
| 710 | + "fullName": "Move all into the stack", |
| 711 | + "functionType": "Action", |
| 712 | + "name": "MoveAllInto", |
| 713 | + "sentence": "Move all the objects of the stack of _PARAM3_ into the stack of _PARAM0_ at height: _PARAM2_", |
| 714 | + "events": [ |
| 715 | + { |
| 716 | + "type": "BuiltinCommonInstructions::Standard", |
| 717 | + "conditions": [], |
| 718 | + "actions": [ |
| 719 | + { |
| 720 | + "type": { |
| 721 | + "value": "ObjectStack::ObjectStack::MoveInto" |
| 722 | + }, |
| 723 | + "parameters": [ |
| 724 | + "Object", |
| 725 | + "Behavior", |
| 726 | + "GetArgumentAsNumber(\"Height\")", |
| 727 | + "Stack", |
| 728 | + "StackBehavior", |
| 729 | + "0", |
| 730 | + "Stack.StackBehavior::Height() - 1", |
| 731 | + "" |
| 732 | + ] |
| 733 | + } |
| 734 | + ] |
| 735 | + } |
| 736 | + ], |
| 737 | + "parameters": [ |
| 738 | + { |
| 739 | + "description": "Object", |
| 740 | + "name": "Object", |
| 741 | + "type": "object" |
| 742 | + }, |
| 743 | + { |
| 744 | + "description": "Behavior", |
| 745 | + "name": "Behavior", |
| 746 | + "supplementaryInformation": "ObjectStack::ObjectStack", |
| 747 | + "type": "behavior" |
| 748 | + }, |
| 749 | + { |
| 750 | + "description": "Height", |
| 751 | + "name": "Height", |
| 752 | + "type": "expression" |
| 753 | + }, |
| 754 | + { |
| 755 | + "description": "Stack", |
| 756 | + "name": "Stack", |
| 757 | + "type": "objectList" |
| 758 | + }, |
| 759 | + { |
| 760 | + "description": "Stack behavior", |
| 761 | + "name": "StackBehavior", |
| 762 | + "supplementaryInformation": "ObjectStack::ObjectStack", |
| 763 | + "type": "behavior" |
| 764 | + } |
| 765 | + ], |
| 766 | + "objectGroups": [] |
| 767 | + }, |
| 768 | + { |
| 769 | + "description": "Move all the object from a stack into another one at the top.", |
| 770 | + "fullName": "Move all on top of the stack", |
| 771 | + "functionType": "Action", |
| 772 | + "name": "MoveAllOnTop", |
| 773 | + "sentence": "Move all the objects of the stack of _PARAM2_ on the top of the stack of _PARAM0_", |
| 774 | + "events": [ |
| 775 | + { |
| 776 | + "type": "BuiltinCommonInstructions::Standard", |
| 777 | + "conditions": [], |
| 778 | + "actions": [ |
| 779 | + { |
| 780 | + "type": { |
| 781 | + "value": "ObjectStack::ObjectStack::MoveInto" |
| 782 | + }, |
| 783 | + "parameters": [ |
| 784 | + "Object", |
| 785 | + "Behavior", |
| 786 | + "Object.Behavior::Height()", |
| 787 | + "Stack", |
| 788 | + "StackBehavior", |
| 789 | + "0", |
| 790 | + "Stack.StackBehavior::Height() - 1", |
| 791 | + "" |
| 792 | + ] |
| 793 | + } |
| 794 | + ] |
| 795 | + } |
| 796 | + ], |
| 797 | + "parameters": [ |
| 798 | + { |
| 799 | + "description": "Object", |
| 800 | + "name": "Object", |
| 801 | + "type": "object" |
| 802 | + }, |
| 803 | + { |
| 804 | + "description": "Behavior", |
| 805 | + "name": "Behavior", |
| 806 | + "supplementaryInformation": "ObjectStack::ObjectStack", |
| 807 | + "type": "behavior" |
| 808 | + }, |
| 809 | + { |
| 810 | + "description": "Stack", |
| 811 | + "name": "Stack", |
| 812 | + "type": "objectList" |
| 813 | + }, |
| 814 | + { |
| 815 | + "description": "Stack behavior", |
| 816 | + "name": "StackBehavior", |
| 817 | + "supplementaryInformation": "ObjectStack::ObjectStack", |
| 818 | + "type": "behavior" |
| 819 | + } |
| 820 | + ], |
| 821 | + "objectGroups": [] |
| 822 | + }, |
639 | 823 | { |
640 | 824 | "description": "Shuffle the stack.", |
641 | 825 | "fullName": "Shuffle", |
|
729 | 913 | "objectGroups": [] |
730 | 914 | }, |
731 | 915 | { |
732 | | - "description": "The number of objects in the stack.", |
| 916 | + "description": "the number of objects in the stack.", |
733 | 917 | "fullName": "Stack height", |
734 | | - "functionType": "Expression", |
| 918 | + "functionType": "ExpressionAndCondition", |
735 | 919 | "name": "Height", |
736 | | - "sentence": "", |
| 920 | + "sentence": "the number of objects in the stack", |
737 | 921 | "events": [ |
738 | 922 | { |
739 | 923 | "type": "BuiltinCommonInstructions::JsCode", |
|
743 | 927 | "", |
744 | 928 | "/** @type {gdjs.RuntimeObject[]} */", |
745 | 929 | "const stack = behavior.objectStack;", |
746 | | - "eventsFunctionContext.returnValue = stack.length;" |
| 930 | + "eventsFunctionContext.returnValue = stack.length;", |
| 931 | + "" |
747 | 932 | ], |
748 | 933 | "parameterObjects": "Object", |
749 | 934 | "useStrict": true, |
|
770 | 955 | }, |
771 | 956 | { |
772 | 957 | "description": "Compare the number of objects in the stack.", |
773 | | - "fullName": "Stack height", |
| 958 | + "fullName": "Stack height (deprecated)", |
774 | 959 | "functionType": "Condition", |
775 | 960 | "name": "CheckHeight", |
| 961 | + "private": true, |
776 | 962 | "sentence": "_PARAM0_ has _PARAM2_ objects in its stack", |
777 | 963 | "events": [ |
778 | 964 | { |
|
0 commit comments