Changeset View
Changeset View
Standalone View
Standalone View
src/activities/memory/memory.js
Show All 31 Lines | |||||
32 | var cardLeft | 32 | var cardLeft | ||
33 | var cardList | 33 | var cardList | ||
34 | 34 | | |||
35 | function start(items_) { | 35 | function start(items_) { | ||
36 | 36 | | |||
37 | items = items_ | 37 | items = items_ | ||
38 | 38 | | |||
39 | currentLevel = 0 | 39 | currentLevel = 0 | ||
40 | numberOfLevel = items.dataset.length | 40 | numberOfLevel = items.levels.length | ||
41 | 41 | | |||
42 | initLevel() | 42 | initLevel() | ||
43 | } | 43 | } | ||
44 | 44 | | |||
45 | function stop() { | 45 | function stop() { | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | function initLevel() { | 48 | function initLevel() { | ||
49 | items.bar.level = currentLevel + 1 | 49 | items.bar.level = currentLevel + 1 | ||
50 | items.containerModel.clear() | 50 | items.containerModel.clear() | ||
51 | items.playQueue = [] | 51 | items.playQueue = [] | ||
52 | items.tuxTurn = false | 52 | items.tuxTurn = false | ||
53 | items.selectionCount = 0 | 53 | items.selectionCount = 0 | ||
54 | items.blockClicks = false | 54 | items.blockClicks = false | ||
55 | 55 | | |||
56 | // compute the number of cards | 56 | // compute the number of cards | ||
57 | var columns = items.dataset[currentLevel].columns | 57 | var columns = items.levels[currentLevel].columns | ||
58 | var rows = items.dataset[currentLevel].rows | 58 | var rows = items.levels[currentLevel].rows | ||
59 | var images = items.dataset[currentLevel].images | 59 | var images = items.levels[currentLevel].images | ||
60 | var sounds = items.dataset[currentLevel].sounds | 60 | var sounds = items.levels[currentLevel].sounds | ||
61 | var texts = items.dataset[currentLevel].texts | 61 | var texts = items.levels[currentLevel].texts | ||
62 | items.columns = columns | 62 | items.columns = columns | ||
63 | items.rows = rows | 63 | items.rows = rows | ||
64 | nbOfPair = rows * columns / 2 | 64 | nbOfPair = rows * columns / 2 | ||
65 | cardLeft = nbOfPair * 2 | 65 | cardLeft = nbOfPair * 2 | ||
66 | 66 | | |||
67 | // Check the provided dataset has enough data | 67 | // Check the provided dataset has enough data | ||
68 | var maxData = Math.max( | 68 | var maxData = Math.max( | ||
69 | images ? images.length : 0, | 69 | images ? images.length : 0, | ||
70 | sounds ? sounds.length : 0, | 70 | sounds ? sounds.length : 0, | ||
71 | texts ? texts.length : 0) | 71 | texts ? texts.length : 0) | ||
72 | 72 | | |||
73 | if(rows * columns > maxData) { | 73 | if(rows * columns > maxData * 2) { | ||
jjazeix: extra space added | |||||
dekumar: I have fixed this on my branch in a commit. | |||||
echarruau: I still see it, we need to find a way to see your corrections | |||||
74 | console.log("ERROR: Memory dataset does not have enough data pairs at level ", | 74 | console.log("ERROR: Memory dataset does not have enough data pairs at level ", | ||
75 | currentLevel + 1) | 75 | currentLevel + 1) | ||
76 | return | 76 | return | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | // Create a list of indexes for the shuffling | 79 | // Create a list of indexes for the shuffling | ||
80 | // This way we can keep the 3 lists in sync | 80 | // This way we can keep the 3 lists in sync | ||
81 | var shuffleIds = [] | 81 | var shuffleIds = [] | ||
▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines |
extra space added