forked from FronterAS/top-trumps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
31 lines (27 loc) · 1 KB
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
app.service('Utils', function ($q) {
var makeNumber = function (multiplier) {
return Math.floor(Math.random() * (multiplier || 10));
};
this.makeCard = function () {
// found in images folder i.e. oldie-[*].jpg
var numOfImages = 10;
return {
'cardDetails': {
'age': makeNumber(200),
'height': makeNumber(100)
},
'chosenProperty': null,
'imageUrl': 'images/oldie-' +
(Math.floor(Math.random() * numOfImages)) + '.jpg'
};
};
// A draw is null
// This is going to have to be replaced if the values become more complex
// or different winning factors have to be taken into consideration.
this.calculateWinner = function (property, opponentCard, myCard) {
var winLoseDraw = opponentCard[property] === myCard[property] ?
null :
myCard[property] > opponentCard[property]
return $q.when(winLoseDraw);
};
})