git @ Cat's Eye Technologies Super-Wumpus-Land / 78ed3a3
Finish implementing score and subway. catseye 10 years ago
1 changed file(s) with 73 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
1515 }
1616
1717 function rjust(str, width) {
18 str = '' + str;
1819 if (str.length >= width) return str;
1920 return rep(' ', width - str.length) + str;
2021 }
6364 this.grip = 0;
6465 this.ustink = 0;
6566
66 this.subway = false;
67 this.subway = 0;
68 this.subwayTurns = 0;
6769
6870 this.skip = false;
6971 this.moved = false;
161163 if (i === 6)
162164 print("* S U P E R W U M P U S L A N D *\n");
163165 else if (i === 7)
164 print("* --------- ----------- ------- *\n");
166 print("* --------- ----------- ------- *\n");
165167 else if (i === 9)
166 print("* v1.1 (Javascript) *\n");
168 print("* v1.1 (Javascript) *\n");
167169 else if (i === 14)
168 print("* by Chris Pressey, Cat's Eye Technologies *\n");
170 print("* by Chris Pressey, Cat's Eye Technologies *\n");
169171 else if (i === 16)
170 print("* Based on an original game by Gregory Yob *\n");
172 print("* Based on an original game by Gregory Yob *\n");
171173 else
172 print("*" + rep(' ', 70) + "*\n");
174 print("*" + rep(' ', 70) + "*\n");
173175 }
174176 print(rep('*', 72) + "\n");
175177 };
183185 print("Scorecard for " + this.name + "\n");
184186 print(rep('=', 14 + this.name.length) + "\n\n");
185187
186 var h1 = rjust('' + this.hides, 3);
187 var s1 = rjust('' + (this.hides * 25), 9);
188 print("Wumpus Hides " + h1 + " x 25 = " + s1 + "\n");
189
190 var h2 = rjust('' + this.arrows, 3);
191 var s2 = rjust('' + (this.arrows * 2), 9);
192 print("Arrows Remaining " + h2 + " x 2 = " + s2 + "\n");
193
194 var h4 = rjust('' + this.cans, 3);
195 var s4 = rjust('' + (this.cans * 3), 9);
196 print("Aerosol Cans " + h4 + " x 3 = " + s4 + "\n");
197
198 var h5 = rjust('' + this.tokens, 3);
199 var s5 = rjust('' + (this.tokens * 5), 9);
200 print("Subway Tokens " + h5 + " x 5 = " + s5 + "\n");
201
202 /*
203 my $h3 = 0;
204 for (my $i = 1; $i <= 100; $i++)
205 {
206 $h3++ if $visited[$i];
207 }
208 $h3 = sprintf("%3d", $h3);
209 my $s3 = sprintf("%9d", $h3);
210 print "Locations Visited $h3 x 1 = $s3\n";
211
212 my $tot = sprintf("%9d", $s1 + $s2 + $s3 + $s4 + $s5);
213 print " ---------\n";
214 print "Total $tot\n\n";
215 */
216 };
217
188 var scoreHides = this.hides * 25;
189 print("Wumpus Hides " +
190 rjust(this.hides, 3) +
191 " x 25 = " +
192 rjust(scoreHides, 9) +
193 "\n");
194
195 var scoreArrows = this.arrows * 2;
196 print("Arrows Remaining " +
197 rjust(this.arrows, 3) +
198 " x 2 = " +
199 rjust(scoreArrows, 9) +
200 "\n");
201
202 var scoreCans = this.cans * 3;
203 print("Aerosol Cans " +
204 rjust(this.cans, 3) +
205 " x 3 = " +
206 rjust(scoreCans, 9) +
207 "\n");
208
209 var scoreTokens = this.tokens * 5;
210 print("Subway Tokens " +
211 rjust(this.tokens, 3) +
212 " x 5 = " +
213 rjust(scoreTokens, 9) +
214 "\n");
215
216 var scoreLocations = 0;
217 for (var i = 1; i <= 100; i++) {
218 if (this.visited[i]) scoreLocations++;
219 }
220 print("Locations Visited " +
221 rjust(scoreLocations, 3) +
222 " x 1 = " +
223 rjust(scoreLocations, 9) +
224 "\n");
225
226 var scoreTotal = scoreHides + scoreArrows + scoreCans + scoreTokens + scoreLocations;
227 print(" ---------\n");
228 print("Total " + rjust(scoreTotal, 9) + "\n\n");
229 };
218230
219231 this.pause = function(nextState) {
220232 this.tty.write("\n[Press ENTER to continue.] ");
277289 for (var i = 0; i < this.wumpi.length; i++) {
278290 if (this.wumpi[i].room === this.roomNo) {
279291 if (!this.wumpi[i].asleep) {
280 if (this.subway) {
292 if (this.subway > 0) {
281293 print("* Right outside the train window is a Wumpus!\n");
282294 } else if (this.camo) {
283295 print("* Good thing the Wumpus here can't see you.\n");
306318 }
307319
308320 if (room.bats > 0) {
309 if (this.subway) {
321 if (this.subway > 0) {
310322 print("* Super Bats flutter out of the path of the subway train.\n");
311323 } else if (this.batbgon > 0) {
312324 print("* Super Bats in this location stay well away from your awful stench!\n");
329341 }
330342
331343 if (room.pits > 0) {
332 if (this.subway) {
344 if (this.subway > 0) {
333345 print("* The subway rails take a curving path around a bottomless pit here.\n");
334346 } else if (this.grip > 0) {
335347 print("* You deftly stick to the edge of the bottomless pit!\n");
592604 this.pause('statePrompt');
593605 } else {
594606 this.tokens--;
607 this.subway = dest;
608 this.subwayTurns = 3;
595609 print("\n \"All aboard!\"\n\n");
610 this.pause('stateRidingSubway');
611 }
612 };
613
614 this.stateRidingSubway = function(input) {
615 var self = this;
616 var print = function(str) {
617 self.tty.write(str);
618 };
619 this.roomNo = d(1, 100);
620 this.show();
621 this.subwayTurns--;
622 if (this.subwayTurns === 0) {
623 print("\n \"Next stop, " + this.subway + ", " + this.rooms[this.subway].desc + "...\"\n\n");
624 this.roomNo = this.subway;
596625 this.pause('statePrompt');
597 /*
598 sleep 2;
599 for(my $q = 1; $q <= 3; $q++) { print ((' ' x $q) x $q . "...chug chug...\n"); sleep 1; }
600 for(my $i = 1; $i <= 3; $i++)
601 {
602 $room = d(1,100);
603 $subway = 1;
604 show();
605 for(my $q = 1; $q <= 3; $q++) { print ((' ' x $i) x $q . "...chug chug...\n"); sleep 1; }
606 $subway = 0;
607 }
608 print "\n \"Next stop, $r, $room[$r]->[0]...\"";
609 sleep 3;
610 $room = $r;
611 */
626 } else {
627 print("\n ...chug chug...\n\n");
628 this.pause('stateRidingSubway');
612629 }
613630 };
614631