
Nice to have you here.
Behind the Scenes: Prospero
2015-09-17 · by Bruno Dias
tagged Tutorials
“Prospero”, which sub-Q published earlier this week, was written using a relatively new tool called Raconteur. Raconteur is a library of tools that wraps and extends Undum, an engine for writing choice-based and cybertext interactive fiction using plain JavaScript. Raconteur supplies a toolchain and CoffeeScript-targeted API for Undum, which is meant to hugely accelerate the process of writing Undum stories.
For a while now, Raconteur has lacked a full code example. “Prospero” is just about the right length for it, and sub-Q has graciously agreed to publish the full source code. The story file for “Prospero” is about 871 lines long and contains all of the unique story text and logic.
You can find out more about Raconteur, including documentation and tutorials to help you start writing with it, on the Raconteur website.
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 |
# " There comes Poe, with his Raven, like Barnaby Rudge, # Three-fifths of him genius, and two-fifths sheer fudge. " # # -- James Russel Lowe, A Fable for Critics # # The story source code for Prospero begins here. (C) Bruno Dias 2015. # Originally published by Sub-Q magazine (http://sub-q.com/) # # This source code is distributed as a code example for educational purposes. # No permission is granted to redistribute or rebuild the story from this # source code. # ---------------------------------------------------------------------------- # 0 -- Front Matter # Require the libraries we rely on. situation = require('raconteur') undum = require('undum-commonjs') oneOf = require('raconteur/lib/oneOf.js') elements = require('raconteur/lib/elements.js') qualities = require('raconteur/lib/qualities.js') a = elements.a span = elements.span img = elements.img # IFID and game version -- Required by Undum undum.game.id = "0a7f01b6-b435-483c-8874-bdbee2683255" # UUID undum.game.version = "source-distribution" # ---------------------------------------------------------------------------- # 1 -- Preamble # Helper functions # Cycles through an array's contents Array.prototype.cycle = () -> return this[1..].concat(this[0]) # Checks if a situation has been visited by the player seen = (situation) -> Boolean undum.game.situations[situation].visited # Typographical shorthand # An alias for setting up an "aside" link # (that creates a parenthetical when clicked, usually) aside = (word) -> ref = "#{word}-aside" inner = a(word).once().inserter(ref).toString() span(inner).id(ref) # An alias for setting up a link to another situation, with the correct # element class. segue = (content, ref) -> a(content).class('segue').ref(ref) # An object to hold reusable templates. type = ending: '<h2 class="ending">an ending</h2>' # ---------------------------------------------------------------------------- # 2 -- Game content # 2.0 -- Prologue situation 'start', content: () -> prospero = span(a('Prospero').inserter('prospero').once().toString()).id('prospero') """ The "Red Death" had long devastated the country. No pestilence had ever been so fatal, or so hideous. Blood was its Avatar and its seal -- the redness and horror of blood. There were sharp pains, and sudden dizziness, and then profuse bleeding at the pores, with dissolution. The scarlet stains upon the body and especially upon the face of the victim, were the pest-ban which shut them out from the aid and from the sympathy of their neighbors. The whole seizure, progress and termination of the disease, were the incidents of half an hour. When Prince #{prospero} found his dominions half depopulated, he summoned to his presence a thousand hale and light-hearted friends from among the people of his court, and with these retired to the deep seclusion of one of his summer #{segue('retreats', 'retreats')}. """ writers: prospero: " (happy and dauntless and sagacious)" situation 'retreats', content: """ # Prospero ## Adapted by Bruno Dias from the short story by Edgar Allan Poe """ choices: ['cars'] situation 'cars', optionText: 'Continue' content: """ It was an extensive and magnificent structure, a modernist design not unlike the carved *béton brut* that had sprouted all over Europe. An angular steel fence surrounded it. Courtiers had abandoned their cars all along the gravel paths of the courtyard, gleaming silver and black machines defying the rust each misty Savoyard morning. Their keys had been collected and buried behind the enormous house, leaving no means of egress to the sudden impulses of despair or frenzy from within. Its exterior had #{a('suffered').once().writer('suffered')} the passage of time. Of all the #{aside('cars')}, one #{segue('stood out', 'red-car')}. """ writers: 'cars-aside': " (stately Hässels from Prussia, sinuous Verbeeks from New Amsterdam, sharklike Bulettes from Brittany)" 'suffered': """ In months of grinding, desperate seclusion, no servant had stepped outside the house. The panes of safety glass -- surrounding the house like scales -- had accrued a layer of dark grime from the wind and rain. The garden was an overgrown, matted ruin. Native weeds thrived among the corpses of neglected foreign flowers. And not far from the door was a pile of ashes -- remains of clothes and surgical masks suspected of carrying disease. """ situation 'red-car', content: """ It was a ruddy, beautiful *coupé* -- a Carrièr Matador, from Toulouse. Painted a color too dark to be cherry red. Fresh gouges in the gravel behind it, mud on its rims. She stepped out of the car, not bothering to lock it. She made her way, through undisturbed gravel, to the #{segue 'trunk', 'open-trunk'}. """ situation 'open-trunk', # Note how we can attach arbitrary properties to situation objects books: ['Relics', 'Mementos', 'Evidence'] content: () -> mask = a('masque').once().writer('mask') novels = a('novels').once().writer('novels') """ Inside the trunk were a stack of paperback #{novels} and a curiously made #{mask}. """ writers: novels: () -> finger = a('finger').once().replacer('finger-inserter') here = span('.').id('finger-inserter') relics = span( a(this.books[0]) .replacer('relic-book') .toString()) .id('relic-book') """ They had been with her as she drove through the back country of Savoy, taken from abandoned bookstores and gas stations. #{relics} of the desert she left behind her. She ran one #{finger} through the the pile, reading the titles#{here} """ 'finger-inserter': " -- Short stories collected from pulp authors; Chamber's The King in Yellow; a clandestine copy of the banned, pseudonymous Return of the Worm; louche Italian romances for all kinds of underserved audiences..." mask: """ The masque was red, to match her outfit, and cleverly constructed for effect. The top resembled those delicate porcelain features, the shaded eyes, of a Venetian *columbina*. But this one had a mouth covering in the form of a silken, draping scarf, meant to be pulled down to reveal the full #{segue('visage', 'visage')} of the masque. """ 'relic-book': () -> this.books = this.books.cycle() # `this` is the situation object itself span( a(this.books[0]).replacer('relic-book').toString() ).id('relic-book').toString() situation 'visage', content: """ She tentatively slid a finger behind the masque's silk covering, as though to check that what had always been underneath it remained. In this, she was interrupted by the #{segue('chiming', 'chiming')} of the great clock within the #{segue('mansion', 'mansion')}. She had arrived just in time. """ situation 'chiming', content: """ Somewhere deep inside the Prince's apartments was an enormous, grotesque clock. Made of ebony and sharp angles -- a modernist retelling of a Gothic original the Prince's ancestors had neglected in a castle elsewhere. The Prince had it attached to the metal bones of the mansion. On the hour, the whole building would reverberate along with its chiming, phasing the guests, halting the music, shaking the floor. Its tolling, just now, signaled the start of the #{segue 'ball', 'ball'}. """ situation 'mansion', content: """ The mansion had been erected out of glass, steel, tropical woods from the domains of distant cousins; unlike the ostentatious glass houses of his peers, the retreat had been built wholly out of sheer, broken angles; so that the glass could not provide a clear sight-line through the house at all -- instead of an airy rectangle, it was a steel snake hiding in its own coils. It was a small palace and a world unto itself; and presently, it all shook to the ringing of the clock, signaling the start of the #{segue 'ball', 'ball'}. """ situation 'ball', content: """ Within the mansion, the Prince had gathered perhaps two hundred guests and nearly as many servants. The summer home, a small palace, was amply provisioned. A remote stand of cypress surrounded it. The world outside could care for itself, and in the meantime, it was folly to grieve -- or to think. To that end, the Prince had supplied all appliances of pleasure: There were dancers, there were musicians, there was Beauty, there was wine. As all signals traveling through the Prince's *aether* ceased to carry any joy for him, the servants had hidden away all the radios and television sets, cutting cords to #{segue 'silence', 'ball-continue'} them completely; so that the guests, finally, were left to the labors of pleasure and life in seclusion. """ situation 'ball-continue', content: """ When the Prince's collection of #{aside 'films'} ran out, the lights were turned on and the servants were made to play in blackbox comedies, their scripts supplied by dilettante guests. When even that entertainment ran thin, the Prince announced a night of extreme revel, a masquerade ball, where the guests and servants would mingle, shed their identities, forget. Wine, and song, and whatever earthly pleasures remained, would flow freely. She #{segue 'donned her masque', 'put-on-mask'}, having arrived just in time. """ writers: 'films-aside': " (from bolshevik *kinopoesiya* to staid adaptations of the *commedia dell'arte*)" situation 'put-on-mask', optionText: "She put on her masque, and made her way to the ball." content: """ The ball had been arranged within a sequence of seven apartments joined together -- a grand suite. In other mansions and palaces, those suites open widely, so that one can see clearly through all of their spaces, their sliding doors receding almost entirely into the walls. However, this suite was crooked, each chamber at a sharp angle from the next, so that the guests could see only one room at a time. Outside, through the great panes of safety glass, was darkness. The seven apartments were each one decorated in a particular color and style, a neon mirage of a different place and time. The first one was blue, and everything in it had some tint of blue, matched by the bright blue lights overhead. The second chamber was purple, from the carpet to the ceiling. The third chamber was green throughout; the fourth, orange; the fifth, white; the sixth, violet. And at the edge of the great house was the last apartment, itself decorated wholly in #{segue 'black', 'black'}. """ situation 'black', content: """ The black chamber was closely shrouded in black velvet tapestries that hung all over the ceiling and down the walls, falling in heavy folds upon a carpet of the same material and hue. BUt in this chamber only, the color of the neon lights failed to correspond to the decorations. The tubes here were scarlet -- a deep blood color. In the black chamber, the effect of the neon light that dappled across the dark hangings was ghastly in the extreme, and produced so wild a look upon the countenances of those who entered, that there were few guests bold enough to set foot within the chamber at all. No dancing happened within -- only furtive whispers, and abortive trysts cut short by the eeriness of the chambers. She #{segue 'followed the procession of revelers', 'ball-begin'}. """ situation 'ball-begin', content: """ Her costume was a draping, heavy robe, covering her form in red. Topped with the strange masque, she was an imposing figure, wearing a color that horror had forbidden, shocking those few guests who bothered to notice her presence at all. She had walked slowly through the revelers, noting how they clung to the western end of the grand suite, how they avoided the other end with its black velvet room. She moved between them, unnoticed. And as the ninth hour approached, she stopped at the halfway point, the orange chamber, where the warm neon overhead suggested some distant tropical sunset. """ classes: ['orange'] choices: ['ninth-third', 'ninth-fifth'] # 2.1 -- The Ball ### From here on out, situation ids take the form "bell-room", eg "ninth-fifth" means the fifth (white) room, at the tolling of the ninth bell. ### # 2.1.0 -- Ninth bell # The descriptions for these chambers shows up the first time they're visited, # which can happen in different situations. So we set up an adhoc object to # hold them, as well as the connecting paragraph about the bell tolling. chambers = green: """ She stepped into the green chamber, and found it covered in leafy arabesques that recalled the cypress stand outside. Glistening vinyl ferns sprouted from the walls, their artificiality only heightened by the color of the lights. """ white: """ She took stock of the white chamber: Lit with a staid white light, this room was made to resemble a sarcastic mockery of a church undercroft, complete with arched niches in the walls holding sconces with flickering candles. The plastic skulls that would have completed the effect, however, had been taken away by the servants -- the Prince wanted no *memento mori*. """ toll: """ At the far end of the suite, in the black chamber, was the clock. Its tolling reverberated violently through the entire house, with a sound so strange and musical it compelled the musicians to stop and harken to its sound; and here the dancers, too, would cease their revolutions around one another, listening to the brazen vibrations of the hour. But just as it had come, it would fade away, the shaking of the walls the sound of mere moments, soon replaced by the revived noises of revelry and joy. The striking of the tenth hour approached. """ situation 'ninth-third', crowdReactions: [ "She noted sadly the interrupted futures of the young ones in the crowd." "She cataloged their lives with ennui, seeing the common arc of their fates." "In them, she saw only a mass of indistinct humanity." ] # Once again we attach a list of possible phrases to the situation object content: () -> crowd = a('crowd').once().writer('crowd') """ #{chambers.green} A woman stood uncomfortably #{segue 'distant', 'save-woman'} from the party, leaning furtively against the wall, her lithe body vanishing into the gaudy plastic bush. She did not seem to fit the #{crowd} of courtly hangers-on around her. """ choices: ['tenth-second', 'tenth-fourth'] optionText: 'She retreated to the green chamber.' classes: ['green'] writers: crowd: () -> """ The green room seemed the most agreeable to the guests. A circle of courtiers orbited around some of the Prince's favored friends: Masked actors, musicians, and a brooding novelist or two. They were stared at by industry barons and literal barons, investment bankers, lesser sons of princely families. From the middle of the crowd, camera flashes would sometimes emerge, casting their masks in stark light for a moment. #{this.writers['crowd-react'].call(this)} """ 'crowd-react': () -> this.crowdReactions = this.crowdReactions.cycle() span( a(this.crowdReactions[0]).replacer('crowd-react').toString() ).id('crowd-react').toString() situation 'save-woman', content: """ She saw a small woman, raven-haired and short, wearing a golden tragedy masque and a black cocktail dress that fit her poorly. The stranger in red approached her, noting that the woman was neither servant nor courtier. In her borrowed dress, she tried to mingle, but too awkwardly, clutching an untouched glass of wine. A party crasher, perhaps? Or a survivor from a nearby village, taken in by the Prince? The stranger did not need to know. """ choices: ['give-woman-key', 'tenth-second', 'tenth-fourth'] extendSection: true situation 'give-woman-key', optionText: "She gave her the keys." content: """ From the folds of her robe she produced her keys, which she pressed into the hand of the young woman. "Leave." There was no argument. Behind her tragedy masque, she recognized who spoke to her. """ after: (character) -> character.sandbox.hasKeys = false choices: ['tenth-second', 'tenth-fourth'] extendSection: true situation 'ninth-fifth', adverbs: ['soberly', 'longingly', 'distractedly', 'curiously'] # Situations can also encapsulate arbitrary functions. This one wraps an # adverb from the list in the right tags to generate a link; it's used # both in the main content and by the related writer. adverbise: () -> this.adverbs = this.adverbs.cycle() span( a(this.adverbs[0]).replacer('wine-adverb').toString() ).id('wine-adverb') content: () -> """ #{chambers.white} Wine flowed from the white chamber, a play on communion. She glanced #{this.adverbise()} at a glass of dark red liquid left abandoned on an arched sill. #{chambers.toll} """ choices: ['tenth-fourth', 'tenth-sixth'] optionText: 'She advanced to the white chamber.' classes: ['white'] writers: 'wine-adverb': () -> this.adverbise().toString() # Tenth bell bells = eleventh: "The striking of the eleventh hour approached." musicians: """ When the hourly shaking of the house ceased, and the great clock had rung ten times, she could hear a distant song: Musicians in another room, picking up on the very note where they stopped, their song interrupted by the clock. """ situation 'tenth-second', musicReactions: [ 'swayed along to the rhythm' 'listened with distant interest' 'did not harken to the sound' ] musicReact: () -> this.musicReactions = this.musicReactions.cycle() span( a(this.musicReactions[0]).replacer('music-react').toString() ).id('music-react') content: () -> acted = this.musicReact() musicians = a('musicians').once().writer('musicians') """ The purple room felt hazy, unreal. The walls and floor had been covered in a single, abstract mural, which dancers would unsteadily wobble over in their convolutions. It was hard to discern where the floor ended and the walls began. Here stood the #{musicians}, playing through an interminable medley, the bassist's arm drooping slightly under the weight of the instrument. As the sound of the bells faded, they would pick up on the very note where they had stopped. As she moved unseen through the crowd, she #{acted}. """ writers: musicians: """ They worked their way laboriously through a half-improvised swing, six minutes into a minor key jazz that is only three minutes long. It was wearily joyful, the sound of a band that played nothing but final numbers. #{bells.eleventh} """ 'music-react': () -> this.musicReact().toString() choices: ['eleventh-first', 'eleventh-third'] optionText: 'She moved to the purple chamber' classes: ['purple'] # Since we know the player has already seen the orange chamber # (it's a bottleneck), we don't have to print its description. situation 'tenth-fourth', content: () -> youth = a('youth').once().writer('youth') """ At the tolling of the tenth bell, she walked again around the tight scrum of dancers that spun through the center of the orange room, most too unsteady from wine and #{youth} to fall properly on their steps. #{bells.musicians} """ writers: youth: """ Here was a clique of idle young scions from mercantile houses and their hangers-on, interrupted in their holiday through the Savoyard countryside by the plague that forced them to seek shelter in the house of the Prince, showing up at his doorstep in their fast cars, with their cheap wine and dilettante typewriters. One of them caught her masked #{segue 'eye', 'save-dilettante'}. """ choices: ['eleventh-third', 'eleventh-fifth'] optionText: 'She returned to the orange chamber.' situation 'save-dilettante', content: """ He had known grief beyond his years, which he hid with sarcasm and a little too much wine. He and his two friends fancied themselves writers. But their typewriters had been silent for a while. """ choices: ['give-dilettante-key', 'eleventh-third', 'eleventh-fifth'] extendSection: true # Normally, the output of each situation is put into its own section, allowing # it to be styled accordingly (in Prospero, by giving it the proper colour # background). But here we set the `extendSection` property to `true`, so that # it will instead write into the existing section, so that the background will # extend over the new text. situation 'give-dilettante-key', optionText: 'She gave him her keys.' canChoose: (character) -> character.sandbox.hasKeys content: """ She startled him, drawing nervous laughter from the youth. She pressed a car key into the shaking palm of his hand. "Leave." She knew he would gather his friends. That he would know which one of the cars parked outside to take. Three souls made it out alive that evening. """ after: (character) -> character.sandbox.hasKeys = false choices: ['eleventh-third', 'eleventh-fifth'] extendSection: true; situation 'tenth-sixth', content: () -> secrets = segue 'secrets', 'chamber-secrets' lies = segue 'lies', 'chamber-lies' """ The violet apartment was a prelude for the black chamber. It was filled with mock horror that prefigured what was beyond the black door. The decor, deliberately disturbed like a crime scene, resembled a horror film, or perhaps a sanitized *giallo*. The walls were covered in foreboding Gothic stonework, rendered in papier-mâché. #{bells.musicians} She stopped for a moment to listen to the whispering of the gossips who retreated from the main body of the fête to find themselves here. Under the glow of the violet light, their whispers carried #{secrets} and #{lies} to one another, more out of habit than necessity. """ optionText: 'She walked into the violet chamber' classes: ['violet'] situation 'chamber-secrets', content: """ The Prince's tastes for the curious and the bizarre had always manifested, in his courtiers, in the form of a secretive and peculiar fear. They still passed on stories of the man's nocturnal activities, of what went on in the black chamber at the edge of the suite. And as she approached them, they dispersed, turning away masked faces. #{bells.eleventh} """ choices: ['eleventh-fifth', 'eleventh-seventh'] extendSection: true situation 'chamber-lies', content: """ Even amidst death, the business of the court went on. The lies they told one another were becoming extravagant in desperation, shifting from hour to hour as furtive news of the calamity outside starkly changed the value of lands and titles. They still discussed the news and events of the day, even though no news had reached the mansion in weeks. There was much talk of an antipope that had already been deposed, of an oil industry merger that had already happened, of war with Lombardy that was pre-empted by the plague. The world outside had moved on in their absence, as it would continue to do. #{bells.eleventh} """ choices: ['eleventh-fifth', 'eleventh-seventh'] extendSection: true # Eleventh bell situation 'eleventh-first', content: () -> prospero = segue 'Prospero', 'prospero' """ Starkly ultramarine, the blue chamber greeted the Prince's guests to his chromatic fantasy. Here huddled the offended ones, the fearful, the religious. Those guests who did not care for the revelry or its accoutrements, who thought the whole affair a small blasphemy. They clung to the exit, caught between politeness and piety. And there, stuck trying to placate them with his silent presence, was #{prospero}. """ optionText: 'She moved into the blue chamber' # We always find Prospero in the last chamber we visit; this variable tracks # where, exactly. after: (character) -> character.sandbox.prosperoAt = 1 classes: ['blue'] # Check if those rooms have been seen before. situation 'eleventh-third', content: () -> guard = a('guard').once().writer('green-chamber-guard') """ #{if not seen('ninth-third') then chambers.green else ''} The green chamber held the food, the night's banquet, carefully measured out from the mansion's provisions. Weary servants had laid it out in faux- pastoral splendor. At each edge of the table, a reminder of the creeping scarcity, stood a #{guard}. And at the edge of his own party, staring at his dwindling food, stood #{segue 'Prospero', 'prospero'}. """ optionText: 'She moved to the green chamber.' writers: 'green-chamber-guard': () -> crest = aside 'crest' weapons = aside 'weapons' """ Liveried in dark turtlenecks and berets bearing Prospero's family #{crest}, the guards were ever-presence and furtive, gaunt, faces hardened from watching the despair of the poor and the lost caught outside the manor's walls. Tonight, they watched the guests, clutched their #{weapons}, and didn't touch the food. """ "crest-aside": " (gold emblazoned with a sable sun)" "weapons-aside": " (something compact and full-auto from Lombardy)" after: (character) -> character.sandbox.prosperoAt = 3 classes: ['green'] situation 'eleventh-fifth', content: () -> # Note how if-then-else statements are expressions, so we can embed them # right into the output text; we need the else clause so it won't just # output `undefined` if the value is false. # Note, too, how this `content` property has to be a function, so that # the `seen` expression will be checked at runtime when the situation # is reached, and not when the situations are being generated. """ #{if not seen('ninth-fifth') then chambers.white else ''} She had seen the path that wine took on its way around the chambers, from the great casket in the white apartment. Guests would timidly sip it or hurriedly down it; servants would disappear with glasses and flasks of it. There was so much of it to go through. And there, all but laying his head beneath the tap, was Prince #{segue 'Prospero', 'prospero'} himself. """ optionText: 'She moved to the white chamber.' after: (character) -> character.sandbox.prosperoAt = 5 classes: ['white'] situation 'eleventh-seventh', content: """ Few dared step into the last, velvet-draped chamber. The effect of the crimson neon distorted the visages of those within into a masque of horror. Those who came -- dared by others, drunkenly stumbling through the curtain -- did not stay long. When she happened upon it, the black chamber was nearly empty. There was only Prince #{segue 'Prospero', 'prospero'} himself, seated on a black velvet and ebony ottoman, caught up in his own dark fantasy. """ optionText: 'She entered the black chamber.' after: (character) -> character.sandbox.prosperoAt = 7 classes: ['black'] situation 'prospero', content: (character, system, from) -> # `switch` statements in CoffeeScript are expressions, too # so we can assign their return value to a variable. Here, we # have a different reaction for Prospero depending on where he # was found, without having four different situations. prosperoGraph = switch from when 'eleventh-first' """ But his staid, pious exterior melted into rage when she saw her, dressed head to toe in crimson. """ when 'eleventh-third' """ But his hungry smile faded away when he saw her, covered head to toe in scarlet. """ when 'eleventh-fifth' """ But he snapped out of his stupor when he saw her, covered head to toe in vermilion. """ else """ But his melancholy turned to anger when he saw her, covered head to toe in red. """ """ Prince Prospero was hale, and strong. He stood too tall for his guests in samite finery, the spitting image of some forgotten Gothic ancestor. He had, for too long, led his guests in their revels. #{prosperoGraph} """ choices: ['prospero-unmask', 'prospero-leave'] extendSection: true; situation 'prospero-unmask', optionText: 'She took off the veil.' content: (character) -> ### The final sequence is a run through the chambers of the suite. The more chambers there are to run through, the longer it is; so we splice into a point determined by where we start. ### chamber = switch character.sandbox.prosperoAt when 1 segue 'purple', 'death-finale-2' when 3 segue 'orange', 'death-finale-4' when 5 segue 'violet', 'death-finale-6' when 7 segue 'black', 'death-finale-7' chamberGraph = if character.sandbox.prosperoAt < 7 "But the masked figure already retreated into the #{chamber} chamber." else "The masked figure stood in the middle of the #{chamber} chamber." """ As the house shook with the striking of midnight, she disposed of the veil that had concealed her masque. And beneath the veil, her masque was made to so closely resemble the visage of a stiffened corpse, daubed and sprinkled delicately with blood, that one could scarcely see anything but mockery of the tragedy that had befallen the Prince's domain. Prospero's face convulsed with disgust, then reddened with anger: "Who dares?" #{chamberGraph} """ situation 'death-finale-2', content: """ Stunned by his momentary hesitation, the Prince #{segue 'chased', 'death-finale-4'} her through the apartments. """ situation 'death-finale-4', content: """ As she moved through them, the assembled crowd parted in mute horror, stepping out of the way of the stalking spectre and the #{segue 'prince', 'death-finale-6'} who stalked her. """ situation 'death-finale-6', content: """ He might have screamed for his guards to seize her, or simply silently cursed at the affront to his #{segue 'authority', 'death-finale-7'}. """ situation 'death-finale-7', before: () -> # If we haven't seen the black background effect yet, then we see it here. if not seen 'eleventh-seventh' then this.classes = ['black'] content: () -> """ #{if seen 'eleventh-seventh' then '' else "She stood in the middle of the black chamber, defying him."} He bore aloft a drawn pistol, and approached her impetuously, to within two or three feet of the spectral figure, when she turned sharply and confronted the Prince. There was a sharp cry -- and the pistol dropped inert upon the sable carpet, upon which, instantly afterward, fell prostrate in death the Prince Prospero. And now was acknowledged the presence of the Red Death. She had come as an uninvited guest. And one by one dropped the revelers in the blood-flecked halls of their revel, and died each in the despairing posture of their fall. And the life of the ebony clock went out with the of the last of the joyful. And the colorful neon lights flickered and expired. And Darkness and Decay and the Red Death held illimitable dominion over all. #{type.ending} """ situation 'prospero-leave', optionText: 'She turned to leave.' canChoose: (character) -> character.sandbox.hasKeys before: (character) -> character.sandbox.leaveMotivation = ['sadness', 'mercy', 'ennui', 'weariness', 'apathy', 'kindness', 'forgiveness'] content: (character) -> """ But to his anger, she could respond only with a sudden #{this.writers.selectmotivation(character)}. Five months hidden in his manse had made of the Prince a ragged man, slightly too thin for his sequined party garb, eyeglasses slightly askew on a wrinkled nose. It had taken her so long to arrive at this man's party that she was no longer sure these were the people she had come to #{segue 'collect', 'leave-collect'}. """ writers: selectmotivation: (character) -> character.sandbox.leaveMotivation = character.sandbox.leaveMotivation.cycle() inner = a(character.sandbox.leaveMotivation[0]) .replacer('selectmotivation') .toString() span(inner).id('selectmotivation').toString() situation 'leave-collect', content: """ She walked through a parting way in the middle of the throng of distraught guests, out of the richly decorated apartments of the Prince who could scarcely muster the strength to #{segue 'follow', 'leave-follow'}. """ situation 'leave-follow', content: """ Her footfalls made no sound as she strode onto the gravel path, tailed by a baffled Prince. He stood, paralyzed, watching as his iron gate was thrown open by crimson-gloved #{segue 'hands', 'leave-hands'}. """ situation 'leave-hands', content: """ From one of his guards, the Prince had at some point reached for a drawn pistol. But he could not lift it against her. The open gates were a sign of black fear to him, a sign of the outside world creeping in on the sanctuary he had built, a sign of death. The ebony clock struck twelve, unheeded by the two figures standing before the great house. Darkness and Decay had arrived ahead of her. And so the Red Death got in her car and drove away. #{type.ending} """ #----------------------------------------------------------------------------- # 3 -- Initialisation Code undum.game.init = (character, system) -> character.sandbox.hasKeys = true # Undum's sandbox can hold arbitrary values inside the `character` object # passed to situation methods. Here, we use it to track whether the player # character has given away her car keys. # When the DOM is ready, get Undum running. window.onload = undum.begin |
