-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontroller.js
More file actions
239 lines (220 loc) · 10.8 KB
/
controller.js
File metadata and controls
239 lines (220 loc) · 10.8 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
var app = angular.module('gameApp', ['angularModalService']);
app.controller('gameCtrl', ['$scope', '$log', 'ModalService', function($scope, $log, ModalService) {
$scope.$log = $log;
$scope.player1 = {'name': 'Player 1', 'score': 0, 'bet': 0};
$scope.player2 = {'name': 'Player 2', 'score': 0, 'bet': 0};
$scope.showOption = true;
$scope.questionsDone = 0;
$scope.FinalJeopardy = false;
$scope.finalRespond1 = true;
$scope.finalRespond2 = true;
$scope.winner = '';
$scope.title = 'Jeopardy!';
$scope.showQuestion = function(QandA) {
$log.log(QandA);
};
$scope.round = {
'name':'Game 1',
'categories': {
'Command Line': {
'100':
{'Is another name for Command Line': 'What is Shell, GUI, Terminal or Console?'},
'200':
{'Its acronym is pwd.' : 'What is Print Working Directory?'},
'300':
{'A command to see the built in manual' : 'What is "man"?'},
'400':
{'A command to print to STDOUT' : 'What is "echo"?'},
'500':
{'A command to seach within files' : 'What is "grep"?'},
},
'TV': {
'100':
{'A weekly television series on NBC was the first to air completely in color in 1959': 'What is the show Bonanza?'},
'200':
{'The family name of the main characters in the Cosby Show which ran from 1984-1992' : 'What is The Huxtable Family?'},
'300':
{'A popular children show that debuted on PBS in 1969' : 'What is Sesame Street?'},
'400':
{'The breakout star who played Stella Carlin on the third season of Orange Is the New Black' : 'Who is Ruby Rose?'},
'500':
{'The last guest on the Late Show with David Letterman' : 'Who is Bill Murray?'},
},
'Movies' : {
'100':
{'Sings the theme song for "Spectre", the new James Bond film': 'Who is Sam Smith?'},
'200':
{'Charlize Theron played this bad-ass character in "Mad Max: Fury Road"' : 'Who is Furiosa?'},
'300':
{'Won the Best Picture at the 2015 Academy Awards' : 'What is Birdman?'},
'400':
{'Amy Schumers well-received comedy "Trainwreck" co-starred which famous NBA player' : 'Who is Lebron James?'},
'500':
{'Cast as Belle in the upcoming Disney live-action "Beauty and the Beast"' : 'Who is Emma Watson?'},
},
'Python': {
'100':
{'The hardest part of programming': 'What is naming variables?'},
'200':
{'A one-line summary for fucntions' : 'What is Docstrings?'},
'300':
{'The data structure that range() returns' : 'What is list?'},
'400':
{'The list of things defined for a function to receive' : 'What are parameters?'},
'500':
{'The Zen of Python poem prints out using this command' : 'What is "import this"?'},
},
'Ada or Grace': {
'100':
{'She is the first computer programmer in history': 'Who is Ada?'},
'200':
{'She retired from the navy at the standard age of 60, but was repeatedly recalled until her eighties' : 'Who is Grace?'},
'300':
{'Her most famous quotes, which is often attributed to others, is: "It\'s easier to ask forgiveness than it is to get permission."' : 'Who is Grace?'},
'400':
{'She was described as "The most coarse and vulgar woman in England. . ."' : 'Who is Ada?'},
'500':
{'When she was younger she believed she could fly, and wrote illustrated a guide called Flyology' : 'Who is Ada?'},
},
'Staff' : {
'100':
{'Used to live in a communal, falling-down 28-room mansion in baltimore': 'Who is Joel?'},
'200':
{'Carried Stephen Hawking\'s wheelchair with him in it' : 'Who is Henry?'},
'300':
{'Has a betta fish - and talks to it A LOT' : 'Who is Meggie?'},
'400':
{'This persons great-great-great uncle was president of Mexico' : 'Who is Leslie?'},
'500':
{'Bungy jumped off the 3rd largest bungy jump distance in the world' : 'Who is Ally?'},
},
}
};
$scope.finaljeopardy = {
'question': 'A style guide for python, its acronym is PEP',
'answer': 'What are Python Enhancement Proposals?'
};
$scope.init = function(){
ModalService.showModal({
templateUrl: 'splash.html',
controller: 'ModalController',
scope: $scope,
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
});
});
};
$scope.loss = function(player, dollars) {
player.score -= Number(dollars);
$log.log(player.name + " " + player.score);
};
$scope.finalloss = function(player) {
player.score -= Number(player.bet);
$log.log(player.name + " " + player.score);
};
$scope.finalright = function(player) {
player.score += Number(player.bet);
$log.log(player.name + " " + player.score);
};
$scope.bet = function(player1bet, player2bet) {
$scope.player1.bet = Number(player1bet);
$scope.player2.bet = Number(player2bet);
$log.log($scope.player1);
$log.log($scope.player2);
};
$scope.showQ = function(QandA, dollars) {
$scope.questionsDone++;
ModalService.showModal({
templateUrl: 'question.html',
controller: "ModalController",
scope: $scope,
}).then(function(modal) {
modal.element.modal();
$scope.currentQ = Object.keys(QandA)[0];
$scope.currentA = QandA[$scope.currentQ];
$scope.dollars = dollars;
$scope.wrong1 = false;
$scope.wrong2 = false;
modal.close.then(function(player) {
player.score += Number(dollars);
$scope.showA();
});
});
};
$scope.showA = function() {
ModalService.showModal({
templateUrl: 'answer.html',
controller: "ModalController",
scope: $scope,
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$log.log($scope.questionsDone);
if ($scope.questionsDone === 30) {
$scope.FinalJeopardy = true;
}
});
});
};
$scope.showBetting = function(){
ModalService.showModal({
templateUrl: 'bettingfinal.html',
controller: 'ModalController',
scope: $scope,
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$log.log(result);
$scope.showFinal();
});
});
};
$scope.showFinal = function(){
ModalService.showModal({
templateUrl: 'finaljeopardyQ.html',
controller: 'ModalController',
scope: $scope,
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$scope.showFinalA();
});
});
};
$scope.showFinalA = function() {
ModalService.showModal({
templateUrl: 'finalanswer.html',
controller: 'ModalController',
scope: $scope,
}).then(function(modal){
modal.element.modal();
modal.close.then(function(result) {
if ($scope.player1.score > $scope.player2.score){
$scope.winner = "Player 1";
} else if ($scope.player1.score === $scope.player2.score){
$scope.winner = "Tie";
}else {
$scope.winner = "Player 2";
}
$scope.showWinner();
});
});
};
$scope.showWinner = function(){
ModalService.showModal({
templateUrl: 'winner.html',
controller: 'ModalController',
scope: $scope,
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
});
});
};
}]);
app.controller('ModalController', function($scope, close) {
$scope.close = function(result) {
close(result, 500); // close, but give 500ms for bootstrap to animate
};
});