Guest User

Untitled

a guest
Jul 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. /********************
  2. * crispsContest.js *
  3. ********************
  4. *
  5. * The Algorithm is almost in our grasp!
  6. * At long last, we will definitively establish
  7. * that 3SAT is solvable in polynomial time. It's
  8. * been a long, strange journey, but it will all be
  9. * worth it.
  10. *
  11. * You have the red, green, and blue keys. Now you
  12. * just need to figure out how to unlock this thing.
  13. */
  14.  
  15. function startLevel(map) {
  16. map.defineObject('redLock', {
  17. 'symbol': String.fromCharCode(0x2297),
  18. 'color': 'red',
  19. 'impassable': function (player) {
  20. if (player.hasItem('redKey')) {
  21. player.removeItem('redKey');
  22. return false;
  23. } else {
  24. return true;
  25. }
  26. }
  27. });
  28.  
  29. map.defineObject('blueLock', {
  30. 'symbol': String.fromCharCode(0x2297),
  31. 'color': '#06f',
  32. 'impassable': function (player) {
  33. if (player.hasItem('blueKey')) {
  34. player.removeItem('blueKey');
  35. return false;
  36. } else {
  37. return true;
  38. }
  39. }
  40. });
  41.  
  42. map.defineObject('greenLock', {
  43. 'symbol': String.fromCharCode(0x2297),
  44. 'color': '#0f0',
  45. 'impassable': function (player) {
  46. if (player.hasItem('greenKey')) {
  47. player.removeItem('redKey'); map.placeObject(25, 10,'blueKey');
  48. return false;
  49. } else {
  50. return true;
  51. }
  52. }
  53. });
  54.  
  55. map.defineObject('yellowLock', {
  56. 'symbol': String.fromCharCode(0x2297),
  57. 'color': 'yellow',
  58. 'impassable': function (player) {
  59. if (player.hasItem('yellowKey')) {
  60. player.removeItem('yellowKey');
  61. return false;
  62. } else {
  63. return true;
  64. }
  65. }
  66. });
  67.  
  68. map.createFromGrid(
  69. [' +++++ +++++ ',
  70. ' + b +++ r + ',
  71. ' + +E+ + ',
  72. '+++G+B+ +R+G+++',
  73. '+ y B R b +',
  74. '+ + + +',
  75. '+++++ @ +++++',
  76. '+ + + +',
  77. '+ y R B y +',
  78. '++++++Y+Y++++++',
  79. ' + + + ',
  80. ' + ABy + ',
  81. ' +++++++ '],
  82. {
  83. '@': 'player',
  84. 'E': 'exit',
  85. 'A': 'theAlgorithm',
  86. '+': 'block',
  87. 'R': 'redLock',
  88. 'G': 'greenLock',
  89. 'B': 'blueLock',
  90. 'Y': 'yellowLock',
  91. 'r': 'redKey',
  92. 'g': 'greenKey',
  93. 'b': 'blueKey',
  94. 'y': 'yellowKey'
  95. }, 17, 6);
  96. }
  97.  
  98. function validateLevel(map) {
  99. map.validateExactlyXManyObjects(1, 'exit');
  100. map.validateAtMostXObjects(1, 'theAlgorithm');
  101. map.validateAtMostXObjects(4, 'yellowKey');
  102. map.validateAtMostXObjects(2, 'blueKey');
  103. map.validateAtMostXObjects(1, 'redKey');
  104. }
  105.  
  106. function onExit(map) {
  107. // make sure we have all the items we need!
  108. if (!map.getPlayer().hasItem('theAlgorithm')) {
  109. map.writeStatus("You must get that Algorithm!!");
  110. return false;
  111. } else if (!map.getPlayer().hasItem('computer')) {
  112. map.writeStatus("You'll need your computer! [Ctrl-5 to restart]");
  113. return false;
  114. } else if (!map.getPlayer().hasItem('phone')) {
  115. map.writeStatus("You'll need your phone! [Ctrl-5 to restart]");
  116. return false;
  117. } else {
  118. return true;
  119. }
  120. }
Add Comment
Please, Sign In to add comment