Changeset View
Changeset View
Standalone View
Standalone View
src/activities/share/share.js
Show All 23 Lines | |||||
24 | var items | 24 | var items | ||
25 | 25 | | |||
26 | var savedTotalBoys | 26 | var savedTotalBoys | ||
27 | var savedTotalGirls | 27 | var savedTotalGirls | ||
28 | var savedTotalCandies | 28 | var savedTotalCandies | ||
29 | var savedPlacedInGirls | 29 | var savedPlacedInGirls | ||
30 | var savedPlacedInBoys | 30 | var savedPlacedInBoys | ||
31 | var savedCurrentCandies | 31 | var savedCurrentCandies | ||
32 | var subLevelData | ||||
32 | 33 | | |||
33 | function start(items_) { | 34 | function start(items_) { | ||
34 | items = items_ | 35 | items = items_ | ||
35 | currentLevel = 0 | 36 | currentLevel = 0 | ||
36 | initLevel() | 37 | initLevel() | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | function stop() { | 40 | function stop() { | ||
40 | } | 41 | } | ||
41 | 42 | | |||
42 | function initLevel() { | 43 | function initLevel() { | ||
43 | items.bar.level = currentLevel + 1 | 44 | items.bar.level = currentLevel + 1 | ||
44 | setUp() | 45 | setUp() | ||
45 | } | 46 | } | ||
46 | 47 | | |||
47 | function setUp() { | 48 | function setUp() { | ||
48 | var levelData = items.levels | 49 | var levelData = items.levels | ||
49 | numberOfLevel = items.levels.length | 50 | numberOfLevel = items.levels.length | ||
50 | var subLevelData = levelData[currentLevel][items.currentSubLevel]; | 51 | subLevelData = levelData[currentLevel][items.currentSubLevel]; | ||
51 | // use board levels | 52 | // use board levels | ||
52 | if (!subLevelData["randomisedInputData"]) { | 53 | if (!subLevelData["randomisedInputData"]) { | ||
53 | items.totalBoys = subLevelData.totalBoys | 54 | items.totalBoys = subLevelData.totalBoys | ||
54 | items.totalGirls = subLevelData.totalGirls | 55 | items.totalGirls = subLevelData.totalGirls | ||
55 | items.totalCandies = subLevelData.totalCandies | 56 | items.totalCandies = subLevelData.totalCandies | ||
56 | 57 | | |||
57 | items.instruction.text = subLevelData.instruction | 58 | items.instruction.text = subLevelData.instruction | ||
58 | items.nbSubLevel = levelData[currentLevel].length | 59 | items.nbSubLevel = levelData[currentLevel].length | ||
Show All 26 Lines | 74 | else { | |||
85 | items.nbSubLevel = levelData[currentLevel].length | 86 | items.nbSubLevel = levelData[currentLevel].length | ||
86 | // stay within the max margin | 87 | // stay within the max margin | ||
87 | if (items.totalCandies > maxCandies) | 88 | if (items.totalCandies > maxCandies) | ||
88 | items.totalCandies = maxCandies | 89 | items.totalCandies = maxCandies | ||
89 | 90 | | |||
90 | items.background.showCount = false | 91 | items.background.showCount = false | ||
91 | 92 | | |||
92 | // depending on the levels configuration, add candies from start in a child rectangle | 93 | // depending on the levels configuration, add candies from start in a child rectangle | ||
93 | if (subLevelData.alreadyPlaced == false) { | 94 | if (subLevelData.alreadyPlaced == false) { | ||
jjazeixUnsubmitted Not Done jjazeix: === | |||||
94 | items.background.placedInGirls = 0 | 95 | items.background.placedInGirls = 0 | ||
95 | items.background.placedInBoys = 0 | 96 | items.background.placedInBoys = 0 | ||
96 | items.background.currentCandies = 0 | 97 | items.background.currentCandies = 0 | ||
97 | } | 98 | } | ||
98 | else { | 99 | else { | ||
99 | items.background.currentCandies = items.totalCandies * 2 | 100 | items.background.currentCandies = items.totalCandies * 2 | ||
100 | // Place randomly between 0 and 3 candies for each child | 101 | // Place randomly between 0 and 3 candies for each child | ||
101 | while (items.background.currentCandies > items.totalCandies / 3) { | 102 | while (items.background.currentCandies > items.totalCandies / 3) { | ||
102 | items.background.placedInGirls = Math.floor(Math.random() * 3) | 103 | items.background.placedInGirls = Math.floor(Math.random() * 3) | ||
103 | items.background.placedInBoys = Math.floor(Math.random() * 3) | 104 | items.background.placedInBoys = Math.floor(Math.random() * 3) | ||
104 | items.background.currentCandies = items.totalGirls * items.background.placedInGirls | 105 | items.background.currentCandies = items.totalGirls * items.background.placedInGirls | ||
105 | + items.totalBoys * items.background.placedInBoys | 106 | + items.totalBoys * items.background.placedInBoys | ||
106 | } | 107 | } | ||
107 | } | 108 | } | ||
108 | //~ singular Place %n boy | 109 | //~ singular Place %n boy | ||
109 | //~ plural Place %n boys | 110 | //~ plural Place %n boys | ||
110 | 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); | 111 | 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); | ||
111 | 112 | | |||
112 | //~ singular and %n girl in the center. | 113 | //~ singular and %n girl in the center. | ||
113 | //~ plural and %n girls in the center. | 114 | //~ plural and %n girls in the center. | ||
114 | 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); | 115 | 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); | ||
115 | 116 | | |||
116 | //~ singular Then equally split %n candy between them. | 117 | //~ singular Then equally split %n candy between them. | ||
117 | //~ plural Then equally split %n candies between them. | 118 | //~ plural Then equally split %n candies between them. | ||
118 | 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); | 119 | 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); | ||
Previously for non randomised levels, Instructions show how many candies child needs to distribute while for random levels instructions shows total no. of candies without considering placed in candies. shubhammishra: Previously for non randomised levels, Instructions show how many candies child needs to… | |||||
119 | 120 | | |||
120 | 121 | | |||
121 | items.background.rest = items.totalCandies - | 122 | items.background.rest = items.totalCandies - | ||
122 | Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) | 123 | Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) | ||
123 | 124 | | |||
124 | items.basketWidget.element.opacity = 1 | 125 | items.basketWidget.element.opacity = 1 | ||
125 | 126 | | |||
126 | items.background.wrongMove.visible = false; | 127 | items.background.wrongMove.visible = false; | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 169 | function loadVariables() { | |||
170 | items.totalGirls = savedTotalGirls | 171 | items.totalGirls = savedTotalGirls | ||
171 | items.totalCandies = savedTotalCandies | 172 | items.totalCandies = savedTotalCandies | ||
172 | items.background.placedInGirls = savedPlacedInGirls | 173 | items.background.placedInGirls = savedPlacedInGirls | ||
173 | items.background.placedInBoys = savedPlacedInBoys | 174 | items.background.placedInBoys = savedPlacedInBoys | ||
174 | items.background.currentCandies = savedCurrentCandies | 175 | items.background.currentCandies = savedCurrentCandies | ||
175 | } | 176 | } | ||
176 | 177 | | |||
177 | function reloadRandom() { | 178 | function reloadRandom() { | ||
178 | if (currentLevel < 7) { | 179 | if (!subLevelData["randomisedInputData"]) { | ||
179 | initLevel() | 180 | initLevel() | ||
180 | } | 181 | } | ||
181 | else { | 182 | else { | ||
182 | loadVariables() | 183 | loadVariables() | ||
183 | resetBoard() | 184 | resetBoard() | ||
184 | 185 | | |||
185 | items.background.rest = items.totalCandies - | 186 | items.background.rest = items.totalCandies - | ||
186 | Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) | 187 | Math.floor(items.totalCandies / items.totalChildren) * (items.totalBoys+items.totalGirls) | ||
Show All 30 Lines |