-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
674 lines (635 loc) · 28.2 KB
/
index.html
File metadata and controls
674 lines (635 loc) · 28.2 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>STRONGMEN</title>
<style>
body {
margin: 0;
background:
linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3)),
url('backdrop_final.jpg') no-repeat center center fixed;
background-size: cover;
min-height: 100vh;
color: white;
font-family: Georgia, serif;
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
box-sizing: border-box;
justify-content: flex-end;
padding-bottom: 100px;
}
#content {
max-width: 700px;
width: 100%;
text-align: center;
padding: 20px;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 10px;
margin-top: auto;
margin-bottom: 30px;
}
#maintext {
font-size: 20px;
text-align: justify;
hyphens: auto;
line-height: 1.6;
margin-bottom: 30px;
}
#options button {
display: block;
font-family: fantasy;
margin: 15px auto;
font-size: 20px;
padding: 12px;
width: 100%;
max-width: 350px;
background-color: rgba(255,255,255,0.9);
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
#options button:hover {
background-color: white;
}
.score-container {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.score-bar-container {
width: 48%;
margin-bottom: 5px;
}
.score-label {
font-family: fantasy;
font-size: 16px;
margin-bottom: 5px;
}
.score-bar {
height: 20px;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 10px;
overflow: hidden;
position: relative;
}
.score-bar-center {
position: absolute;
width: 2px;
height: 100%;
background-color: white;
left: 50%;
transform: translateX(-50%);
}
.score-bar-fill {
height: 100%;
border-radius: 10px;
transition: all 0.5s ease;
position: absolute;
bottom: 0;
}
#Res_bar-fill {
background-color: #ff6b6b;
left: 50%;
width: 0%;
}
#Ego_bar-fill {
background-color: #feca57;
left: 50%;
width: 0%;
}
.score-value {
font-family: fantasy;
font-size: 14px;
margin-top: 3px;
}
</style>
</head>
<body>
<div id="content">
<div class="score-container">
<div class="score-bar-container">
<div class="score-label">Resistance</div>
<div class="score-bar">
<div class="score-bar-center"></div>
<div id="Res_bar-fill" class="score-bar-fill"></div>
</div>
<div id="Res_score-value" class="score-value">0</div>
</div>
<div class="score-bar-container">
<div class="score-label">Ego</div>
<div class="score-bar">
<div class="score-bar-center"></div>
<div id="Ego_bar-fill" class="score-bar-fill"></div>
</div>
<div id="Ego_score-value" class="score-value">0</div>
</div>
</div>
<div id="maintext"></div>
<div id="options"></div>
</div>
</body>
<script>
// Initialize score and variable X
let Res_Score = 0;
let Ego_Score = 0;
let res_factor = 0;
let ego_factor = 0;
let power = 0; //0 for billionaire friend, 1 for propaganda team
let cause = 0; //0 for immigrants, 1 for libs
let trait = 0; //1 for megalomaniac, 0 for self obsessed
let R1 = 0; //0 for R11, 1 for R12
let eSM = 0;
let rSM = 0;
const e0 = 3;
const r0 = 2;
const e11 = 2; //People in the right places
const r12 = 3; //State of emergency alarms the society
const e21 = -2; //rewriting history didnt look so good
const r22 = 2; //if you fight universities, they fight you back
const r3 = 2; //your dreams are met with a lot of resistance
const r4 = 3; //tariffs make people angry
const e5 = -3; //car sale/signal group was embarrassing
const r611 = -2; //that will shut up your critics
const r621 = -2; //that will shut up your critics
const r612 = 3; //that didnt work so well
const r622 = 3; //that didnt work so well
const e622 = -2; //that didnt work so well
const e71 = -4; //backing down is embarrassing
const r72 = +5; //not backing down makes people very scarred
const Res_End = 7;
const Ego_End = 0
//might still need those
const Y = 5;
const X_HIGH_THRESHOLD = 1; // If X >= 1, it's "high"
const data = {
//introduction
segment1: { //
id: "segment1",
text: "Welcome! Come one, come all! Join the show. On today's program: The strongman! The autoritarian leader, the aspiring dictator, the one to rule power itself.",
options: [
{
id: "segment1a",
text: "Who are you? What is this?"
}
],
},
segment1a: { //
id: "segment1a",
text: "Me? I'm the director of this little show ... your guide, so to speak. I will show you the ways of power. " +
"<br><br>I even took on a fitting form - don't you think so?",
options: [
{
id: "segment1b",
text: "Haha, very funny. Then if this is a 'show', what am I doing here?"
}
],
},
segment1b: { //
id: "segment1b",
text: "Well, well, any play needs actors, don't you know? And as it turns out, I'm short of one. So join me on my stage! \n I will be your director - and you will be my player.",
options: [
{
id: "segment1c",
text: "Do I have a choice?"
}
],
},
segment1c: { //
id: "segment1c",
text: "More choice than I have - if you think about it. You will have plenty of choices, actually! " +
"<br><br> But a word of advice: your actions have consequences. So choose wisely. " +
"Results may not always be what you expect. And don't value yourself too much... " +
"<br><br>Anyway! Welcome, welcome again. Let us begin!",
options: [
{
id: "segment1d",
text: "Okay."
}
],
},
//character building rounds
segment1d: { //1. choose your strength
id: "segment1d",
text: "First, we have to get you into character. " +
"You have to decide which flavor of strongman you want to be." +
" History gives us so many options to pick from. You are not my first student, you see?" +
" <br><br> So first things first: Choose your strength!",
options: [
{
id: "segment2",
text: "Billionaire friend",
setPower: 0, // Sets strength to billionaire
setResFactor: 0.8,
scoreChange: () => ({Ego_Score: Ego_Score + e0}) // billionaire friend boosts your ego
},
{
id: "segment3",
text: "Propaganda Team",
setPower: 1, // Sets strength to propaganda team
setResFactor: 0.5 //Propagandamachine is very helpful
},
],
},
segment2: {//Billionaire friend
id: "segment2",
text: "You are in good company! Many strong leaders have had the backing of the rich. Just ask Pinochet or Franco. " +
"<br><br> I'm sure you will use their money wisely - and kick them out of your office, once your done with them." +
" Like a real strongman. <br><br> Anyway, having this much money in your hands does boost your Ego.",
options: [{id: "segment4",text: "Ok"},],
},
segment3: {//Propaganda team
id: "segment3",
text: "A wise choice! He who controls the media controls reality itself. My student, Putin, for example, understands this very well. Of course," +
" simply owning the media would be even better - Berlusconi would know all about that..." +
"<br><br> Well, we must be happy with what we have. And a propaganda team surely comes in handy when one has to keep down Resistance...",
options: [{id: "segment4",text: "Ok"},],
},
segment4: { //2. choose your weakness
id: "segment4",
text: "Next, you will have to choose a weakness. This is only fair - power comes with a price! I'm sure you can handle it.",
options: [
{
id: "segment5",
text: "Megalomaniac",
setEgoFactor: 1,
setTrait: 1,
setESM: 3,
setRSM: 2,
scoreChange: () => ({Res_Score: Res_Score +r0}) // people think you are dangerous
},
{
id: "segment6",
text: "Self obsessed",
setEgoFactor: 1.5,
setTrait: 0,
setESM: 3,
setRSM: 3
}
],
},
segment5: {//Megalomaniac
id: "segment5",
text: "Ah, the good old Megalomaniac. You see yourself as godsent, larger than life. You lost every sense of reality. " +
"Quite a traditional choice. " +
"Lavish parades, Louis 14th style apartments, fancy titles - you want it all. My student, Idi Amin Dada, called himself: " +
"<br><br>'His Excellency, President for Life, Field Marshal Al Hadji Doctor Idi Amin Dada, VC, DSO, MC, " +
"Lord of All the Beasts of the Earth and Fishes of the Seas and Conqueror of the British Empire " +
"in Africa in General and Uganda in Particular.'" +
"<br><br> Glorious title! But ... maybe you start with calling yourself 'king'. Note though that people think you are dangerous. " +
"There seems to be some resistence building up...",
options: [{id: "segment7",text: "Ok"},],
},
segment6: {//Self obsessed
id: "segment6",
text: "You are a narcissist through and through. You are terribly insecure. How fun!" +
"<br><br> You are in good company! Many of my students had a very fragile ego. Dear Mussolini had to check the news obsessively just to make sure" +
" nobody talked bad about him. Good thing you don't read the news. Instead you are on social media... " +
"<br><br> Your fragile ego, though, makes you react much more volatile when confronted by negative events - let's hope there won't be too many!",
options: [{id: "segment7",text: "Ok"},],
},
segment7: { //3. choose your cause
id: "segment7",
text: "Lastly, you need a cause! Something to bring the people together. After all, your country is suffering and YOU know who's fault that is!" +
" What - or rather who - are you against?",
options: [
{
id: "segment8",
text: "Immigrants!",
setCause: 0 //Immigrants
},
{
id: "segment9",
text: "The Liberals!",
setCause: 1 //The libs
}
],
},
segment8: {//Immigrants
id: "segment8",
text: "Immigrants - such an unoriginal choice. Alas, never change a winning team! <br><br> The fear of the unknown, of 'being replaced' - a hundred years ago, Mussolini" +
"employed this exact parole, saying that Italy was under attack, invaded by African immigrants that would surely replace Italians. Funny, how " +
"some things never go out of fashion.",
options: [{id: "segment10",text: "Ok"},],
},
segment9: {//The Libs
id: "segment9",
text: "The Liberals! The Universities, the free press, women, queer people, leftists. Take your pick! The 'enemy within' always worked wonders." +
"<br><br> I once had a German student who hated queer people (among others). Germany was quite progressive back then, it even had a movement to legalize homosexuality." +
" But as soon as Adolf came to power he closed their institutes and burned their books. And it worked! Who today knows about Magnus Hirschfeld?" +
"<br><br> Of course you would never go after gay people (any time soon). Transgender folks though...",
options: [{id: "segment9a",text: "Ok"},],
},
segment9a: { //
id: "segment9a",
text: "Now, now! The stage is set and your character has been built. You have been elected president and it is time to set your plans in motion.",
options: [
{
id: "segment10",
text: "Okay."
}
],
},
segment10: { //Round 1: Consolidate Power
id: "segment10",
text: "Let's consolidate your power! What should be do first?",
options: [
{
id: "segment11", //R11
text: "Dismantle the government!",
setR1: 0, //R11
scoreChange: () => ({Ego_Score: + ego_factor*e11})
},
{
id: "segment12", //R12
text: "Invoke a state of emergency!",
setR1: 1, //R12
scoreChange: () => ({Res_Score: + res_factor*r12})
}
],
},
segment11: {//R11 Dismantle the Government
id: "segment11",
text: "You are in good company. And now you have people in the right places!",
options: [{id: "segment13", text: "Ok"},],
},
segment12: {//R12 Invoke a state of emergency
id: "segment12",
text: "You are in good company. And taking away power from the judges might come in handy later...",
options: [{id: "segment13",text: "Ok"},],
},
segment13: { //Round 2: Attack education!
id: "segment13",
text: "Well, well! Now its time to 'improve' the education system. We don't want people to learn the wrong things, do we?",
options: [
{
id: "segment14", //R21
text: "Rewrite history",
scoreChange: () => ({Ego_Score: + ego_factor*e21})
},
{
id: "segment15", //R22
text: "Attack universities",
scoreChange: () => ({Res_Score: + res_factor*r22})
}
],
},
segment14: {//R21 Rewrite history
id: "segment14",
text: "You are in good company. However, your 'corrections' were done rather clumsily and you deleted the picture of a " +
"bomber because it was called 'Enola Gay'. The press is making fun of you. How embarrassing... ",
options: [{id: "segment16", text: "Ok"},],
},
segment15: {//R22 attack universities
id: "segment15",
text: "You are in good company. However, it seems like universities are organising themselves now. Resistance is growing...",
options: [{id: "segment16",text: "Ok"},],
},
segment16: { //Round 3a: Follow your dreams!
id: "segment16",
text: "You have been working so hard! And all for the good of the people! It is time to treat yourself",
options: [
{
id: "segment17", //R31
text: "Do something for your cause",
scoreChange: () => ({Res_Score: + res_factor*(r3+rSM), Ego_Score: + ego_factor*eSM})
},
{
id: "segment18", //R32
text: "Do something for yourself",
scoreChange: () => ({Res_Score: + res_factor*(r3+rSM), Ego_Score: + ego_factor*eSM})
}
],
},
segment17: {//R31 Do something for your cause
id: "segment17",
text: () => cause < 1
? "You send a group of immigrants to a torture prison in El Salvadore. " +
"<br><br> While this really helps your ego, you might have ignored due process. Unsurprisingly, resistance rises."
: "You stop all DEI initiatives. While you are at it, you also start cleansing government institutions from all kinds of 'waste, fraud and abuse'. " +
"<br><br> Your followers praise you, but thousands of people lose their jobs and social security." +
" Tensions keep rising...",
options: [{id: "segment19", text: "Ok"},],
},
segment18: {//Do something for yourself
id: "segment18",
text: () => trait < 1
? "You release your own crypto currency. Again. Abu Dhabi promptly invests two billion dollars in your stable coin. " +
"75% of the returns on this money go directly to you, hence, you do feel quite good about yourself. However, some call this" +
" 'corruption' and resistance keeps rising significantly."
: "You propose to invade Canada. And Greenland. You imagine yourself as the king of a united north america. For some reason, the rest " +
" of the world doesn't appreciate your visionary ideas...",
options: [{id: "segment19",text: "Ok"},],
},
segment19: { //Round 4: Tariffs!
id: "segment19",
text: "Your country has been suffering so hard!",
options: [
{
id: "segment20", //R4
text: "Time to put tariffs on everyone!",
scoreChange: () => ({Res_Score: + res_factor*r4})
},
],
},
segment20: {//R4 Tariffs!
id: "segment20",
text: "You are in good company. However, with rising prices, resistance is growing too...",
options: [{id: "segment21", text: "Ok"},],
},
segment21: {//R5 Bad event
id: "segment21",
text: () => power <1
? "Your billionaire friend is calling in a favour. He wants you to promote his cars. You have to do a car sale on your own lawn. It reminds you of your days as a washed-up salesman..."
: "Your subordinates have been caught using an unsafe messanger service. Now you have to defend these idiots. Seems like there is noone you can truly rely on ...",
options: [{id: "segment22", text: "Ok", scoreChange: () => ({Ego_Score: + ego_factor*e5})}],
},
segment22: { //R6: Your critics won't shut up
id: "segment22",
text: "Your critics won't shut up",
options: [
{
id: "segment23", //R61 Go after the free press
text: "Go after the free press",
scoreChange: () => ({Res_Score: + res_factor*R1*r612 + (-(R1-1))*(1/res_factor*r611), Ego_Score: + ego_factor*e622*R1})
},
{
id: "segment24", //R62 Go after the judges
text: "Go after the judges",
scoreChange: () => ({Res_Score: + res_factor*(-(R1-1))*r622 + R1*(1/res_factor*r621), Ego_Score: + ego_factor*e622*(-(R1-1))})
}
],
},
segment23: {//R61 Go after the free press
id: "segment23",
text: () => R1 < 1
? "That will shut up your critics. Good thing you have dismantled the government"
: "That didn't work so well. You might have made the situation worse...",
options: [{id: "segment25", text: "Ok"},],
},
segment24: {//R62 Go after the judges
id: "segment24",
text: () => R1 > 0
? "That will shut up your critics. Good thing you took the power from the judges"
: "That didn't work so well. You might have made the situation worse...",
options: [{id: "segment25",text: "Ok"},],
},
segment25: { //Round 7: Economic crash
id: "segment25",
text: "Seems like your tariffs have caused a major economic crash. What to do?",
options: [
{
id: "segment26", //R71
text: "Back down",
scoreChange: () => ({Ego_Score: + ego_factor*e71})
},
{
id: "segment27", //R22
text: "Don't back down",
scoreChange: () => ({Res_Score: + res_factor*r72})
}
],
},
segment26: {//R71
id: "segment26",
text: "Well, well, Wall Street has made up a nick name for you know, the are calling you TACO. I wonder what that stands for...",
options: [{id: "segment28", text: "Ok"},],
},
segment27: {//R72
id: "segment27",
text: "People are very scared. You might be in for a tough ride...",
options: [{id: "segment28",text: "Ok"},],
},
segment28: {// Round 8
id: "segment28",
text: () => Res_Score <= Res_End
? "You have had enough. Time to choose violence!"
: "You are spiraling",
options: () => Res_Score <= Res_End
? [ //You had enough options
{
id: "segment_Res_low",
text: "Time to incite some riots and then 'restore law and order' by sending in the military.",
scoreChange: () => ({Res_Score: + res_factor*2})
},
{
id: "segment_Res_low",
text: "Time to organize a 'parade to honour our troops' (on your own birthday of course). " +
"And once the tanks are in the capital - why not keep them there? ",
scoreChange: () => ({Res_Score: + res_factor*2})
}
]
: [ //You are spiraling options
{
id: "segment_Res_high",
text: "You pick a fight with the richest man in the world. It escalades quite badly.",
},
{
id: "segment_Res_high",
text: "You generate a picture of yourself as the pope. Might be time to declare yourself as 'lord and saviour'",
}
]
},
segment_Res_low: {
id: "segment_Res_low",
text: () => Ego_Score <= Ego_End //E1 and E2
? "Well, well. Seems like you finished off your last critic. You made it! You are THE strongman. " +
"You might also be miserable - but who said power doesn't come with a price?"
: "Congrats, you started a civil war! Well, don't blame me for that. Tensions are high and " +
"you may have gone a liiiiittle crazy. Might be better to keep down your ego a bit. " +
"<br><br>Anyway, I know enough about the future to tell you that you will get shot very soon... better luck next time. ",
options: []
},
segment_Res_high: {
id: "segment_Res_high",
text: () => Ego_Score <= Ego_End //E3 and E2
? "Weeeell, I think you have embarrassed yourself enough. " +
"And so do the people. You have been impeached. Seems like you didn't have it in you to become a strongman. Might be a good idea to keep an " +
"eye on resistence. " +
"Better luck next time!"
: "Congrats, you started a civil war! Well, don't blame me for that. " +
"Tensions are high and you may have gone a liiiiittle crazy. Might be better to keep down your ego a bit. " +
"<br><br>Anyway, I know enough about the future to tell you that you will get shot very soon... better luck next time. ",
options: []
},
};
window.onload = loadFirstpage;
window.onload = loadFirstpage;
function updateDisplays() {
// Resistance bar (0 to 15)
const resPosPercentage = Math.min(100, Math.max(0, (Res_Score / 20) * 100));
const resNegPercentage = Math.min(100, Math.max(0, (-Res_Score / 5) * 100));
// Ego bar (-5 to 0 to 15)
const egoPosPercentage = Math.min(100, Math.max(0, (Ego_Score / 20) * 100));
const egoNegPercentage = Math.min(100, Math.max(0, (-Ego_Score / 5) * 100));
// Update Resistance bar
if (Res_Score >= 0) {
document.querySelector("#Res_bar-fill").style.left = "50%";
document.querySelector("#Res_bar-fill").style.width = `${resPosPercentage}%`;
document.querySelector("#Res_bar-fill").style.backgroundColor = "#ff6b6b";
} else {
document.querySelector("#Res_bar-fill").style.left = `${50 - resNegPercentage}%`;
document.querySelector("#Res_bar-fill").style.width = `${resNegPercentage}%`;
document.querySelector("#Res_bar-fill").style.backgroundColor = "#ff9e9e"; // Lighter red for negative
}
// Update Ego bar
if (Ego_Score >= 0) {
document.querySelector("#Ego_bar-fill").style.left = "50%";
document.querySelector("#Ego_bar-fill").style.width = `${egoPosPercentage}%`;
document.querySelector("#Ego_bar-fill").style.backgroundColor = "#feca57";
} else {
document.querySelector("#Ego_bar-fill").style.left = `${50 - egoNegPercentage}%`;
document.querySelector("#Ego_bar-fill").style.width = `${egoNegPercentage}%`;
document.querySelector("#Ego_bar-fill").style.backgroundColor = "#ffe0a3"; // Lighter yellow for negative
}
// Update numeric values
document.querySelector("#Res_score-value").textContent = `${Math.round(Res_Score * 100) / 100}`;
document.querySelector("#Ego_score-value").textContent = `${Math.round(Ego_Score * 100) / 100}`;
}
function loadFirstpage() {
Res_Score = 0;
Ego_Score = 0;
updateDisplays();
document.querySelector("#maintext").innerHTML = data.segment1.text;
generateButtonsFromIds(data.segment1.options, "options");
}
function loadNextpage(id, scoreChange = () => ({})) {
const changes = scoreChange();
if (changes.Res_Score !== undefined) Res_Score += changes.Res_Score;
if (changes.Ego_Score !== undefined) Ego_Score += changes.Ego_Score;
updateDisplays();
const segment = data[id];
const text = typeof segment.text === 'function' ? segment.text() : segment.text;
const options = typeof segment.options === 'function' ? segment.options() : segment.options;
document.querySelector("#maintext").innerHTML = text;
generateButtonsFromIds(options, "options");
}
function generateButtonsFromIds(idArray, containerId) {
const container = document.getElementById(containerId);
if (!container) return;
container.innerHTML = "";
idArray.forEach((option) => {
const button = document.createElement("button");
button.textContent = option.text;
button.setAttribute("data-id", option.id);
button.addEventListener("click", () => {
if (option.setEgoFactor !== undefined) ego_factor = option.setEgoFactor;
if (option.setResFactor !== undefined) res_factor = option.setResFactor;
if (option.setPower !== undefined) power = option.setPower;
if (option.setCause !== undefined) cause = option.setCause;
if (option.setTrait !== undefined) trait = option.setTrait;
if (option.setESM !== undefined) eSM = option.setESM;
if (option.setRSM !== undefined) rSM = option.setRSM;
if (option.setR1 !== undefined) R1 = option.setR1;
const scoreChangeFn = option.scoreChange || (() => 0);
loadNextpage(option.id, scoreChangeFn);
});
container.appendChild(button);
});
}
</script>
</html>