diff --git a/src/activities/magic-hat-minus/ActivityInfo.qml b/src/activities/magic-hat-minus/ActivityInfo.qml --- a/src/activities/magic-hat-minus/ActivityInfo.qml +++ b/src/activities/magic-hat-minus/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math arithmetic" createdInVersion: 0 + levels: "1,2,3,4,5" } diff --git a/src/activities/magic-hat-minus/MagicHat.qml b/src/activities/magic-hat-minus/MagicHat.qml --- a/src/activities/magic-hat-minus/MagicHat.qml +++ b/src/activities/magic-hat-minus/MagicHat.qml @@ -64,6 +64,8 @@ property alias background: background property GCSfx audioEffects: activity.audioEffects property alias bar: bar + property var levels: activity.datasetLoader.item.data + property var range: activity.datasetLoader.item.range property alias bonus: bonus property alias hat: theHat property alias introductionText: introText diff --git a/src/activities/magic-hat-minus/StarsBar.qml b/src/activities/magic-hat-minus/StarsBar.qml --- a/src/activities/magic-hat-minus/StarsBar.qml +++ b/src/activities/magic-hat-minus/StarsBar.qml @@ -21,14 +21,18 @@ */ import QtQuick 2.6 import "magic-hat.js" as Activity +import "../../core" Item { id: item height: starsSize property int barGroupIndex property int barIndex property int nbStarsOn: 0 property bool authorizeClick: false + property int coefficient: 1 + property bool coefficientVisible: false + property var maxRange property int starsSize property string backgroundColor property string starsColor: "1" @@ -39,6 +43,16 @@ id: rowlayout height: item.height spacing: 5 + GCText { + id: text + visible: item.coefficientVisible + text: qsTr(item.coefficient.toString() + " x") + fontSizeMode: Text.HorizontalFit + width: rowlayout.width / 10 + color: "white" + anchors.rightMargin: 20 + fontSize: tinySize + } Repeater { id: repeaterStars model: item.opacity == 1 ? 10 : 0 diff --git a/src/activities/magic-hat-minus/magic-hat.js b/src/activities/magic-hat-minus/magic-hat.js --- a/src/activities/magic-hat-minus/magic-hat.js +++ b/src/activities/magic-hat-minus/magic-hat.js @@ -24,21 +24,25 @@ var url = "qrc:/gcompris/src/activities/magic-hat-minus/resource/" var currentLevel -var numberOfLevel = 9 +var numberOfLevel var numberOfUserStars var items; var mode; var magicHat var numberOfStars var nbStarsToAddOrRemove var nbStarsToCount var animationCount +var coffieients = [] +var answerCofficients = [] +var coefficientsNeeded = false function start(items_, mode_) { items = items_ mode = mode_ magicHat = items.hat currentLevel = 0 + numberOfLevel = items.levels.length initLevel() } @@ -59,53 +63,39 @@ } else { items.introductionText.visible = true } - + coefficientsNeeded = items.range / 30 <= 1 ? false : true for(var j=0; j<3; j++) { items.repeatersList[0].itemAt(j).initStars() items.repeatersList[1].itemAt(j).initStars() items.repeatersList[2].itemAt(j).resetStars() } - - var maxValue = mode === "minus" ? 10 : 9 - switch(currentLevel) { - case 0: numberOfStars[0] = getRandomInt(2,4) - break; - case 1: numberOfStars[0] = getRandomInt(2,6) - break; - case 2: numberOfStars[0] = getRandomInt(2,maxValue) - break; - case 3: numberOfStars[0] = getRandomInt(2,5) - numberOfStars[1] = getRandomInt(2,5) - break; - case 4: numberOfStars[0] = getRandomInt(2,8) - numberOfStars[1] = getRandomInt(2,8) - break; - case 5: numberOfStars[0] = getRandomInt(2,maxValue) - numberOfStars[1] = getRandomInt(2,maxValue) - break; - case 6: numberOfStars[0] = getRandomInt(2,4) - numberOfStars[1] = getRandomInt(2,4) - numberOfStars[2] = getRandomInt(2,4) - break; - case 7: numberOfStars[0] = getRandomInt(2,6) - numberOfStars[1] = getRandomInt(2,6) - numberOfStars[2] = getRandomInt(2,6) - break; - case 8: numberOfStars[0] = getRandomInt(2,8) - numberOfStars[1] = getRandomInt(2,8) - numberOfStars[2] = getRandomInt(2,8) - break; - case 9: numberOfStars[0] = getRandomInt(2,maxValue) - numberOfStars[1] = getRandomInt(2,maxValue) - numberOfStars[2] = getRandomInt(2,maxValue) - break; + if(!coefficientsNeeded) { + coffieients[0] = coffieients[1] = coffieients[2] = 1; + answerCofficients[0] = answerCofficients[1] = answerCofficients[2] = 1; + setCoefficientVisibility(false) + setWantedColor() + } else { + for(var i = 0; i < 3; i++) + coffieients[i] = Math.round(items.levels[currentLevel].maxStars[i] / 10); + answerCofficients[0] = items.range / 100; + answerCofficients[1] = items.range / 20; + answerCofficients[2] = items.range / 10; + setCoefficientVisibility(true) + setWantedColor("1") } + var subtractor = mode === "minus" ? 0 : 1 + numberOfStars[0] = items.levels[currentLevel].maxStars[0] > 0 ? getRandomInt(items.levels[currentLevel].minStars[0], (items.levels[currentLevel].maxStars[0] / coffieients[0]) - subtractor) : 0 + numberOfStars[1] = items.levels[currentLevel].maxStars[1] > 0 ? getRandomInt(items.levels[currentLevel].minStars[1], (items.levels[currentLevel].maxStars[1] / coffieients[1]) - subtractor) : 0 + numberOfStars[2] = items.levels[currentLevel].maxStars[2] > 0 ? getRandomInt(items.levels[currentLevel].minStars[2], (items.levels[currentLevel].maxStars[2] / coffieients[2]) - subtractor) : 0 for(var i=0; i<3; i++) { items.repeatersList[0].itemAt(i).nbStarsOn = numberOfStars[i] + items.repeatersList[0].itemAt(i).coefficient = coffieients[i] items.repeatersList[1].itemAt(i).nbStarsOn = 0 + items.repeatersList[1].itemAt(i).coefficient = coffieients[i] items.repeatersList[2].itemAt(i).nbStarsOn = 0 items.repeatersList[2].itemAt(i).authorizeClick = false + items.repeatersList[2].itemAt(i).coefficient = answerCofficients[i] if(numberOfStars[i] > 0) { items.repeatersList[0].itemAt(i).opacity = 1 items.repeatersList[1].itemAt(i).opacity = 1 @@ -135,20 +125,52 @@ } } +function setCoefficientVisibility(visibility) { + for(var i=0; i<3; i++) { + items.repeatersList[0].itemAt(i).coefficientVisible = visibility + items.repeatersList[1].itemAt(i).coefficientVisible = visibility + items.repeatersList[2].itemAt(i).coefficientVisible = visibility + items.repeatersList[0].itemAt(i).maxRange = items.range.toString() + items.repeatersList[1].itemAt(i).maxRange = items.range.toString() + items.repeatersList[2].itemAt(i).maxRange = items.range.toString() + } +} + +function setWantedColor(colorValue) { + if(colorValue != null) { + for(var i=0; i<3; i++) { + items.repeatersList[0].itemAt(i).starsColor = colorValue + items.repeatersList[1].itemAt(i).starsColor = colorValue + items.repeatersList[2].itemAt(i).starsColor = colorValue + } + } +} + function userClickedAStar(barIndex,state) { if(state) numberOfUserStars[barIndex]++ else numberOfUserStars[barIndex]-- } function verifyAnswer() { - if(numberOfUserStars[0] === nbStarsToCount[0] && - numberOfUserStars[1] === nbStarsToCount[1] && - numberOfUserStars[2] === nbStarsToCount[2]) { - items.bonus.good("flower") + if(items.range / 30 <= 1) { + if(numberOfUserStars[0] === nbStarsToCount[0] && + numberOfUserStars[1] === nbStarsToCount[1] && + numberOfUserStars[2] === nbStarsToCount[2]) { + items.bonus.good("flower") + } else { + items.bonus.bad("flower") + } } else { - items.bonus.bad("flower") + var userStars = numberOfUserStars[0] * answerCofficients[0] + numberOfUserStars[1] * answerCofficients[1] + + numberOfUserStars[2] * answerCofficients[2]; + var toBeStars = nbStarsToCount[0] * coffieients[0] + nbStarsToCount[1] * coffieients[1] + + nbStarsToCount[2] * coffieients[2]; + if( userStars == toBeStars) + items.bonus.good("flower") + else + items.bonus.bad("flower") } } diff --git a/src/activities/magic-hat-minus/resource/1/Data.qml b/src/activities/magic-hat-minus/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-minus/resource/1/Data.qml @@ -0,0 +1,46 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate remaining stars upto 5") + difficulty: 1 + property var range: 10 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [3, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 0, 0], + "maxStars" : [4, 0, 0] + }, + { + "level" : "3", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + } + ] +} diff --git a/src/activities/magic-hat-minus/resource/2/Data.qml b/src/activities/magic-hat-minus/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-minus/resource/2/Data.qml @@ -0,0 +1,66 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate remaining stars upto 10") + difficulty: 2 + property var range: 10 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [3, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + }, + { + "level" : "3", + "minStars" : [2, 0, 0], + "maxStars" : [6, 0, 0] + }, + { + "level" : "4", + "minStars" : [2, 0, 0], + "maxStars" : [7, 0, 0] + }, + { + "level" : "5", + "minStars" : [2, 0, 0], + "maxStars" : [8, 0, 0] + }, + { + "level" : "6", + "minStars" : [2, 0, 0], + "maxStars" : [9, 0, 0] + }, + { + "level" : "7", + "minStars" : [2, 0, 0], + "maxStars" : [10, 0, 0] + } + ] +} diff --git a/src/activities/magic-hat-minus/resource/3/Data.qml b/src/activities/magic-hat-minus/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-minus/resource/3/Data.qml @@ -0,0 +1,61 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate remaining stars upto 30") + difficulty: 3 + property var range: 10 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 0, 0], + "maxStars" : [10, 0, 0] + }, + { + "level" : "3", + "minStars" : [2, 2, 0], + "maxStars" : [8, 8, 0] + }, + { + "level" : "4", + "minStars" : [2, 2, 0], + "maxStars" : [10, 10, 0] + }, + { + "level" : "5", + "minStars" : [2, 2, 2], + "maxStars" : [9, 9, 7] + }, + { + "level" : "6", + "minStars" : [2, 2, 2], + "maxStars" : [10, 10, 10] + } + ] +} diff --git a/src/activities/magic-hat-minus/resource/4/Data.qml b/src/activities/magic-hat-minus/resource/4/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-minus/resource/4/Data.qml @@ -0,0 +1,56 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate remaining stars upto 100 with coefficients") + difficulty: 4 + property var range: 100 + data: [ + { + "level" : "1", + "minStars" : [2, 2, 0], + "maxStars" : [20, 10, 0] + }, + { + "level" : "2", + "minStars" : [2, 2, 2], + "maxStars" : [20, 20, 10] + }, + { + "level" : "3", + "minStars" : [2, 2, 2], + "maxStars" : [20, 20, 20] + }, + { + "level" : "4", + "minStars" : [2, 2, 2], + "maxStars" : [30, 30, 20] + }, + { + "level" : "5", + "minStars" : [2, 2, 2], + "maxStars" : [40, 40, 20] + } + ] +} diff --git a/src/activities/magic-hat-minus/resource/5/Data.qml b/src/activities/magic-hat-minus/resource/5/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-minus/resource/5/Data.qml @@ -0,0 +1,56 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate remaining stars upto 1000 with coefficients") + difficulty: 5 + property var range: 1000 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [100, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 2, 0], + "maxStars" : [100, 100, 0] + }, + { + "level" : "3", + "minStars" : [2, 2, 2], + "maxStars" : [200, 200, 100] + }, + { + "level" : "4", + "minStars" : [2, 2, 2], + "maxStars" : [300, 300, 100] + }, + { + "level" : "5", + "minStars" : [2, 2, 2], + "maxStars" : [400, 400, 200] + } + ] +} diff --git a/src/activities/magic-hat-plus/ActivityInfo.qml b/src/activities/magic-hat-plus/ActivityInfo.qml --- a/src/activities/magic-hat-plus/ActivityInfo.qml +++ b/src/activities/magic-hat-plus/ActivityInfo.qml @@ -37,4 +37,5 @@ credit: "" section: "math arithmetic" createdInVersion: 0 + levels: "1,2,3,4" } diff --git a/src/activities/magic-hat-plus/resource/1/Data.qml b/src/activities/magic-hat-plus/resource/1/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-plus/resource/1/Data.qml @@ -0,0 +1,46 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate total stars upto 5") + difficulty: 1 + property var range: 5 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [3, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 0, 0], + "maxStars" : [4, 0, 0] + }, + { + "level" : "3", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + } + ] +} diff --git a/src/activities/magic-hat-plus/resource/2/Data.qml b/src/activities/magic-hat-plus/resource/2/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-plus/resource/2/Data.qml @@ -0,0 +1,66 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate total stars upto 10") + difficulty: 2 + property var range: 10 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [3, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 0, 0], + "maxStars" : [4, 0, 0] + }, + { + "level" : "3", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + }, + { + "level" : "4", + "minStars" : [2, 0, 0], + "maxStars" : [6, 0, 0] + }, + { + "level" : "5", + "minStars" : [2, 0, 0], + "maxStars" : [7, 0, 0] + }, + { + "level" : "6", + "minStars" : [2, 0, 0], + "maxStars" : [8, 0, 0] + }, + { + "level" : "7", + "minStars" : [2, 0, 0], + "maxStars" : [9, 0, 0] + } + ] +} diff --git a/src/activities/magic-hat-plus/resource/3/Data.qml b/src/activities/magic-hat-plus/resource/3/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-plus/resource/3/Data.qml @@ -0,0 +1,61 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate total stars upto 30") + difficulty: 3 + property var range: 30 + data: [ + { + "level" : "1", + "minStars" : [2, 0, 0], + "maxStars" : [5, 0, 0] + }, + { + "level" : "2", + "minStars" : [2, 2, 0], + "maxStars" : [7, 3, 0] + }, + { + "level" : "3", + "minStars" : [2, 2, 0], + "maxStars" : [8, 8, 0] + }, + { + "level" : "4", + "minStars" : [2, 2, 2], + "maxStars" : [8, 8, 4] + }, + { + "level" : "5", + "minStars" : [2, 2, 2], + "maxStars" : [9, 9, 7] + }, + { + "level" : "6", + "minStars" : [2, 2, 2], + "maxStars" : [9, 9, 9] + } + ] +} diff --git a/src/activities/magic-hat-plus/resource/4/Data.qml b/src/activities/magic-hat-plus/resource/4/Data.qml new file mode 100644 --- /dev/null +++ b/src/activities/magic-hat-plus/resource/4/Data.qml @@ -0,0 +1,56 @@ +/* GCompris - Data.qml + * + * Copyright (C) 2019 Akshay Kumar + * + * Authors: + * Akshay Kumar + * + * 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 GCompris 1.0 +import "../../../../core" + +Dataset { + objective: qsTr("Learn to calculate total stars upto 100 with coefficients") + difficulty: 4 + property var range: 100 + data: [ + { + "level" : "1", + "minStars" : [2, 2, 0], + "maxStars" : [20, 10, 0] + }, + { + "level" : "2", + "minStars" : [2, 2, 2], + "maxStars" : [20, 20, 10] + }, + { + "level" : "3", + "minStars" : [2, 2, 2], + "maxStars" : [20, 20, 20] + }, + { + "level" : "4", + "minStars" : [2, 2, 2], + "maxStars" : [30, 30, 20] + }, + { + "level" : "5", + "minStars" : [2, 2, 2], + "maxStars" : [40, 40, 20] + } + ] +}