-
Notifications
You must be signed in to change notification settings - Fork 1
/
index_completed.html
93 lines (80 loc) · 2.24 KB
/
index_completed.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html ng-app>
<head>
<title>Random Pokemon! </title>
<link href="index.css" type = "text/css" rel = "stylesheet">
<script type="text/javascript" src="./angular.min.js"></script>
<script type="text/javascript" src = "./sasstore.min.js"></script>
<script>
function pokemans($scope) {
$scope.text = "Wow. A Pokemon appeared! Wow.";
$scope.store = new SASStore({id: "pokemonStore", length: 649, itemSize: 1});
$scope.getPokemonString = function(n) {
var num;
if (n < 10) {
num = '00' + String(n);
} else if (n < 100) {
num = '0' + String(n);
} else if (n < 1000) {
num = String(n);
}
return num;
}
$scope.getPokemon = function(num) {
var num2 = num-1;
$scope.store.setItem(num2, "1");
return num;
};
$scope.getProgress = function() {
var count = $scope.store.countOccurrencesOf("0");
return "you've got " +count + "/649 pokemans left to catch";
};
$scope.isShiny = function(){
var num = Math.floor(Math.random()*8193);
var str = "";
if (num == 5){
return true;
}
else{
return false
}
};
$scope.isWinner = function() {
if ($scope.store.countOccurrencesOf("0") == 0) {
return true;
} else {
return false;
}
}
$scope.reset = function(){
$scope.store.reset();
$scope.winner = $scope.isWinner();
}
$scope.update = function() {
$scope.pokemontype = "i";
$scope.num = $scope.getPokemon(Math.floor(Math.random() * 649) + 1);
$scope.pokemonString = $scope.getPokemonString($scope.num);
$scope.shiny = $scope.isShiny();
$scope.winner = $scope.isWinner();
if ($scope.shiny) {
$scope.pokemontype = "s";
}
};
$scope.update();
}
</script>
</head>
<body>
<div ng-controller="pokemans" align=center>
<div>{{text}}</div>
<div>{{getProgress()}}</div>
<div>
<img ng-src="http://sprites.pokecheck.org/{{pokemontype}}/{{pokemonString}}.gif" height="150px"></img>
</div>
<div ng-show="shiny">look is a shiny</div>
<div ng-show="winner">a winner is u</div>
<button ng-click="update()">new</button>
<button ng-click="reset()" >reset if u want</button>
</div>
</body>
</html>