parent
e8ad552266
commit
3b79752b86
13
card.js
13
card.js
|
@ -99,4 +99,17 @@
|
||||||
MemoryGame.Card.prototype = Object.create(EventDispatcher.prototype);
|
MemoryGame.Card.prototype = Object.create(EventDispatcher.prototype);
|
||||||
MemoryGame.Card.prototype.constructor = MemoryGame.Card;
|
MemoryGame.Card.prototype.constructor = MemoryGame.Card;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the given object corresponds with the semantics for
|
||||||
|
* a memory game card.
|
||||||
|
*
|
||||||
|
* @param {object} params
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
MemoryGame.Card.isValid = function (params) {
|
||||||
|
return (params !== undefined &&
|
||||||
|
params.image !== undefined &&
|
||||||
|
params.image.path !== undefined);
|
||||||
|
};
|
||||||
|
|
||||||
})(H5P.MemoryGame, H5P.EventDispatcher, H5P.jQuery);
|
})(H5P.MemoryGame, H5P.EventDispatcher, H5P.jQuery);
|
||||||
|
|
|
@ -101,11 +101,13 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
|
||||||
|
|
||||||
// Initialize cards.
|
// Initialize cards.
|
||||||
for (var i = 0; i < parameters.cards.length; i++) {
|
for (var i = 0; i < parameters.cards.length; i++) {
|
||||||
// Add two of each card
|
if (MemoryGame.Card.isValid(parameters.cards[i])) {
|
||||||
var cardOne = new MemoryGame.Card(parameters.cards[i], id);
|
// Add two of each card
|
||||||
var cardTwo = new MemoryGame.Card(parameters.cards[i], id);
|
var cardOne = new MemoryGame.Card(parameters.cards[i], id);
|
||||||
addCard(cardOne, cardTwo);
|
var cardTwo = new MemoryGame.Card(parameters.cards[i], id);
|
||||||
addCard(cardTwo, cardOne);
|
addCard(cardOne, cardTwo);
|
||||||
|
addCard(cardTwo, cardOne);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
H5P.shuffleArray(cards);
|
H5P.shuffleArray(cards);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue