-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathmain.js
70 lines (55 loc) · 1.42 KB
/
main.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
// var pizzaCook = {
// ego: 0,
// spinDough: function () {
// this.ego += 1;
// if (this.ego > 10) {
// this.trigger('confidence');
// }
// }
// };
// // TODO: RIGHT HERE
// Robin.extend(pizzaCook,Robin.Events)
// pizzaCook.on('confidence', function () {
// alert('I HAVE SOLVED WORLD HUNGER');
// });
// for (var i = 0; i < 11; i += 1) {
// pizzaCook.spinDough();
// }
// var weather = Robin.extend({}, Robin.Events);
// weather.on('snow-storm',function() {
// alert('Bring your coats');
// })
// weather.on('tornado',function() {
// alert('Everybahdy panic!')
// })
// weather.trigger('snow-storm');
// weather.trigger('tornado');
var fireEater = {
state: 'arrogant',
eatFire: function () {
if (this.state === 'choking') {
this.trigger('choke');
return;
}
var fate = parseInt(Math.random() * 5, 10);
if (fate === 0) {
this.trigger('choke');
this.state = 'choking';
}
else {
this.trigger('pose');
}
}
};
Robin.extend(fireEater,Robin.Events);
fireEater.on("pose",function() {
console.log("audience applause")
})
fireEater.on("choke",function() {
console.log("audience gasp")
});
// Add two event listeners on fireEater that listen for a pose event and a choke event. When the fire eater poses,
// console log an applause. When the fire eater chokes, console log an audience gasp
for (var i = 0; i < 10; i += 1) {
fireEater.eatFire();
}