-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.js
More file actions
54 lines (45 loc) · 1.36 KB
/
Copy pathmodel.js
File metadata and controls
54 lines (45 loc) · 1.36 KB
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
function Pokemon(args){
Object.assign(this, args);
};
function Pokedex(){
this.party_list = []
this.storage_box = []
};
Pokemon.getStarterPokemon = function(pokedex){
var starterNumbers = [1, 4, 7, 152, 155, 158]
var rand = starterNumbers[Math.floor(Math.random() * starterNumbers.length)]
return Pokemon.getSinglePokemon(rand)
};
Pokemon.getSinglePokemon = function(number){
if (number == null){
number = Math.floor((Math.random() * 251) + 1)
}
return $.get("http://pokeapi.co/api/v1/pokemon/" + number, function(result){
}).then(function(result){
var pokemon = new Pokemon(result)
pokemon.imageUrl = "http://pokeapi.co/media/img/"+ pokemon.national_id +".png"
return pokemon
});
};
Pokedex.prototype.catchPokemon = function(pokemon){
pokemon.wild = false
if (this.partySizeTooGreat()){
this.storage_box.push(pokemon)
}else{
this.party_list.push(pokemon)
}
}
Pokedex.prototype.partySizeTooGreat = function(){
return this.party_list.length >= 6
}
Pokedex.prototype.switchPartyPokemon = function(dragIndex, dropIndex){
drop = this.party_list[dragIndex]
drag = this.party_list[dropIndex]
this.party_list[dragIndex] = drag
this.party_list[dropIndex] = drop
}
Pokedex.prototype.switchPartyBoxPokemon = function (dragIndex, dropIndex){
drop = this.storage_box[dropIndex]
drag = this.party_list[dragIndex]
debugger
}