-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathputinparty.html
More file actions
91 lines (72 loc) · 2.41 KB
/
putinparty.html
File metadata and controls
91 lines (72 loc) · 2.41 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
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
<script>
function animal(name, speed, focus) {
this.name = name;
//these values go from 0-9
this.speed = speed;
this.focus = focus;
this.position = 10;
//calculates whether they are focused by seeing if their focus level is higher than a random number
this.isFocused = function() {
return Math.floor(Math.random() * 10) < this.focus
}
this.advance = function() {
if (this.isFocused()) {
this.position += this.speed;
}
}
this.progressReport = function() {
return this.name + " is at: " + this.position;
}
}
var nameList = ["FDR", "John F Kennedy", "Richard 'Dick' Nixon", "Ronald Regan",
"George 'Dubya' Bush", "Bill Clinton", "Abe Lincoln", "George Bush", "Hilary Clinton", "Barack Obama"];
var animalName = function(){
return nameList[Math.floor(Math.random() * nameList.length)];
}
var animal1 = new animal(animalName(), 2, 6);
var animal2 = new animal(animalName(), 8, 3);
var animal3 = new animal(animalName(), 6, 4);
var animal4 = new animal(animalName(), 5, 5);
var putin = new Object()
putin.name = "Vladmir Putin"
putin.position = 0;
putin.speed = 6;
putin.focus = 5;
putin.isFocused = function() {
return Math.floor(Math.random() * 10) < putin.focus
}
putin.advance = function() {
if (putin.isFocused()) {
putin.position += putin.speed;
}
else{
alert(putin.name + " paused to take some photos with a bear!");
}
}
putin.progressReport = function() {
return putin.name + " is at: " + putin.position;
}
while (animal1.position > putin.position && animal2.position > putin.position && animal3.position > putin.position && animal4.position > putin.position) {
animal1.advance();
animal2.advance();
animal3.advance();
animal4.advance();
putin.advance();
if(putin.position >= animal1.position){
alert("Oh no! Putin caught and ate " + animal1.name + "!");
}
else if(putin.position >= animal2.position){
alert("Oh no! Putin caught and ate " + animal2.name + "!");
}
else if(putin.position >= animal3.position){
alert("Oh no! Putin caught and ate " + animal3.name + "!");
}
else if(putin.position >= animal4.position){
alert("Oh no! Putin caught and ate " + animal4.name + "!");
}
else {
alert(putin.progressReport());
alert(animal1.progressReport() + " -- " + animal2.progressReport() + " -- " + animal3.progressReport() + " -- " + animal4.progressReport());
}
}
</script>