git @ Cat's Eye Technologies Super-Wumpus-Land / 55e23a0
Basics of shooting arrows. catseye 9 years ago
1 changed file(s) with 81 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
424424 }
425425 return message;
426426 };
427
428 this.fireArrow = function() {
429 var self = this;
430 var print = function(str) {
431 self.tty.write(str);
432 };
433 print("Twang!... ");
434 this.arrows--;
435
436 var arrowLoc = this.roomNo;
437 while (this.itinerary.length > 0) {
438 var arrowDest = this.itinerary.shift();
439 var room = this.rooms[arrowLoc];
440 if ((arrowLoc === arrowDest) ||
441 (room.exits[0] === arrowDest) ||
442 (room.exits[1] === arrowDest) ||
443 (room.exits[2] === arrowDest)) {
444 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 + ")");
472 } else {
473 print("...*clang*\n\n");
474 this.itinerary = [];
475 if (d(1, 3) === 1) room.arrows++;
476 return;
477 }
478 }
479
480 var room = this.rooms[arrowLoc];
481 if (room.pits === 0) {
482 print("...*thud*");
483 room.arrows++;
484 }
485 };
427486
428487 /* -*-*-*- GAME STATES -*-*-*- */
429488
430489 this.statePrompt = function(input) {
431490 if (this.show()) {
432491 this.ask();
492 }
493 };
494
495 this.stateArrowPrompt = function(input) {
496 var self = this;
497 var print = function(str) {
498 self.tty.write(str);
499 };
500 var dest = parseInt(input, 10);
501 if (dest !== 0 && dest !== NaN) {
502 this.itinerary.push(dest);
503 print("Enter next location to fire into> ");
504 this.gameState = 'stateArrowPrompt';
505 return;
506 } else {
507 this.fireArrow();
508 this.pause('statePrompt');
433509 }
434510 };
435511
494570 }
495571 this.pause('statePrompt');
496572 return;
573 } else if (input === 'F' && this.arrows > 0) {
574 this.itinerary = [];
575 print("Enter the first location to fire into> ");
576 this.gameState = 'stateArrowPrompt';
577 return;
497578 } else if (input === 'D' && room.guano > 0) {
498579 this.ustink += d(3,3);
499580 room.guano--;