-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoke-memory.js
96 lines (56 loc) · 1.57 KB
/
poke-memory.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
angular.module("pokeApp", [])
.controller("pokeController", pokeFunction)
.factory("PokeFactory", pokeFactory)
pokeFunction.$inject = ["PokeFactory",];
function pokeFunction(pokeFactory){
var pCtrl = this;
pCtrl.pokeMasterArray = [];
pCtrl.randomNum;
pCtrl.pokeArray = [];
//
pCtrl.randomInit = function(){
for (var i = 0; i < 8; i++) {
pCtrl.pokeArray.push(pCtrl.randomNum = Math.floor(Math.random() * (712 - 1) + 1))
for (var z = 0; z < 8; z++) {
if(i===z){
}else{
if(pCtrl.pokeArray[i]===pCtrl.pokeArray[z]){
pCtrl.randomInit()
}
}
}
}
}
pCtrl.randomInit()
//
var shuffleFix = _.shuffle;
pCtrl.pokeMasterArray = pCtrl.pokeMasterArray.concat(pCtrl.pokeArray);
pCtrl.pokeMasterArray = pCtrl.pokeMasterArray.concat(pCtrl.pokeArray);
shuffleFix = (_.shuffle(pCtrl.pokeMasterArray));
pCtrl.pokeMasterArray = shuffleFix;
console.log(pCtrl.pokeMasterArray)
pCtrl.cardClick = function(index){
$(".card").flip();
}
// pCtrl.getPokemon = function(pokemonID){
// pokeFactory
// .getPokemon(pokemonID)
// .then(function(response){
// console.log(response)
// pCtrl.pokemon = response.data
// })
// }
}
pokeFactory.$inject = ["$http"]
function pokeFactory($http){
var baseURI = "http://pokeapi.co/api/v2";
function getPokemon (pokemonID) {
return $http({
method : 'GET',
url : baseURI + '/pokemon/' + pokemonID
})
}
return {
getPokemon : getPokemon
}
}