diff --git a/src/activities/share/ActivityConfig.qml b/src/activities/share/ActivityConfig.qml new file mode 100644 --- /dev/null +++ b/src/activities/share/ActivityConfig.qml @@ -0,0 +1,58 @@ +/* GCompris - ActivityConfig.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * Shubham Mishra + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import QtQuick 2.6 +import "../../core" + +Item { + id: activityConfiguration + property Item background + property bool easyMode: true + width: if(background) background.width + + Column { + id: column + spacing: 10 + width: parent.width + + GCDialogCheckBox { + id: easyModeBox + width: activityConfiguration.width + text: qsTr("Display candy counter") + checked: easyMode // This is available in all editors. + onCheckedChanged: { + easyMode = checked + } + } + } + + property var dataToSave + + function setDefaultValues() { + if(dataToSave["mode"] === undefined) { + dataToSave["mode"] = "true"; + } + easyModeBox.checked = (dataToSave.mode === "true") + } + + function saveValues() { + dataToSave = { "mode": "" + easyMode } + } +} diff --git a/src/activities/share/ActivityInfo.qml b/src/activities/share/ActivityInfo.qml --- a/src/activities/share/ActivityInfo.qml +++ b/src/activities/share/ActivityInfo.qml @@ -36,4 +36,5 @@ credit: "" section: "math arithmetic" createdInVersion: 7000 + levels :"1,2,3" } diff --git a/src/activities/share/Share.qml b/src/activities/share/Share.qml --- a/src/activities/share/Share.qml +++ b/src/activities/share/Share.qml @@ -36,7 +36,7 @@ signal stop Component.onCompleted: { - dialogActivityConfig.getInitialConfiguration() + dialogActivityConfig.initialize() activity.start.connect(start) activity.stop.connect(stop) } @@ -53,7 +53,6 @@ property int nbSubLevel property alias listModel: listModel property bool acceptCandy: false - property alias dataset: dataset property alias girlWidget: girlWidget property alias boyWidget: boyWidget property alias candyWidget: candyWidget @@ -63,17 +62,13 @@ property int totalGirls property int totalCandies property int totalChildren: totalBoys + totalGirls + property var levels: activity.datasetLoader.data property int barHeightAddon: ApplicationSettings.isBarHidden ? 1 : 3 property int cellSize: Math.round(Math.min(background.width / 12, background.height / (11 + barHeightAddon))) property alias repeaterDropAreas: repeaterDropAreas property int maxNumberOfCandiesPerWidget: 8 } - Loader { - id: dataset - asynchronous: false - } - onStart: { Activity.start(items) } onStop: { Activity.stop() } @@ -247,9 +242,9 @@ Rectangle { id: leftWidget width: background.vert ? - items.cellSize * 1.74 : background.width + items.cellSize * 2.04 : background.width height: background.vert ? - background.height : items.cellSize * 1.74 + background.height : items.cellSize * 2.04 color: "#5a9de0" border.color: "#3f81c4" border.width: 4 @@ -287,13 +282,15 @@ id: girlWidget name: "girl" total: items.totalGirls + visible: items.totalGirls !== 0 current: background.currentGirls placedInChild: background.placedInGirls } ChildWidget { id: boyWidget name: "boy" + visible: items.totalBoys !== 0 total: items.totalBoys current: background.currentBoys placedInChild: background.placedInBoys @@ -356,40 +353,22 @@ } } - DialogActivityConfig { + DialogChooseLevel { id: dialogActivityConfig - currentActivity: activity - content: Component { - Item { - height: column.height - - Column { - id: column - spacing: 10 - width: parent.width - - GCDialogCheckBox { - id: easyModeBox - width: dialogActivityConfig.width - text: qsTr("Display candy counter") - checked: background.easyMode - onCheckedChanged: { - background.easyMode = checked - Activity.reloadRandom() - } - } - } - } + currentActivity: activity.activityInfo + onSaveData: { + levelFolder = dialogActivityConfig.chosenLevels + currentActivity.currentLevels = dialogActivityConfig.chosenLevels + ApplicationSettings.setCurrentLevels(currentActivity.name, dialogActivityConfig.chosenLevels) } - onLoadData: { - if(dataToSave && dataToSave["mode"]) { - background.easyMode = (dataToSave["mode"] === "true"); + if(activityData && activityData["mode"]) { + background.easyMode = (activityData["mode"] === "true"); } } - - onSaveData: { - dataToSave = { "mode": "" + background.easyMode } + onStartActivity: { + background.stop(); + background.start() } onClose: home() @@ -403,17 +382,16 @@ Bar { id: bar - content: BarEnumContent { value: help | home | level | reload | config} + content: BarEnumContent { value: help | home | level | reload | activityConfig} onHelpClicked: { displayDialog(dialogHelp) } onPreviousLevelClicked: Activity.previousLevel() onNextLevelClicked: Activity.nextLevel() onHomeClicked: activity.home() onReloadClicked: Activity.reloadRandom() - onConfigClicked: { - dialogActivityConfig.active = true - displayDialog(dialogActivityConfig) + onActivityConfigClicked: { + displayDialog(dialogActivityConfig) } } diff --git a/src/activities/share/resource/1/Data.qml b/src/activities/share/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/share/resource/1/Data.qml @@ -0,0 +1,313 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * shivam828787@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import GCompris 1.0 + +Data { + objective: qsTr("Maximum 25 candies and 5 kids, no rest.") + difficulty: 4 + data: [ + [ + { + "instruction": qsTr("Paul wants to equally share 2 pieces of candy between 2 of his girl friends. Can you help him? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 2, + "totalCandies": 2, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Now he wants to give 4 pieces of candy to his friends."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 4, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Can you now give 6 of Paul's pieces of candy to his friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 6, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("He wants to give 7 more pieces of candy to his friends."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 8, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 1, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Paul has only 12 pieces of candy left. He eats 2 pieces of candy and he gives the rest to his friends. Can you help him equally split the 10 remaining pieces of candy?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 10, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + } + ], + [ + { + "instruction": qsTr("George wants to equally share 3 pieces of candy between 3 of his girl friends. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 3, + "totalCandies": 3, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Maria wants to equally share 6 pieces of candy between 3 of her friends: one girl and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 1, + "totalCandies": 6, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("John wants to equally share 8 pieces of candy between 3 of his friends: one boy and two girls. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 9, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 1 + }, + { + "instruction": qsTr("Paul wants to equally share 12 pieces of candy between 3 of his friends: two boys and one girl. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 1, + "totalCandies": 12, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Maria wants to equally share 11 pieces of candy between 3 of his friends: one boy and two girls. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 15, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 2, + "placedInBoys": 0 + } + ], + [ + { + "instruction": qsTr("Alice wants to equally share 4 pieces of candy between 4 of her girl friends. Can you help her? First, place the children in the center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 4, + "totalCandies": 4, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Now, Alice wants to give 8 pieces of candy to her friends."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 8, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Can you help Alice give 10 pieces of candy to her friends: one girl and three boys?"), + "randomisedInputData": false, + "totalBoys": 3, + "totalGirls": 1, + "totalCandies": 12, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 2, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Alice wants to give 16 pieces of candy to her friends."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 16, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Alice has 14 pieces of candy left. She wants to give them all to her friends. Can you help her split the pieces of candy equally?"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 20, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 3 + } + ], + [ + { + "instruction": qsTr("Michael wants to equally share 5 pieces of candy between 5 of his girl friends. Can you help him? First, place the children in center, then drag the pieces of candy to each of them!"), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 5, + "totalCandies": 5, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Helen has 5 friends: two boys and three girls. She wants to give them 10 pieces of candy. Help her split the pieces of candy between her friends!"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 3, + "totalCandies": 10, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Michelle has 12 pieces of candy and wants to split them with four brothers and one sisters. Help her share the pieces of candy!"), + "randomisedInputData": false, + "totalBoys": 4, + "totalGirls": 1, + "totalCandies": 15, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 3, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Thomas wants to share his 20 pieces of candy with his friends: one boy and four girls. Can you help him?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 4, + "totalCandies": 20, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Paul wants to equally share 20 pieces of candy between 5 of his friends: two girls and three boys. Can you help him? First, place the children in center, then drag the pieces of candy to each of them!"), + "randomisedInputData": false, + "totalBoys": 3, + "totalGirls": 2, + "totalCandies": 25, + "showCount": false, + "forceShowBasket": false, + "placedInGirls": 1, + "placedInBoys": 1 + } + ], + [ + { + "instruction": qsTr("Charles wants to share his 6 pieces of candy with 2 of his friends: two girls. Can he split the pieces of candy equally?"), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 2, + "totalCandies": 6, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("For her birthday, Elizabeth has 8 pieces of candy to share with 3 of her friends: two girls and one boy. How should she split the pieces of candy to her friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 12, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 2, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Jason's father gave him 16 pieces of candy to share with his friends: two boys and two girls. Help him give the pieces of candy to his friends!"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 16, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("George wants to equally share 14 pieces of candy between 4 of his friends: two girls and two boys. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 20, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Maria wants to equally share 25 pieces of candy between 5 of her friends: three girls and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 3, + "totalCandies": 25, + "showCount": true, + "forceShowBasket": false, + "placedInGirls": 0, + "placedInBoys": 0 + } + ] + ] +} diff --git a/src/activities/share/resource/2/Data.qml b/src/activities/share/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/share/resource/2/Data.qml @@ -0,0 +1,291 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * shivam828787@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import GCompris 1.0 + +Data { + objective: qsTr("Maximum 25 candies and 5 kids, possible rest.") + difficulty: 5 + data: [ + [ + { + "instruction": qsTr("Paul wants to equally share 2 pieces of candy between 2 of his girl friends. Can you help him? First, place the children in center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 2, + "totalCandies": 2, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Now he wants to give 5 pieces of candy to his friends."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 5, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Can you now give 7 of Paul's pieces of candy to his friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 7, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("He wants to give 8 more pieces of candy to his friends."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 8, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Paul has only 11 pieces of candy left. He eats 2 pieces of candy and he gives the rest to his friends. Can you help him equally split the 9 remaining pieces of candy?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 1, + "totalCandies": 9, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + } + ], + [ + { + "instruction": qsTr("Bob wants to give 3 pieces of candy to his girl friends. Can you help him equally split the pieces of candy so that each friend will have the same amount of pieces of candy?"), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 3, + "totalCandies": 3, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Harry wants to equally share 8 pieces of candy between his friends: one boy and two girls. Place the children in center, then drag the pieces of candy to each of them so that each of them has an equal number of pieces of candy."), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 9, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 1 + }, + { + "instruction": qsTr("Can you now give 8 of Harry's pieces of candy to his friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 10, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 2 + }, + { + "instruction": qsTr("Harry is left with 12 pieces of candy, can you share them between his friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 14, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 2 + } + ], + [ + { + "instruction": qsTr("Alice wants to equally share 4 pieces of candy between 4 of her girl friends. Can you help her? First, place the children in the center, then drag the pieces of candy to each of them."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 4, + "totalCandies": 4, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Now, Alice wants to give 8 pieces of candy to her friends."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 8, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Can you help Alice give 10 pieces of candy to her friends: one girl and three boys?"), + "randomisedInputData": false, + "totalBoys": 3, + "totalGirls": 1, + "totalCandies": 12, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 2, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Alice wants to give 16 pieces of candy to her friends."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 16, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Alice has 14 pieces of candy left. She wants to give them all to her friends. Can you help her split the pieces of candy equally?"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 20, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 3 + } + ], + [ + { + "instruction": qsTr("Help Jon split 11 pieces of candies between five girls. The rest will remain to Jon."), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 5, + "totalCandies": 11, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Jon wants to share the rest of his pieces of candies with his brothers and his sisters. Can you split them equally, knowing that his brothers already has two pieces of candy?"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 3, + "totalCandies": 16, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 2 + }, + { + "instruction": qsTr("Help Tux split some pieces of candies to his friends: 19 pieces of candy to four boys and one girl."), + "randomisedInputData": false, + "totalBoys": 4, + "totalGirls": 1, + "totalCandies": 21, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 2, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Help Maria split 18 pieces of candy between three boys and two girls."), + "randomisedInputData": false, + "totalBoys": 3, + "totalGirls": 2, + "totalCandies": 20, + "showCount": false, + "forceShowBasket": true, + "placedInGirls": 1, + "placedInBoys": 0 + }, + ], + [ + { + "instruction": qsTr("Charles wants to share his 6 pieces of candy with 2 of his two girl friends. Can he split the pieces of candy equally?"), + "randomisedInputData": false, + "totalBoys": 0, + "totalGirls": 2, + "totalCandies": 6, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("For her birthday, Elizabeth has 8 pieces of candy to share with 3 of her friends: two girls and one boy. How should she split the pieces of candy to her friends?"), + "randomisedInputData": false, + "totalBoys": 1, + "totalGirls": 2, + "totalCandies": 12, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 2, + "placedInBoys": 0 + }, + { + "instruction": qsTr("Jason's father gave him 17 pieces of candy to share with his friends: two boys and two girls. Help him give the pieces of candy to his friends!"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 17, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 0 + }, + { + "instruction": qsTr("George wants to equally share 14 pieces of candy between 4 of his friends: two girls and two boys. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful."), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 2, + "totalCandies": 20, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 2, + "placedInBoys": 1 + }, + { + "instruction": qsTr("Maria wants to equally share 23 pieces of candy between 5 of her friends: three girls and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"), + "randomisedInputData": false, + "totalBoys": 2, + "totalGirls": 3, + "totalCandies": 25, + "showCount": true, + "forceShowBasket": true, + "placedInGirls": 0, + "placedInBoys": 1 + } + ] + ] +} diff --git a/src/activities/share/resource/3/Data.qml b/src/activities/share/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/share/resource/3/Data.qml @@ -0,0 +1,213 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2020 Shubham Mishra + * + * Authors: + * shivam828787@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +import GCompris 1.0 + +Data { + objective: qsTr("Maximum 30 candies and 6 kids, possible rest.") + difficulty: 5 + data: [ + [ + { + "randomisedInputData": true, + "maxBoys": 0, + "maxGirls": 4, + "maxCandies": 6, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 10, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 12, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 16, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 16, + "alreadyPlaced": false + } + ], + [ + { + "randomisedInputData": true, + "maxBoys": 0, + "maxGirls": 4, + "maxCandies": 6, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 10, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 14, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 16, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 18, + "alreadyPlaced": false + } + ], + [ + { + "randomisedInputData": true, + "maxBoys": 0, + "maxGirls": 5, + "maxCandies": 10, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 3, + "maxCandies": 14, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 2, + "maxCandies": 18, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 3, + "maxCandies": 22, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 26, + "alreadyPlaced": false + } + ], + [ + { + "randomisedInputData": true, + "maxBoys": 0, + "maxGirls": 4, + "maxCandies": 10, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 2, + "maxGirls": 2, + "maxCandies": 14, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 18, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 22, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 26, + "alreadyPlaced": false + } + ], + [ + { + "randomisedInputData": true, + "maxBoys": 0, + "maxGirls": 6, + "maxCandies": 12, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 16, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 20, + "alreadyPlaced": true + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 24, + "alreadyPlaced": false + }, + { + "randomisedInputData": true, + "maxBoys": 3, + "maxGirls": 3, + "maxCandies": 30, + "alreadyPlaced": true + } + ] + ] +} diff --git a/src/activities/share/resource/board/board0.qml b/src/activities/share/resource/board/board0.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board0.qml +++ /dev/null @@ -1,69 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are given in the left widget which eases kid work. - No rest (basket). -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Paul wants to equally share 2 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them."), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 2, - "showCount": true, - "forceShowBasket": "false", - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Now he wants to give 4 pieces of candy to his friends."), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 4, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Can you now give 6 of Paul's pieces of candy to his friends?"), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 6, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - - }, - { - "instruction": qsTr("Paul has only 10 pieces of candy left. He eats 2 pieces of candy and he gives the rest to his friends. Can you help him equally split the 8 remaining pieces of candy?"), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 8, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board1.qml b/src/activities/share/resource/board/board1.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board1.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are given in the left widget which eases kid work. - There is a rest (basket) -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("George wants to equally share 3 pieces of candy between 2 of his friends: one girl and one boy. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 3, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Maria wants to equally share 5 pieces of candy between 3 of her friends: one girl and two boys. Can she equally split the pieces of candy between her friends? First, place the children in center, then drag the pieces of candy to each of them. Be careful, a rest will remain!"), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 5, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("John wants to equally share 10 pieces of candy between 3 of his friends: one boy and two girls. Can he equally split the pieces of candy between his friends? First, place the children in center, then drag the pieces of candy to each of them."), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 10, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board2.qml b/src/activities/share/resource/board/board2.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board2.qml +++ /dev/null @@ -1,68 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are not given anymore in the left widget which forces kids to understand this part. - No rest (basket). -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Alice wants to equally share 3 pieces of candy between 3 of her friends: one girl and two boys. Can you help her? First, place the children in the center, then drag the pieces of candy to each of them."), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 3, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Now, Alice wants to give 6 pieces of candy to her friends"), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 6, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Can you help Alice give 9 pieces of candy to her friends: one girl and two boys?"), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 9, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Alice has 12 pieces of candy left. She wants to give them all to her friends. Can you help her split the pieces of candy equally?"), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 12, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board3.qml b/src/activities/share/resource/board/board3.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board3.qml +++ /dev/null @@ -1,68 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are not given anymore in the left widget. - There is a rest (basket). -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Michael wants to equally share 5 pieces of candy between 2 of his friends: one girl and one boy. Can you help him? First, place the children in center, then drag the pieces of candy to each of them!"), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 5, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Helen has 3 friends: one boy and two girls. She wants to give them 7 pieces of candy. Help her split the pieces of candy between her friends!"), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 7, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Michelle has 9 pieces of candy and wants to split them with two brothers and two sisters. Help her share the pieces of candy!"), - "totalBoys": 2, - "totalGirls": 2, - "totalCandies": 9, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Thomas wants to share his 11 pieces of candy with his friends: three boys and one girl. Can you help him?"), - "totalBoys": 3, - "totalGirls": 1, - "totalCandies": 11, - "showCount": false, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board4.qml b/src/activities/share/resource/board/board4.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board4.qml +++ /dev/null @@ -1,58 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are not given anymore in the left widget. - There is always a basket even if the rest can be equal to 0 -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Charles wants to share his 8 pieces of candy with 3 of his friends: one boy and two girls. Can he split the pieces of candy equally?"), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 8, - "showCount": true, - "forceShowBasket": true, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("For her birthday, Elizabeth has 12 pieces of candy to share with 4 of her friends: two girls and two boys. How should she split the pieces of candy to her friends?"), - "totalBoys": 2, - "totalGirls": 2, - "totalCandies": 12, - "showCount": true, - "forceShowBasket": true, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Jason's father gave him 14 pieces of candy to share with his friends: two boys and three girls. Help him give the pieces of candy to his friends!"), - "totalBoys": 2, - "totalGirls": 3, - "totalCandies": 14, - "showCount": true, - "forceShowBasket": true, - "placedInGirls": 0, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board5.qml b/src/activities/share/resource/board/board5.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board5.qml +++ /dev/null @@ -1,59 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are not given anymore in the left widget. - No rest (basket). - Boy or Girl rectangles already contain a given number of pieces of candy. -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Bob wants to give 5 pieces of candy to his friends: two boys and one girl, his girlfriend already has one candy. Can you help him equally split the pieces of candy so that each friend will have the same amount of pieces of candy?"), - "totalBoys": 2, - "totalGirls": 1, - "totalCandies": 6, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 1, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Harry wants to equally share 8 pieces of candy between his friends: one boy and two girls. Place the children in center, then drag the pieces of candy to each of them so that each of them has an equal number of pieces of candy."), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 9, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 1 - }, - { - "instruction": qsTr("Can you now give 6 of Harry's pieces of candy to his friends?"), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 8, - "showCount": true, - "forceShowBasket": false, - "placedInGirls": 0, - "placedInBoys": 2 - } - ] -} diff --git a/src/activities/share/resource/board/board6.qml b/src/activities/share/resource/board/board6.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board6.qml +++ /dev/null @@ -1,59 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -/* - Numbers of kids are not given anymore in the left widget. - No rest (basket). - Boy or Girl rectangles already contain a given number of pieces of candies. -*/ - -QtObject { - property var levels : [ - { - "instruction": qsTr("Help Jon split 9 pieces of candies between three boys and two girls. The rest will remain to Jon."), - "totalBoys": 3, - "totalGirls": 2, - "totalCandies": 9, - "showCount": false, - "forceShowBasket": true, - "placedInGirls": 0, - "placedInBoys": 0 - }, - { - "instruction": qsTr("Jon wants to share the rest of his pieces of candies with his brother and his sister. Can you split them equally, knowing that his brother already has two pieces of candies?"), - "totalBoys": 1, - "totalGirls": 1, - "totalCandies": 6, - "showCount": false, - "forceShowBasket": true, - "placedInGirls": 0, - "placedInBoys": 2 - }, - { - "instruction": qsTr("Help Tux split some pieces of candies to his friends: 9 pieces of candies to one boy and two girls."), - "totalBoys": 1, - "totalGirls": 2, - "totalCandies": 13, - "showCount": false, - "forceShowBasket": true, - "placedInGirls": 2, - "placedInBoys": 0 - } - ] -} diff --git a/src/activities/share/resource/board/board7.qml b/src/activities/share/resource/board/board7.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board7.qml +++ /dev/null @@ -1,29 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -QtObject { - property var levels : [ - { - "maxBoys": 2, - "maxGirls": 2, - "maxCandies": 16, - "alreadyPlaced": false - } - ] -} diff --git a/src/activities/share/resource/board/board8.qml b/src/activities/share/resource/board/board8.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board8.qml +++ /dev/null @@ -1,29 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -QtObject { - property var levels : [ - { - "maxBoys": 3, - "maxGirls": 3, - "maxCandies": 24, - "alreadyPlaced": true - } - ] -} diff --git a/src/activities/share/resource/board/board9.qml b/src/activities/share/resource/board/board9.qml deleted file mode 100644 --- a/src/activities/share/resource/board/board9.qml +++ /dev/null @@ -1,29 +0,0 @@ -/* GCompris - * - * Copyright (C) 2016 Stefan Toncu - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ -import QtQuick 2.6 - -QtObject { - property var levels : [ - { - "maxBoys": 3, - "maxGirls": 3, - "maxCandies": 24, - "alreadyPlaced": true - } - ] -} diff --git a/src/activities/share/share.js b/src/activities/share/share.js --- a/src/activities/share/share.js +++ b/src/activities/share/share.js @@ -20,15 +20,16 @@ .import QtQuick 2.6 as Quick var currentLevel = 0 -var numberOfLevel = 10 +var numberOfLevel var items var savedTotalBoys var savedTotalGirls var savedTotalCandies var savedPlacedInGirls var savedPlacedInBoys var savedCurrentCandies +var subLevelData function start(items_) { items = items_ @@ -41,24 +42,21 @@ function initLevel() { items.bar.level = currentLevel + 1 - var filename = "resource/board/"+ "board" + currentLevel + ".qml" - items.dataset.source = filename - setUp() } function setUp() { - var levelData = items.dataset.item - + var levelData = items.levels + numberOfLevel = items.levels.length + subLevelData = levelData[currentLevel][items.currentSubLevel]; // use board levels - if (currentLevel < 7) { - var subLevelData = levelData.levels[items.currentSubLevel]; + if (!subLevelData["randomisedInputData"]) { items.totalBoys = subLevelData.totalBoys items.totalGirls = subLevelData.totalGirls items.totalCandies = subLevelData.totalCandies items.instruction.text = subLevelData.instruction - items.nbSubLevel = levelData.levels.length + items.nbSubLevel = levelData[currentLevel].length items.background.currentCandies = items.totalGirls * subLevelData.placedInGirls + items.totalBoys * subLevelData.placedInBoys @@ -76,37 +74,24 @@ else { // create random (guided) levels // get a random number between 1 and max for boys, girls and candies - var maxBoys = levelData.levels[0].maxBoys - var maxGirls = levelData.levels[0].maxGirls - var maxCandies = levelData.levels[0].maxCandies + var maxBoys = subLevelData.maxBoys + var maxGirls = subLevelData.maxGirls + var maxCandies = subLevelData.maxCandies items.totalBoys = Math.floor(Math.random() * maxBoys) + 1 items.totalGirls = Math.floor(Math.random() * maxGirls) + 1 var sum = items.totalBoys + items.totalGirls - // use sum * 4 as top margin (max 4 candies per rectangle) - items.totalCandies = Math.floor(Math.random() * (4 * sum - sum + 1)) + sum - + // use sum * 6 as top margin (max 6 candies per rectangle) + items.totalCandies = Math.floor(Math.random() * (5 * sum + 1)) + sum + items.nbSubLevel = levelData[currentLevel].length // stay within the max margin if (items.totalCandies > maxCandies) items.totalCandies = maxCandies - //~ singular Place %n boy - //~ plural Place %n boys - items.instruction.text = qsTr("Place %n boy(s) ", "First part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalBoys); - - //~ singular and %n girl in the center. - //~ plural and %n girls in the center. - items.instruction.text += qsTr("and %n girl(s) in the center. ", "Second part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalGirls); - - //~ singular Then equally split %n candy between them. - //~ plural Then equally split %n candies between them. - items.instruction.text += qsTr("Then equally split %n pieces of candy between them.", "Third part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalCandies); - items.background.showCount = false - items.nbSubLevel = 5 // depending on the levels configuration, add candies from start in a child rectangle - if (levelData.levels[0].alreadyPlaced == false) { + if (subLevelData.alreadyPlaced === false) { items.background.placedInGirls = 0 items.background.placedInBoys = 0 items.background.currentCandies = 0 @@ -121,6 +106,18 @@ + items.totalBoys * items.background.placedInBoys } } + //~ singular Place %n boy + //~ plural Place %n boys + items.instruction.text = qsTr("Place %n boy(s) ", "First part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalBoys); + + //~ singular and %n girl in the center. + //~ plural and %n girls in the center. + items.instruction.text += qsTr("and %n girl(s) in the center. ", "Second part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalGirls); + + //~ singular Then equally split %n candy between them. + //~ plural Then equally split %n candies between them. + items.instruction.text += qsTr("Then equally split %n pieces of candy between them.", "Third part of Place %n boy(s) and %n girl(s) in the center. Then equally split %n pieces of candy between them.", items.totalCandies - items.background.currentCandies); + items.background.rest = items.totalCandies - Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) @@ -179,7 +176,7 @@ } function reloadRandom() { - if (currentLevel < 7) { + if (!subLevelData["randomisedInputData"]) { initLevel() } else {