-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitignore.js
274 lines (219 loc) · 10 KB
/
.gitignore.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
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// //next:
// // move questions into app.js (big array of objects, each object k:v pairs)
// // CATEGORIES - separate question array for each (category1, category 2, etc)
// // fix/finish createQuestionCat1 to print questions & answers one at a time! - w Jackson's help
// // created global varible for current question (outside)
// // create variable for single question, use that variable to print Q
// // new varibale for array of answers, loop thru array & create LI, add text to LI, and append LI to parent UL
// // at bottom: for loop to affect global variable currentQuesIdx
// // NOT DOING ANYMORE: create "submit answers" button -> (cached el reference?) & event listener
// // first thing - try to put questions back in sep data doc. (for proj requirement - or ask?)
// // from engineering thread in Slack:
// // for "clicking answers" - add event listener at same time when answers are printed!
// // move for loop to update global variable
// // get LI's clickable / - event listener for those
// // finish function for chooseAnswer - that's where we'll use conditional to see if it matches "true" from quesAs?
// // update playerScore - compare playerChoice with correctAnswer, if === then add points, else then nothing
// // & display playerScore
// // end-game scenario when a Category is finished!
// // when user selects category, tagline, rules, & category buttons disappear -> at any point "reset" or init button starts us over
// // reset button / init
// // PROBLEM - 'reset game' resets board, but then cant populate any new questions - probably has to do with TypeError that appears after I finish a category
// // -line 99! I think ChatGPT came up with a gurd idear! (saved bookmark)
// // PROBLEM - FIXED!--I have "rulesBtnDiv.innerHTML" inside function ONLY FOR CATEGORY 1 - but for some reason it activates even if i'm using category 2 - im calling cat1() inside playerAnswer too! DAMMIT! how can i get that global? - FIXED!!! conditional
// // -Check playerScore!! might be a little wonky
// // timer for entire category, not each question
// // ** sounds: sound for button clicks, add sound for playerScore, and diff sound for perfect score -> button to turn off sounds??
// // fix timer issue!
// // fonts! (quick)
// // ** images: favicon to page DONE, monk image for top of page before game starts
// // mouse pointer, li mouse selects whole thing
// // README! can use "badges" for technology used & credits (inside Course SUpplements > GitHub Beautifuication (2nd link has nicer looking ones)
// // .gitignore or .env for dead code!
// // FIX THT LITTLE BLACK BOX ISUE!! SO CLOSE!!
// // min-width on big container for short questions
CIRCLE BACK IF IM MENTALLY ABLE TO:
-button styles & hover
-fonts
-flexbox fancier
-meditate image go underneath h1 & h2 a bit (position relative, z-index)
-Put rules & category buttons on top of meditate image
// IF I HAVE TIME - BIG
// clearing Q's and A's - diditn mess with it for fear of breaking it - but see if i can display.none instead of innerHTML (but might make a mess with reest? idk)
// // seaprate "rules" & "buttons" - when user starts, everything disappears, but after a reset, only buttons re-appear
// // perfect score make more exciting - if player perfect score, hidden image or page!
// BELOW IS ORIGINAL PSEUDOCODE - the order i wrote things in ended up confusing me - i should have written in order of steps. making some big pivots in code so some are irrelevant - after i get basic functionality better, will come back & try to utilize some of these.
// PSEUDOCODE
// // 1) Define the required variables used to track the state of the game - GAME STATE
// // -scorecard / player score - let playerScore
// // -which question player is on - let currentQuestion
// // -final score / quiz complete - let quizOver (??Maybe not? Since there is no “win state”, only a finite amount of questions)
// // -(maybe separate action for PERFECT score - letPerfectScore)
// 2) Store cached element references
// // -container for question & answers
// -multiple-choice buttons - eliminated until correct answer is selected
// -(points deducted for incorrect answers?)
// // -separate file for data (prompts/answers) - NOT cached element - it's a separate data file
// 3) Upon loading, the game state should be initialized, and a function should be called to render this game state
// // -init function - reset to beginning welcome page, reset score to 0
// // -render function at end of init
// -(ICEBOX) (possible to choose next category without resetting to the welcome page? I.e. continue onto another category from results page? Or too complex for me at the moment?)
// // -player will choose category, then hit “begin” button - altered: category choice itself begins game, NO BEGIN BUTTON
// 4) The state of the game should be rendered to the user
// // -updateBoard (to display each new question)
// // -updateScore (after each question)
// -timer?? Resets for each question, or for entire category (does this belong here?)
// -quizOver - final state, displays score, choices of other categories to try
// 5) Define the required constants
// // -correct answer for each quiz question
// 6) Event listeners
// -handleClick with evt parameter
// -play sound when selecting choices (diff sound for incorrect/correct)
// -(ICEBOX) deduct points for incorrect answer
// -add points & move to next question upon correct answer
// -reset board, or go to next category
// 7) Create Reset functionality
// -reset button to HTML (also as cached element, & event listener)
// let startTimer = setInterval(function() {
// countdown.textContent = timeLeft + ' seconds remaining.'
// timeLeft -= 1
// if (timeLeft < 0) {
// countdownEl.textContent = 'Finished!'
// confetti.start(500)
// }
// }, 1000)
let currQuestionIdx=0 -> this would icnrement up as we go thru next questions
could also do for let score = 0 -> same idea, to keep adding to score
render question method would put questions into (renderedQuestion)
//array of objects
BENS ORIG IDEA - SWITCHING BACK TO THIS
const questionsCat1 = [
{
quesQs: "What do you do etc etc?",
quesAs: [
{ answer: 'be rude', correctAnswer: false },
{ answer: 'be nice', correctAnswer: true },
{ answer: 'be crude', correctAnswer: false },
{ answer: 'be tude', correctAnswer: false },
]
},
{
quesQs: "QUestion 2, what's good to do??",
quesAs: [
{ answer: 'help people', correctAnswer: true },
{ answer: 'hurt people', correctAnswer: false },
{ answer: 'kill people', correctAnswer: false },
{ answer: 'steal someones car', correctAnswer: false },
]
},
{
quesQs: "#3, who's a good person to have around?",
quesAs: [
{ answer: 'bad friend', correctAnswer: false },
{ answer: 'no friend', correctAnswer: false },
{ answer: 'donut stealer', correctAnswer: false },
{ answer: 'Good friend', correctAnswer: true },
]
},
]
2nd method, cleaner but will make more problems later
const questionsCat1 = [
{
quesQs: "What do you do etc etc?",
correctAnswerIdx: 1,
quesAs: [
{ answer1: 'be rude' },
{ answer2: 'be nice' },
{ answer3: 'be crude' },
{ answer4: 'be tude' },
]
},
{
quesQs: "Question #2?",
correctAnswerIdx: 0,
quesAs: [
{ answer1: 'help people' },
{ answer2: 'hurt people' },
{ answer3: 'kill people' },
{ answer4: 'steal someones car' },
]
},
{
quesQs: "Question #3?",
correctAnswerIdx: 3,
quesAs: [
{ answer1: 'bad friend' },
{ answer2: 'no friend' },
{ answer3: 'donut stealer' },
{ answer4: 'Good friend' },
]
},
]
MY ORIG WAY:
{
quesQs: "What do you do etc etc?",
quesAs: {
A: "A - be rude",
B: "B - be nice",
C: "C - be crude",
D: "D - be tude"
},
correctAnswer: "B"
},
{
question: "Question #2?",
answers: {
A: "help people",
B: "hurt people",
C: "kill people",
D: "steal someones car"
},
correctAnswer: "A"
},
{
question: "Question #3?",
answers: {
A: "bad friend",
B: "no friend",
C: "donut stealer",
D: "Good friend"
},
correctAnswer: "D"
},
]
from 1/3 @ 1:40 PM - saving in case i need to go back to anyting - from when i was adding click by adding LI id's
/*--------- Event Listeners ---------*/
btnCategory1.addEventListener('click', renderQuestionCat1)
// eachAnswer.addEventListener('click', playerChooseAnswer)
// tried for loop, when I was adding CLASS to li's instead of ids
// for (let idx = 0; idx < eachAnswer.length; idx++) {
// eachAnswer[idx].addEventListener('click', function() {
// console.log('eachAnswer ' + (idx) + ' clicked!');
// });
// }
/*------------ Functions ------------*/
function renderQuestionCat1() {
//create variable to hold just one specific question (indicated by currentQuesIdx)
const singleQuestion = questionsCat1[currentQuesIdx]
//then use that new variable to access the question & print it
question.textContent = `${singleQuestion.quesQs}`
//create variable to hold all answers to given question - now this holds an array of objects
const answersToSingleQuestion = singleQuestion.quesAs
// console.log(answersToSingleQuestion);
//loop through quesA's array, for each create LI & add text to LI & append LI to parent
answersToSingleQuestion.forEach((eachA) => {
let renderedAnswer = document.createElement('li')
// initial attempty
// add class to each li:
// renderedAnswer.setAttribute('class', 'answer-li');
// OR id to each li
// renderedAnswer.setAttribute('id', 'answer-li');
renderedAnswer.textContent = `${eachA.answer}`
answers.appendChild(renderedAnswer)
// console.log(renderedAnswer);
})
//loop to update GLOBAL currentQuesIdx - Ben recs: want to increment the currentQuesIdx only after a player has made a guess, not all at once like this
// for (let i = 0; i < questionsCat1.length; i++){
// currentQuesIdx += 1
// console.log(currentQuesIdx);
}