-
Notifications
You must be signed in to change notification settings - Fork 0
/
story.js
957 lines (891 loc) · 43.8 KB
/
story.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
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
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
// Created with Squiffy 5.1.2
// https://github.com/textadventures/squiffy
(function(){
/* jshint quotmark: single */
/* jshint evil: true */
var squiffy = {};
(function () {
'use strict';
squiffy.story = {};
var initLinkHandler = function () {
var handleLink = function (link) {
if (link.hasClass('disabled')) return;
var passage = link.data('passage');
var section = link.data('section');
var rotateAttr = link.attr('data-rotate');
var sequenceAttr = link.attr('data-sequence');
if (passage) {
disableLink(link);
squiffy.set('_turncount', squiffy.get('_turncount') + 1);
passage = processLink(passage);
if (passage) {
currentSection.append('<hr/>');
squiffy.story.passage(passage);
}
var turnPassage = '@' + squiffy.get('_turncount');
if (turnPassage in squiffy.story.section.passages) {
squiffy.story.passage(turnPassage);
}
if ('@last' in squiffy.story.section.passages && squiffy.get('_turncount')>= squiffy.story.section.passageCount) {
squiffy.story.passage('@last');
}
}
else if (section) {
currentSection.append('<hr/>');
disableLink(link);
section = processLink(section);
squiffy.story.go(section);
}
else if (rotateAttr || sequenceAttr) {
var result = rotate(rotateAttr || sequenceAttr, rotateAttr ? link.text() : '');
link.html(result[0].replace(/"/g, '"').replace(/'/g, '\''));
var dataAttribute = rotateAttr ? 'data-rotate' : 'data-sequence';
link.attr(dataAttribute, result[1]);
if (!result[1]) {
disableLink(link);
}
if (link.attr('data-attribute')) {
squiffy.set(link.attr('data-attribute'), result[0]);
}
squiffy.story.save();
}
};
squiffy.ui.output.on('click', 'a.squiffy-link', function () {
handleLink(jQuery(this));
});
squiffy.ui.output.on('keypress', 'a.squiffy-link', function (e) {
if (e.which !== 13) return;
handleLink(jQuery(this));
});
squiffy.ui.output.on('mousedown', 'a.squiffy-link', function (event) {
event.preventDefault();
});
};
var disableLink = function (link) {
link.addClass('disabled');
link.attr('tabindex', -1);
}
squiffy.story.begin = function () {
if (!squiffy.story.load()) {
squiffy.story.go(squiffy.story.start);
}
};
var processLink = function(link) {
link = String(link);
var sections = link.split(',');
var first = true;
var target = null;
sections.forEach(function (section) {
section = section.trim();
if (startsWith(section, '@replace ')) {
replaceLabel(section.substring(9));
}
else {
if (first) {
target = section;
}
else {
setAttribute(section);
}
}
first = false;
});
return target;
};
var setAttribute = function(expr) {
var lhs, rhs, op, value;
var setRegex = /^([\w]*)\s*=\s*(.*)$/;
var setMatch = setRegex.exec(expr);
if (setMatch) {
lhs = setMatch[1];
rhs = setMatch[2];
if (isNaN(rhs)) {
if(startsWith(rhs,"@")) rhs=squiffy.get(rhs.substring(1));
squiffy.set(lhs, rhs);
}
else {
squiffy.set(lhs, parseFloat(rhs));
}
}
else {
var incDecRegex = /^([\w]*)\s*([\+\-\*\/])=\s*(.*)$/;
var incDecMatch = incDecRegex.exec(expr);
if (incDecMatch) {
lhs = incDecMatch[1];
op = incDecMatch[2];
rhs = incDecMatch[3];
if(startsWith(rhs,"@")) rhs=squiffy.get(rhs.substring(1));
rhs = parseFloat(rhs);
value = squiffy.get(lhs);
if (value === null) value = 0;
if (op == '+') {
value += rhs;
}
if (op == '-') {
value -= rhs;
}
if (op == '*') {
value *= rhs;
}
if (op == '/') {
value /= rhs;
}
squiffy.set(lhs, value);
}
else {
value = true;
if (startsWith(expr, 'not ')) {
expr = expr.substring(4);
value = false;
}
squiffy.set(expr, value);
}
}
};
var replaceLabel = function(expr) {
var regex = /^([\w]*)\s*=\s*(.*)$/;
var match = regex.exec(expr);
if (!match) return;
var label = match[1];
var text = match[2];
if (text in squiffy.story.section.passages) {
text = squiffy.story.section.passages[text].text;
}
else if (text in squiffy.story.sections) {
text = squiffy.story.sections[text].text;
}
var stripParags = /^<p>(.*)<\/p>$/;
var stripParagsMatch = stripParags.exec(text);
if (stripParagsMatch) {
text = stripParagsMatch[1];
}
var $labels = squiffy.ui.output.find('.squiffy-label-' + label);
$labels.fadeOut(1000, function() {
$labels.html(squiffy.ui.processText(text));
$labels.fadeIn(1000, function() {
squiffy.story.save();
});
});
};
squiffy.story.go = function(section) {
squiffy.set('_transition', null);
newSection();
squiffy.story.section = squiffy.story.sections[section];
if (!squiffy.story.section) return;
squiffy.set('_section', section);
setSeen(section);
var master = squiffy.story.sections[''];
if (master) {
squiffy.story.run(master);
squiffy.ui.write(master.text);
}
squiffy.story.run(squiffy.story.section);
// The JS might have changed which section we're in
if (squiffy.get('_section') == section) {
squiffy.set('_turncount', 0);
squiffy.ui.write(squiffy.story.section.text);
squiffy.story.save();
}
};
squiffy.story.run = function(section) {
if (section.clear) {
squiffy.ui.clearScreen();
}
if (section.attributes) {
processAttributes(section.attributes);
}
if (section.js) {
section.js();
}
};
squiffy.story.passage = function(passageName) {
var passage = squiffy.story.section.passages[passageName];
if (!passage) return;
setSeen(passageName);
var masterSection = squiffy.story.sections[''];
if (masterSection) {
var masterPassage = masterSection.passages[''];
if (masterPassage) {
squiffy.story.run(masterPassage);
squiffy.ui.write(masterPassage.text);
}
}
var master = squiffy.story.section.passages[''];
if (master) {
squiffy.story.run(master);
squiffy.ui.write(master.text);
}
squiffy.story.run(passage);
squiffy.ui.write(passage.text);
squiffy.story.save();
};
var processAttributes = function(attributes) {
attributes.forEach(function (attribute) {
if (startsWith(attribute, '@replace ')) {
replaceLabel(attribute.substring(9));
}
else {
setAttribute(attribute);
}
});
};
squiffy.story.restart = function() {
if (squiffy.ui.settings.persist && window.localStorage) {
var keys = Object.keys(localStorage);
jQuery.each(keys, function (idx, key) {
if (startsWith(key, squiffy.story.id)) {
localStorage.removeItem(key);
}
});
}
else {
squiffy.storageFallback = {};
}
if (squiffy.ui.settings.scroll === 'element') {
squiffy.ui.output.html('');
squiffy.story.begin();
}
else {
location.reload();
}
};
squiffy.story.save = function() {
squiffy.set('_output', squiffy.ui.output.html());
};
squiffy.story.load = function() {
var output = squiffy.get('_output');
if (!output) return false;
squiffy.ui.output.html(output);
currentSection = jQuery('#' + squiffy.get('_output-section'));
squiffy.story.section = squiffy.story.sections[squiffy.get('_section')];
var transition = squiffy.get('_transition');
if (transition) {
eval('(' + transition + ')()');
}
return true;
};
var setSeen = function(sectionName) {
var seenSections = squiffy.get('_seen_sections');
if (!seenSections) seenSections = [];
if (seenSections.indexOf(sectionName) == -1) {
seenSections.push(sectionName);
squiffy.set('_seen_sections', seenSections);
}
};
squiffy.story.seen = function(sectionName) {
var seenSections = squiffy.get('_seen_sections');
if (!seenSections) return false;
return (seenSections.indexOf(sectionName) > -1);
};
squiffy.ui = {};
var currentSection = null;
var screenIsClear = true;
var scrollPosition = 0;
var newSection = function() {
if (currentSection) {
disableLink(jQuery('.squiffy-link', currentSection));
}
var sectionCount = squiffy.get('_section-count') + 1;
squiffy.set('_section-count', sectionCount);
var id = 'squiffy-section-' + sectionCount;
currentSection = jQuery('<div/>', {
id: id,
}).appendTo(squiffy.ui.output);
squiffy.set('_output-section', id);
};
squiffy.ui.write = function(text) {
screenIsClear = false;
scrollPosition = squiffy.ui.output.height();
currentSection.append(jQuery('<div/>').html(squiffy.ui.processText(text)));
squiffy.ui.scrollToEnd();
};
squiffy.ui.clearScreen = function() {
squiffy.ui.output.html('');
screenIsClear = true;
newSection();
};
squiffy.ui.scrollToEnd = function() {
var scrollTo, currentScrollTop, distance, duration;
if (squiffy.ui.settings.scroll === 'element') {
scrollTo = squiffy.ui.output[0].scrollHeight - squiffy.ui.output.height();
currentScrollTop = squiffy.ui.output.scrollTop();
if (scrollTo > currentScrollTop) {
distance = scrollTo - currentScrollTop;
duration = distance / 0.4;
squiffy.ui.output.stop().animate({ scrollTop: scrollTo }, duration);
}
}
else {
scrollTo = scrollPosition;
currentScrollTop = Math.max(jQuery('body').scrollTop(), jQuery('html').scrollTop());
if (scrollTo > currentScrollTop) {
var maxScrollTop = jQuery(document).height() - jQuery(window).height();
if (scrollTo > maxScrollTop) scrollTo = maxScrollTop;
distance = scrollTo - currentScrollTop;
duration = distance / 0.5;
jQuery('body,html').stop().animate({ scrollTop: scrollTo }, duration);
}
}
};
squiffy.ui.processText = function(text) {
function process(text, data) {
var containsUnprocessedSection = false;
var open = text.indexOf('{');
var close;
if (open > -1) {
var nestCount = 1;
var searchStart = open + 1;
var finished = false;
while (!finished) {
var nextOpen = text.indexOf('{', searchStart);
var nextClose = text.indexOf('}', searchStart);
if (nextClose > -1) {
if (nextOpen > -1 && nextOpen < nextClose) {
nestCount++;
searchStart = nextOpen + 1;
}
else {
nestCount--;
searchStart = nextClose + 1;
if (nestCount === 0) {
close = nextClose;
containsUnprocessedSection = true;
finished = true;
}
}
}
else {
finished = true;
}
}
}
if (containsUnprocessedSection) {
var section = text.substring(open + 1, close);
var value = processTextCommand(section, data);
text = text.substring(0, open) + value + process(text.substring(close + 1), data);
}
return (text);
}
function processTextCommand(text, data) {
if (startsWith(text, 'if ')) {
return processTextCommand_If(text, data);
}
else if (startsWith(text, 'else:')) {
return processTextCommand_Else(text, data);
}
else if (startsWith(text, 'label:')) {
return processTextCommand_Label(text, data);
}
else if (/^rotate[: ]/.test(text)) {
return processTextCommand_Rotate('rotate', text, data);
}
else if (/^sequence[: ]/.test(text)) {
return processTextCommand_Rotate('sequence', text, data);
}
else if (text in squiffy.story.section.passages) {
return process(squiffy.story.section.passages[text].text, data);
}
else if (text in squiffy.story.sections) {
return process(squiffy.story.sections[text].text, data);
}
else if (startsWith(text,'@') && !startsWith(text,'@replace')) {
processAttributes(text.substring(1).split(","));
return "";
}
return squiffy.get(text);
}
function processTextCommand_If(section, data) {
var command = section.substring(3);
var colon = command.indexOf(':');
if (colon == -1) {
return ('{if ' + command + '}');
}
var text = command.substring(colon + 1);
var condition = command.substring(0, colon);
condition = condition.replace("<", "<");
var operatorRegex = /([\w ]*)(=|<=|>=|<>|<|>)(.*)/;
var match = operatorRegex.exec(condition);
var result = false;
if (match) {
var lhs = squiffy.get(match[1]);
var op = match[2];
var rhs = match[3];
if(startsWith(rhs,'@')) rhs=squiffy.get(rhs.substring(1));
if (op == '=' && lhs == rhs) result = true;
if (op == '<>' && lhs != rhs) result = true;
if (op == '>' && lhs > rhs) result = true;
if (op == '<' && lhs < rhs) result = true;
if (op == '>=' && lhs >= rhs) result = true;
if (op == '<=' && lhs <= rhs) result = true;
}
else {
var checkValue = true;
if (startsWith(condition, 'not ')) {
condition = condition.substring(4);
checkValue = false;
}
if (startsWith(condition, 'seen ')) {
result = (squiffy.story.seen(condition.substring(5)) == checkValue);
}
else {
var value = squiffy.get(condition);
if (value === null) value = false;
result = (value == checkValue);
}
}
var textResult = result ? process(text, data) : '';
data.lastIf = result;
return textResult;
}
function processTextCommand_Else(section, data) {
if (!('lastIf' in data) || data.lastIf) return '';
var text = section.substring(5);
return process(text, data);
}
function processTextCommand_Label(section, data) {
var command = section.substring(6);
var eq = command.indexOf('=');
if (eq == -1) {
return ('{label:' + command + '}');
}
var text = command.substring(eq + 1);
var label = command.substring(0, eq);
return '<span class="squiffy-label-' + label + '">' + process(text, data) + '</span>';
}
function processTextCommand_Rotate(type, section, data) {
var options;
var attribute = '';
if (section.substring(type.length, type.length + 1) == ' ') {
var colon = section.indexOf(':');
if (colon == -1) {
return '{' + section + '}';
}
options = section.substring(colon + 1);
attribute = section.substring(type.length + 1, colon);
}
else {
options = section.substring(type.length + 1);
}
var rotation = rotate(options.replace(/"/g, '"').replace(/'/g, '''));
if (attribute) {
squiffy.set(attribute, rotation[0]);
}
return '<a class="squiffy-link" data-' + type + '="' + rotation[1] + '" data-attribute="' + attribute + '" role="link">' + rotation[0] + '</a>';
}
var data = {
fulltext: text
};
return process(text, data);
};
squiffy.ui.transition = function(f) {
squiffy.set('_transition', f.toString());
f();
};
squiffy.storageFallback = {};
squiffy.set = function(attribute, value) {
if (typeof value === 'undefined') value = true;
if (squiffy.ui.settings.persist && window.localStorage) {
localStorage[squiffy.story.id + '-' + attribute] = JSON.stringify(value);
}
else {
squiffy.storageFallback[attribute] = JSON.stringify(value);
}
squiffy.ui.settings.onSet(attribute, value);
};
squiffy.get = function(attribute) {
var result;
if (squiffy.ui.settings.persist && window.localStorage) {
result = localStorage[squiffy.story.id + '-' + attribute];
}
else {
result = squiffy.storageFallback[attribute];
}
if (!result) return null;
return JSON.parse(result);
};
var startsWith = function(string, prefix) {
return string.substring(0, prefix.length) === prefix;
};
var rotate = function(options, current) {
var colon = options.indexOf(':');
if (colon == -1) {
return [options, current];
}
var next = options.substring(0, colon);
var remaining = options.substring(colon + 1);
if (current) remaining += ':' + current;
return [next, remaining];
};
var methods = {
init: function (options) {
var settings = jQuery.extend({
scroll: 'body',
persist: true,
restartPrompt: true,
onSet: function (attribute, value) {}
}, options);
squiffy.ui.output = this;
squiffy.ui.restart = jQuery(settings.restart);
squiffy.ui.settings = settings;
if (settings.scroll === 'element') {
squiffy.ui.output.css('overflow-y', 'auto');
}
initLinkHandler();
squiffy.story.begin();
return this;
},
get: function (attribute) {
return squiffy.get(attribute);
},
set: function (attribute, value) {
squiffy.set(attribute, value);
},
restart: function () {
if (!squiffy.ui.settings.restartPrompt || confirm('Are you sure you want to restart?')) {
squiffy.story.restart();
}
}
};
jQuery.fn.squiffy = function (methodOrOptions) {
if (methods[methodOrOptions]) {
return methods[methodOrOptions]
.apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof methodOrOptions === 'object' || ! methodOrOptions) {
return methods.init.apply(this, arguments);
} else {
jQuery.error('Method ' + methodOrOptions + ' does not exist');
}
};
})();
var get = squiffy.get;
var set = squiffy.set;
squiffy.story.start = 'Beginning';
squiffy.story.id = 'e424eb7b6b';
squiffy.story.sections = {
'Beginning': {
'clear': true,
'text': "<p><img src=\"images/coverIntro.png\" id=\"introImage\" /></p>\n<div id=\"introText\">Turn on sound, and <a class=\"squiffy-link link-section\" data-section=\"begin.\" role=\"link\" tabindex=\"0\">begin.</a></div>\n\n<!--<a class=\"squiffy-link link-section\" data-section=\"leaveLR\" role=\"link\" tabindex=\"0\">DEV cut to end of intro</a>\n\n//<a class=\"squiffy-link link-section\" data-section=\"firstsight\" role=\"link\" tabindex=\"0\">DEV cut to fainting</a>\n\n//<a class=\"squiffy-link link-section\" data-section=\"closer look\" role=\"link\" tabindex=\"0\">DEV cut to closerlook</a>\n\n//<a class=\"squiffy-link link-section\" data-section=\"Leave the house.\" role=\"link\" tabindex=\"0\">DEV cut to leave the house</a>-->",
'js': function() {
static = new Audio();
cheery = new Audio();
creepy = new Audio();
document.body.className="introClass";
},
'passages': {
},
},
'begin.': {
'clear': true,
'text': "<p><img src=\"images/Snow.png\" class=\"floatingsnow\" style=\"width:10%; animation-delay: 1s;\"/>\n<img src=\"images/Snow.png\" class=\"floatingsnow\" style=\"width:10%; animation-delay: 5s;\"/>\n<img src=\"images/Snow.png\" class=\"floatingsnow\" style=\"width:15%; animation-delay: 8s;\"/>\n<img src=\"images/Snow.png\" class=\"floatingsnow\" style=\"width:12%; animation-delay: 12s;\"/></p>\n<p>It's a snowy November evening. You were watching TV after dinner (as per usual) and you fell asleep on the couch. </p>\n<p>Again.</p>\n<p>{sequence:Zzz.:Oh, come now, when's the last time you even made your bed?:You don't even have a pillow!:To be honest, I'm not very impressed with you right now.:<a class=\"squiffy-link link-section\" data-section=\"waking up\" role=\"link\" tabindex=\"0\">I mean, doesn't your back hurt?</a>}</p>",
'js': function() {
creepy.src = "creepy.mp3";
creepy.load();
creepy.play();
creepy.loop = true;
set ("creepy",creepy);
},
'passages': {
},
},
'waking up': {
'text': "<p>Ahem...</p>\n<p>Right, well, your back is killing you when you wake up. You open your eyes again and when you glance at the clock, you see that it's around 3AM. </p>\n<p>The glow of the TV has painted the room in blues and greys. It's like it has sucked all of the warmth out of the world.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"Get off the couch\" role=\"link\" tabindex=\"0\">Get off the couch</a>\n <br /><br />\n<a class=\"squiffy-link link-section\" data-section=\"Shut your eyes again\" role=\"link\" tabindex=\"0\">Shut your eyes again</a></p>",
'js': function() {
document.body.className = 'dim';
},
'passages': {
},
},
'Get off the couch': {
'text': "<p>You slowly stand up, groaning as the kinks in your back creak their way out.</p>\n<p>You start to walk towards the kitchen to get some water. </p>\n<p><div class=\"narrator\">(of course, you didn't say you wanted to get some water, but you're probably thirsty)</div>\n<br />\n<a class=\"squiffy-link link-section\" data-section=\"I could use some water.\" role=\"link\" tabindex=\"0\">I could use some water.</a></p>",
'passages': {
},
},
'I could use some water.': {
'text': "<p>But <a class=\"squiffy-link link-section\" data-section=\"TVintro\" role=\"link\" tabindex=\"0\">before</a> you get too far...</p>",
'passages': {
},
},
'Shut your eyes again': {
'text': "<p>You can't really be bothered with things like "getting up" and "leaving the couch," huh? You start to shut your eyes again.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"Zzz.\" role=\"link\" tabindex=\"0\">Zzz.</a></p>",
'passages': {
},
},
'Zzz.': {
'text': "<p>Wow, seriously?</p>\n<p>Okay, fine, you settle back in on your lumpy couch for some more <em>truly restful</em> sleep.\n<br /></p>\n<p><div class=\"narrator\">(hey, fourth-wall-breaking narrative voices get to be sarcastic if we want to be)</div>\n<br /></p>\n<p><a class=\"squiffy-link link-section\" data-section=\"TVintro\" role=\"link\" tabindex=\"0\">And then you hear something.</a></p>",
'passages': {
},
},
'TVintro': {
'clear': true,
'text': "<p>The TV buzzes loudly, and you look to see that static has filled the screen. </p>\n<p>Through the static, a voice wavers...</p>\n<div class=\"badguy\">Hello in there.</div>\n\n<p><br /></p>\n<p><a class=\"squiffy-link link-section\" data-section=\"wtf\" role=\"link\" tabindex=\"0\">"What in the hell?"</a>\n<br /><br />\n<a class=\"squiffy-link link-section\" data-section=\"hello\" role=\"link\" tabindex=\"0\">"Who are you, and what are you doing in my..."</a></p>",
'js': function() {
creepy.pause();
static.src = "static.wav";
static.load();
static.play();
static.volume = .1;
set ("static",static);
},
'passages': {
},
},
'wtf': {
'text': "<div class=\"badguy\">Technically not <em>in</em> hell... at least not right now. Moreso in your television, aren't I?</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"...\" role=\"link\" tabindex=\"0\">...</a></p>",
'passages': {
},
},
'hello': {
'text': "<div class=\"badguy\">Television, yes, and aren't <em>we</em> playing it cool as a cucumber?</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"...\" role=\"link\" tabindex=\"0\">...</a></p>",
'passages': {
},
},
'...': {
'text': "<div class=\"badguy\">We have much to discuss. Please, come closer.</div>\n\n<p>The static wavers for a moment, and through the static you can just make out a human-like shape blending into the darkest greys and blacks.</p>\n<p>You start to find this wavery voice pretty annoying, frankly.</p>\n<p>...and also, mildly terrifying?</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"closerTV\" role=\"link\" tabindex=\"0\">Move closer to the television.</a></p>\n<p><a class=\"squiffy-link link-section\" data-section=\"leaveLR\" role=\"link\" tabindex=\"0\">You're right, I don't like this. I'm going to leave.</a></p>",
'passages': {
},
},
'closerTV': {
'text': "<div class=\"narrator\">interesting choice.</div>\n\n<p>You start to walk towards the television; its pulsing glow is magnetic.</p>\n<p>You gently place your fingertips on the screen, <a class=\"squiffy-link link-section\" data-section=\"titlescreen\" role=\"link\" tabindex=\"0\">and</a></p>",
'passages': {
},
},
'leaveLR': {
'text': "<div class=\"narrator\">yeahhh, that's not going to work, though</div>\n\n<p>When you try to leave, you make it a couple of steps towards the <a class=\"squiffy-link link-section\" data-section=\"titlescreen\" role=\"link\" tabindex=\"0\">door...</a></p>",
'passages': {
},
},
'titlescreen': {
'clear': true,
'text': "<div style=\"font-size:.7em; opacity:0; font-style:italic; color: white; text-align:center; margin-top:-20px; animation-name:disappear; animation-duration:40s;\">A text "adventure" by @kristinalustig for Ludum Dare 43.</div>\n<br />\n\n<div id=\"blammonext\"><a class=\"squiffy-link link-section\" data-section=\"Actually Begin.\" role=\"link\" tabindex=\"0\">Actually Begin.</a></div>",
'js': function() {
document.getElementById("pageheader").className="blammo";
document.body.className="blammobody";
},
'passages': {
},
},
'Actually Begin.': {
'text': "<p>You wake up nice and snuggly in your bed. When you stand up, you feel well-rested, too!</p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"thatsgreat\" role=\"link\" tabindex=\"0\">That's... great?</a>\n<br/><br/>\n<a class=\"squiffy-link link-passage\" data-passage=\"thatsgreat\" role=\"link\" tabindex=\"0\">Gee, I really do love mornings!</a></p>",
'js': function() {
document.body.className="main-bg";
cheery.src = "audioCheery.mp3";
cheery.load();
cheery.play();
cheery.loop = true;
},
'passages': {
'thatsgreat': {
'text': "<p>Yeah, you feel pretty good about life right now. </p>\n<p>For a second, your mind catches on a bit of a strange memory... a moment, perhaps.</p>\n<p>And just as quickly, the thought flutters away. The winter sun streams through your bedroom window.</p>\n<p>What shall you do today?!</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"work\" role=\"link\" tabindex=\"0\">I'll probably just go to work.</a>\n<br />\n<br />\n<a class=\"squiffy-link link-section\" data-section=\"bs\" role=\"link\" tabindex=\"0\">I'll probably just go perform a quick ritualistic blood sacrifice.</a></p>",
},
},
},
'work': {
'clear': true,
'text': "<p><img src=\"images/coverOne.png\" class=\"imageIntro\" /></p>\n<p>What an idea!</p>\n<p>And will you be cycling or walking there?</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"headin\" role=\"link\" tabindex=\"0\">Cycling!</a>\n<br/><br/>\n<a class=\"squiffy-link link-section\" data-section=\"headin\" role=\"link\" tabindex=\"0\">Walking!</a></p>",
'passages': {
},
},
'bs': {
'text': "<p>Uh... hm. I'm going to pretend you didn't suggest that.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"work\" role=\"link\" tabindex=\"0\">I'll probably just go to work.</a></p>",
'passages': {
},
},
'headin': {
'text': "<p>Excellent choice. You head on into work and get there on time.</p>\n<div class=\"narrator\">go you!</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"Do some work.\" role=\"link\" tabindex=\"0\">Do some work.</a></p>",
'passages': {
},
},
'Do some work.': {
'text': "<p>beep boop.</p>\n<p>beep beep boop.</p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"more1\" role=\"link\" tabindex=\"0\">Do some more work.</a></p>",
'passages': {
'more1': {
'text': "<p><em>printer noise</em></p>\n<p><em>printer noise</em></p>\n<p><em>stapler noise</em></p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"more2\" role=\"link\" tabindex=\"0\">Do some more work.</a></p>",
},
'more2': {
'text': "<p>Uh...</p>\n<p><em>coffee maker noise</em></p>\n<p><em>low hum of office noise</em></p>\n<div class=\"narrator\">god, this is boring</div>\n\n<p><a class=\"squiffy-link link-passage\" data-passage=\"more3\" role=\"link\" tabindex=\"0\">do some more work</a></p>",
},
'more3': {
'text': "<p>Alright, it's time to head home.</p>\n<p>Looks like it's raining outside. Which would you rather do?</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"Walk\" role=\"link\" tabindex=\"0\">Walk</a>\n<br /><br />\n<a class=\"squiffy-link link-section\" data-section=\"Take the bus\" role=\"link\" tabindex=\"0\">Take the bus</a></p>",
},
},
},
'Walk': {
'text': "<p>Odd choice, but alright. </p>\n<p>You bid farewell to your coworkers and head out.</p>\n<p>As you're walking down the street, you see a <a class=\"squiffy-link link-section\" data-section=\"firstsight\" role=\"link\" tabindex=\"0\">man</a> unlocking his front door.</p>",
'passages': {
},
},
'Take the bus': {
'text': "<p>Makes sense.</p>\n<p>You bid farewell to your coworkers and head out.</p>\n<p>You get on the bus uneventfully, and get off at your stop.</p>\n<p>When you step off the bus, you see a <a class=\"squiffy-link link-section\" data-section=\"firstsight\" role=\"link\" tabindex=\"0\">man</a> unlocking his front door.</p>",
'passages': {
},
},
'firstsight': {
'clear': true,
'text': "<p><img src=\"images/coverPartTwo.png\" class=\"imageIntro\" /></p>\n<p>You're confused, at first. Then you start...</p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"f1\" role=\"link\" tabindex=\"0\">...to</a></p>",
'js': function() {
cheery.pause();
},
'passages': {
'f1': {
'text': "<p><a class=\"squiffy-link link-passage\" data-passage=\"f2\" role=\"link\" tabindex=\"0\">...feel</a></p>",
},
'f2': {
'text': "<div id=\"fainting-dizzy\">...a bit dizzy.</div>\n<br /><br />\n\n<div id=\"fainting-next\"><a class=\"squiffy-link link-section\" data-section=\"Continue\" role=\"link\" tabindex=\"0\">Continue</a></div>",
'js': function() {
document.body.className="fainting-bg";
},
},
},
},
'Continue': {
'text': "<div style=\"color:white; line-height:1.5em;\">\n\n<p>You come to.<br/><br/></p>\n<p>Your head feels like a rusty garbage can, and when you lift your hand up to touch, it feels hot and wet.\n<br/><br/>\n"Hey, careful, don't touch! I'm trying to clean it." You hear a man's voice.\n<br/><br/>\n"What happened? Do you faint like that a lot?" he asks. He sounds deeply concerned. </div>\n<br/><br/>\n<a class=\"squiffy-link link-section\" data-section=\"niceroute\" role=\"link\" tabindex=\"0\">"Hey, thank you for helping me."</a>\n<br /><br />\n<a class=\"squiffy-link link-section\" data-section=\"meanroute\" role=\"link\" tabindex=\"0\">"What are you doing? Am I in your house?"</a>\n<br /><br />\n<a class=\"squiffy-link link-section\" data-section=\"confusedroute\" role=\"link\" tabindex=\"0\">"What even happened? Where am I?"</a></p>",
'passages': {
},
},
'niceroute': {
'clear': true,
'text': "<p>You thank him.</p>\n<p>You squint open your eyes and make out the figure of the man you remember seeing right before you passed out.</p>\n<p>"Don't even mention it! I saw you fall as I was coming into my house, so I brought you here to give you some ice and clean out that scrape."</p>\n<p>You get a bit of a <a class=\"squiffy-link link-section\" data-section=\"closer look\" role=\"link\" tabindex=\"0\">closer look</a> at him.</p>",
'js': function() {
document.body.className="main-bg";
},
'passages': {
},
},
'meanroute': {
'clear': true,
'text': "<p>You squint open your eyes and make out the figure of the man you remember seeing right before you passed out.</p>\n<p>You sit up, worried, and start questioning him. He looks taken aback.</p>\n<p>"I mean, I saw you fall... I was just trying to help! Yes, you're in my house!"</p>\n<p>You get a bit of a <a class=\"squiffy-link link-section\" data-section=\"closer look\" role=\"link\" tabindex=\"0\">closer look</a> at him.</p>",
'js': function() {
document.body.className="main-bg";
},
'passages': {
},
},
'confusedroute': {
'clear': true,
'text': "<p>You're confused.</p>\n<p>You squint open your eyes and make out the figure of the man you remember seeing right before you passed out.</p>\n<p>"Well, I saw you hit the ground pretty hard, so I came and brought you a few steps to my house to clean you up."</p>\n<p>You get a bit of a <a class=\"squiffy-link link-section\" data-section=\"closer look\" role=\"link\" tabindex=\"0\">closer look</a> at him.</p>",
'js': function() {
document.body.className="main-bg";
},
'passages': {
},
},
'closer look': {
'text': "<p>You sit up a bit and squint at him even more.</p>\n<p>At first glance, he seems pretty average. Balding, brown hair, wire-rimmed glasses. Wearing khakis and a tucked-in shirt with a electronics store logo on it.</p>\n<p>But there's something... somehow... not quite right about him. You're not sure, but then you <em>are</em>. Something's not right.</p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"Look around the room.\" role=\"link\" tabindex=\"0\">Look around the room.</a>\n<br /><br />\n<a class=\"squiffy-link link-passage\" data-passage=\"Ask for some water.\" role=\"link\" tabindex=\"0\">Ask for some water.</a>\n<br /><br />\n<a class=\"squiffy-link link-passage\" data-passage=\"Ask for his name.\" role=\"link\" tabindex=\"0\">Ask for his name.</a></p>",
'passages': {
'Look around the room.': {
'text': "<p>You start to take in your surroundings. You're in a pretty nondescript living room. Saggy couch, particle board coffee table, television with some video games stacked below.</p>\n<p><a class=\"squiffy-link link-passage\" data-passage=\"Turn on the TV.\" role=\"link\" tabindex=\"0\">Turn on the TV.</a></p>",
},
'Turn on the TV.': {
'text': "<p>You reach over for the remote.</p>\n<p>"Oh, ah, well. I suppose if you need to rest and recover for a bit?"</p>\n<p>You turn on the TV. It's showing some sort of Japanese cartoon.</p>\n<div class=\"narrator\">is now really the time?</div>",
},
'Ask for some water.': {
'text': "<p>You ask the man for some water.</p>\n<p>"Ah, of course! So sorry, give me a moment." He scurries off to the kitcken.</p>\n<p>He seems nervous.</p>\n<p>You feel uneasy.</p>\n<p>He comes back in a moment with a bottle of water. You unscrew the cap and take a sip.</p>",
},
'Ask for his name.': {
'text': "<p>"Hey, what's..." Your voice is hoarse and it catches a bit in your throat.</p>\n<p>You try again. "What's your name?"</p>\n<p>He looks startled. "Jake. It's Jake, my name is Jake." </p>\n<div class=\"narrator\">why in the world is he <em>so</em> nervous?</div>\n\n\n\n<p><a class=\"squiffy-link link-section\" data-section=\"memory\" role=\"link\" tabindex=\"0\">Hang on a second...</a></p>",
},
},
},
'memory': {
'clear': true,
'text': "<p>Suddenly, your memory flashes.</p>\n<p>{sequence:Your couch, cast in fuzzy grey.:A commanding, sinister voice.:A snowflake falling on the tip of your nose.:<a class=\"squiffy-link link-section\" data-section=\"Blood running down a drain.\" role=\"link\" tabindex=\"0\">Blood running down a drain.</a>}</p>",
'js': function() {
document.body.className="memoryflashes";
},
'passages': {
},
},
'Blood running down a drain.': {
'text': "<p>You know what you have to do.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"I do.\" role=\"link\" tabindex=\"0\">I do.</a></p>",
'js': function() {
document.body.className="";
},
'passages': {
},
},
'I do.': {
'clear': true,
'text': "<p><img src=\"images/coverPart3.png\" class=\"imageIntro\" /></p>\n<p>You look over at Jake. He's starting to sweat a bit: you see small beads forming at his temples.</p>\n<p>"W... what's your name?"</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"doesitmatter\" role=\"link\" tabindex=\"0\">"Does it matter?"</a></p>",
'passages': {
},
},
'doesitmatter': {
'text': "<p>You deflect and he blinks. His eyes flicker to the door.</p>\n<p>"I guess you're right? Uh... do you want some water?"</p>\n<p><div class=\"narrator\">um, hey there? What's the deal? why were you so rude to him just now?</div>\n<br/><br/>\n<a class=\"squiffy-link link-section\" data-section=\"gogetwater\" role=\"link\" tabindex=\"0\">"I can get it myself."</a></p>",
'passages': {
},
},
'gogetwater': {
'text': "<p>You pick up the glass and start walking towards the kitchen.</p>\n<p>You feel a little bit like your limbs are motorized.</p>\n<p>Like you don't <em>really</em> want to go get yourself some water.</p>\n<p>But you do.\n<br/><br/>\n<a class=\"squiffy-link link-section\" data-section=\"knife\" role=\"link\" tabindex=\"0\">Grab knife from knife block</a></p>",
'passages': {
},
},
'knife': {
'text': "<p><br/><br/></p>\n<div class=\"narrator\">okay, very funny. you can put that down now.</div>\n\n<p>You put the glass in the sink.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"waterlie\" role=\"link\" tabindex=\"0\">"Hey, Jake? There's something wrong with the water."</a></p>",
'passages': {
},
},
'waterlie': {
'text': "<p>Jake hears you call and walks into the kitchen.</p>\n<p>"Oh, the faucet is a bit touchy, if you just"</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"Grab Jake.\" role=\"link\" tabindex=\"0\">Grab Jake.</a></p>\n<div class=\"narrator\">oh my goodness, what are you DOING? If you would just...</div>",
'passages': {
},
},
'Grab Jake.': {
'text': "<p>You grab Jake as he walks in.</p>\n<p>With a smooth motion, before he can react, you plunge the knife into his stomach.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"Leave the house.\" role=\"link\" tabindex=\"0\">Leave the house.</a></p>",
'passages': {
},
},
'Leave the house.': {
'text': "<p>You leave the kitchen and head back into the living room.</p>\n<p>As you pass the <a class=\"squiffy-link link-section\" data-section=\"TVoutro\" role=\"link\" tabindex=\"0\">TV,</a></p>",
'passages': {
},
},
'TVoutro': {
'clear': true,
'text': "<div class=\"badguy\">Well done.</div>\n\n<p>You shake your head, trying to clear out some of the fog.</p>\n<p><a class=\"squiffy-link link-section\" data-section=\"brainfog\" role=\"link\" tabindex=\"0\">"What are you talking about?"</a></p>",
'js': function() {
document.body.className="dim";
static.src = "static.wav";
static.load();
static.play();
static.volume = .1;
},
'passages': {
},
},
'brainfog': {
'text': "<div class=\"badguy\">Don't worry. We have time. </div>\n\n<div class=\"badguy\">And, well.</div>\n\n<div class=\"narrator\">oh no...</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"um\" role=\"link\" tabindex=\"0\">...</a></p>",
'passages': {
},
},
'um': {
'clear': true,
'text': "<div class=\"badguy\">You have many more sacrifices to make.</div>\n\n<p>The TV blinks off.</p>\n<div class=\"narrator\">...what have you done?</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"end\" role=\"link\" tabindex=\"0\">end</a></p>",
'js': function() {
static.pause();
creepy.src = "creepy.mp3";
creepy.load();
creepy.play();
creepy.loop = true;
},
'passages': {
},
},
'end': {
'clear': true,
'text': "<div class=\"badguy\" style=\"font-size:3em; text-align:center; width=100%;\">\n<div>Watching</div></div>\n\n<p><br/><br/><br/><br/>\nWords, code, music, sfx, and art by <a href=\"http://www.twitter.com/kristinalustig\">@kristinalustig</a>.</p>\n<p>Made with <a href=\"http://textadventures.co.uk\">squiffy</a>.</p>\n<p>Made for <a href=\"http://ldjam.com\">Ludum Dare 43</a>.</p>\n<p>Thanks for playing.</p>\n<div class=\"narrator\">ugh, thanks for nothing</div>\n\n<p><a class=\"squiffy-link link-section\" data-section=\"Play again?\" role=\"link\" tabindex=\"0\">Play again?</a></p>",
'js': function() {
},
'passages': {
},
},
'Play again?': {
'text': "<p>Weird. Well, <a class=\"squiffy-link link-section\" data-section=\"Beginning\" role=\"link\" tabindex=\"0\">go ahead...</a></p>",
'js': function() {
creepy.pause();
},
'passages': {
},
},
}
})();