git @ Cat's Eye Technologies Super-Wumpus-Land / 6640413
Arrows do damage, skin carcasses, rudiments of subway. catseye 9 years ago
1 changed file(s) with 66 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
3434 this.rooms = [];
3535 this.visited = [];
3636 this.wumpi = [];
37 this.itinerary = [];
3738
3839 this.name = 'user'; // Actually, it's the *player's* name...
3940 this.roomNo = 0;
425426 return message;
426427 };
427428
429 // returns true if you didn't die
428430 this.fireArrow = function() {
429431 var self = this;
430432 var print = function(str) {
442444 (room.exits[1] === arrowDest) ||
443445 (room.exits[2] === arrowDest)) {
444446 arrowLoc = arrowDest;
445 /*
446 for(my $i = 0; $i < 20; $i++)
447 {
448 if ($wumpus[$i]->[0] == $l)
449 {
450 sleep 3;
451 print "...*SPLAK*! Got something!\n";
452 $wumpus[$i]->[0] = 0;
453 $room[$l]->[5]++;
454 pause();
455 return;
456 }
457 }
458
459 if ($room == $l)
460 {
461 sleep 3;
462 print "...*ZOINKS!*\n\nYou shot yourself in the foot, $name!!!\n";
463 $done = 1;
464 pause();
465 return;
466 }
467
468 sleep 1;
469 print "...whoosh... ";
470 */
471 print("(arrow is in room " + arrowLoc + ")");
447 for (var i = 0; i < this.wumpi.length; i++) {
448 var wumpus = this.wumpi[i];
449 if (wumpus.room === arrowLoc) {
450 print("...*SPLAK*! Got something!\n");
451 wumpus.room = 0;
452 this.rooms[arrowLoc].carcasses++;
453 return true;
454 }
455 }
456 if (arrowLoc === this.roomNo) {
457 print("...*ZOINKS!*\n\nYou shot yourself in the foot, " + this.name + "!!!\n");
458 return false;
459 }
460 print("...whoosh... ");
472461 } else {
473462 print("...*clang*\n\n");
474463 this.itinerary = [];
475464 if (d(1, 3) === 1) room.arrows++;
476 return;
465 return true;
477466 }
478467 }
479468
482471 print("...*thud*");
483472 room.arrows++;
484473 }
474 return true;
485475 };
486476
487477 /* -*-*-*- GAME STATES -*-*-*- */
498488 self.tty.write(str);
499489 };
500490 var dest = parseInt(input, 10);
501 if (dest !== 0 && dest !== NaN) {
491 if (isNaN(dest)) {
492 print("Not a valid location, try again> ");
493 this.gameState = 'stateArrowPrompt';
494 } else if (dest === 0) {
495 if (this.fireArrow()) {
496 this.pause('statePrompt');
497 } else {
498 this.gameState = 'stateGameOver';
499 }
500 } else {
502501 this.itinerary.push(dest);
503 print("Enter next location to fire into> ");
502 print("Enter next location to fire into, or 0 to commence> ");
504503 this.gameState = 'stateArrowPrompt';
505 return;
504 }
505 };
506
507 this.stateSubwayPrompt = function(input) {
508 var self = this;
509 var print = function(str) {
510 self.tty.write(str);
511 };
512 var dest = parseInt(input, 10);
513 if (isNaN(dest) || dest < 1 || dest > 100) {
514 print("OK, keep your token, if that's the way you feel.\n");
515 this.pause('statePrompt');
506516 } else {
507 this.fireArrow();
517 this.tokens--;
518 print("\n \"All aboard!\"\n\n");
508519 this.pause('statePrompt');
520 /*
521 sleep 2;
522 for(my $q = 1; $q <= 3; $q++) { print ((' ' x $q) x $q . "...chug chug...\n"); sleep 1; }
523 for(my $i = 1; $i <= 3; $i++)
524 {
525 $room = d(1,100);
526 $subway = 1;
527 show();
528 for(my $q = 1; $q <= 3; $q++) { print ((' ' x $i) x $q . "...chug chug...\n"); sleep 1; }
529 $subway = 0;
530 }
531 print "\n \"Next stop, $r, $room[$r]->[0]...\"";
532 sleep 3;
533 $room = $r;
534 */
509535 }
510536 };
511537
575601 print("Enter the first location to fire into> ");
576602 this.gameState = 'stateArrowPrompt';
577603 return;
604 } else if (input === 'S' && room.carcasses > 0) {
605 this.hides += room.carcasses;
606 room.carcasses = 0;
607 } else if (input === 'R' && this.tokens > 0) {
608 print("Where do you want to take the subway to? [1-100] ");
609 this.gameState = 'stateSubwayPrompt';
610 return;
578611 } else if (input === 'D' && room.guano > 0) {
579612 this.ustink += d(3,3);
580613 room.guano--;
590623 this.tokens += room.tokens; room.tokens = 0;
591624 } else {
592625 var dest = parseInt(input, 10);
593 if (dest !== NaN) {
626 if (!isNaN(dest)) {
594627 if (room.exits[0] === dest ||
595628 room.exits[1] === dest ||
596629 room.exits[2] === dest) {