Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
197 lines (180 loc) · 6.99 KB
/
Copy pathscript.js
File metadata and controls
197 lines (180 loc) · 6.99 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
const titles = {
loop2: [
"But we need that information to diagnose you.",
"We can't give you a diagnosis if you don't answer.",
"Without that information we can't continue."
],
loop3: [
"I'm sorry, it's protocol.",
"It's protocol unfortunately.",
"Nothing we can do about this protocol.",
"We are required to ask this."
],
loop4: [
"So... Still don't want to answer it?",
"Do you want to answer the question now?"
],
loop5: [
"I'm afraid you won't get hormones then.",
"We can't continue your treatment here.",
"Let's see how you feel next appointment."
],
loop6: [
"See you next month!",
"We'll talk to you later."
]
};
let gender; // will be filled in the first question
let progressDelay = 10;
// 16 seconds = (5 * 365 * 24 * 60 * 60) / 10,000,001
// but this doesn't seem to work well. so we estimate. current factor is 66. change accordingly.
let progressTime = 66 / 100 * (1000 / progressDelay);
let progressTimePast = 0;
let progress = 0;
let progressState = 0;
let updateProgressFunc;
let progressBar = document.getElementById('progress');
let loopsDone = 0;
let buttons = document.querySelectorAll('button'), i;
const lostScreens = ['no_treatment', 'too_fat', 'dont_lie', 'just_confused', 'non_binary', 'too_autistic', 'no_porn', 'no_one', 'hrt_illegal'];
let showSecretMessage = false;
doAction('info');
function determineOrientation(attractedGender) {
console.log(gender, attractedGender)
let binary = ['male', 'female'];
if (binary.includes(gender) && binary.includes(attractedGender) && gender !== attractedGender) {
return goTo('question2')
} else {
if (binary.includes(attractedGender)) {
let misgender_i = binary.indexOf(gender) ^ 1; // Bitwise to flip the index
let genderDesc = attractedGender === 'male' ? 'boyfriend' : 'girlfriend';
let genderTitle = binary[misgender_i] === 'male' ? 'man' : 'woman';
document.getElementById('confused-title').textContent = "You're just a confused " + genderTitle + ".";
document.getElementById('confused-desc').textContent = 'Maybe you should get a ' + genderDesc + ' first.';
} else {
document.getElementById('confused-title').textContent = "You're just confused.";
document.getElementById('confused-desc').textContent = 'Maybe you should get a partner first.';
}
return goTo('just_confused');
}
}
function goTo(elementId) {
setTexts();
let elements = document.getElementsByClassName('box')
for (let i = 0; i < elements.length; i++) {
elements[i].style.display = 'none';
}
let showElement = document.getElementById('box-' + elementId);
showElement.style.display = 'block'
if (elementId === 'progress') {
progress = 0;
progressTimePast = 0;
clearInterval(updateProgressFunc);
updateProgressFunc = setInterval(updateProgress, progressDelay);
} else if (elementId === 'question1') {
clearInterval(updateProgressFunc);
document.getElementById("progress-small").innerHTML = "<span onclick=\"goTo('question1');\">(Press space to skip or click here)</span>";
} else if (elementId === 'loop2') {
loopsDone += 1;
for (i = 0; i < buttons.length; ++i) {
buttons[i].className = "loop" + loopsDone;
}
if (loopsDone == 10) {
let title = document.querySelector('#box-loop2 h2');
title.innerText = "Game over.";
document.querySelector('#box-loop2 button').style.display = "none";
title.insertAdjacentHTML("afterend", "<p>But you made it to the secret end!</p>");
doAction('secretunlocked');
}
} else if (elementId === 'binary_end') {
doAction('won');
}
if (lostScreens.includes(elementId)) {
doAction('lost');
}
}
function updateProgress() {
if (progress < 100) {
if (progressState === 0) {
progressTimePast += progressDelay;
} else if (progressState === 1) {
progressTimePast -= progressDelay * 2;
} else {
progressTimePast += progressDelay;
}
if (progressState === 0 && progress > 95) {
progressState = 1;
} else if (progressState === 1 && progress < 65) {
progressState = 2;
}
progress = (progressTimePast / progressTime) * 1;
progressBar.value = Math.round(progress * 100) / 10000;
} else {
progressState = 2;
goTo('question1');
}
}
document.addEventListener('keydown', skipProgress);
function skipProgress(e) {
let boxLoading = document.getElementById('box-progress');
// Skip only the loading screen
if (boxLoading.style.display !== "none" && e.code === "Space") {
goTo('question1');
}
}
function setTexts() {
const paragraphs = {
no_treatment: [
"It seems you can't transition if you don't work on your other problems first.",
"That sucks. Good luck!"
],
dont_lie: [
"Don't lie to me.",
"That's impossible.",
"So you don't want hormones then?"
],
non_binary: [
"We don't treat non binary people lol get outta here",
"What? Non-binary doesn't exist."
],
too_autistic: [
"You're too autistic my friend, sorry.",
"You're already weird. Don't make it weirder."
],
too_fat: [
"You should really lose some of that weight, otherwise we won't give you anything."
],
// use a getter function to reuse answers but also add unique ones
get no_porn() {
// all unique answers for this option
let base = [
"Everyone has those urges.",
];
// combine unique answers with shared answers
return base.concat(this.dont_lie.slice(0, 2));
}
}
for (let question in titles) {
let items = titles[question];
let item = items[Math.floor(Math.random() * items.length)];
document.querySelector('#box-' + question + ' h2').innerText = item;
}
for (let reason in paragraphs) {
let items = paragraphs[reason];
let item = items[Math.floor(Math.random() * items.length)];
document.querySelector('#box-' + reason + ' p').innerText = item;
}
}
function doAction(action) {
const xhttp = new XMLHttpRequest();
xhttp.open("GET", "score.php?action=" + action, false);
xhttp.send();
const obj = JSON.parse(xhttp.responseText);
document.getElementById('user-id').textContent = obj.id;
document.getElementById('user-won').textContent = obj.won;
document.getElementById('user-lost').textContent = obj.lost;
if (obj.secretunlocked > 0 && showSecretMessage == false) {
document.getElementById('user-lost').insertAdjacentHTML("afterend", "<br />You have unlocked the secret ending!");
showSecretMessage = true;
}
}