# 2.11BSD#431 - /usr/src/games/battlestar/cypher.c

##### Functions

    cypher            X

       1: /*
       2:  * Copyright (c) 1983 Regents of the University of California,
       3:  * All rights reserved.  Redistribution permitted subject to
       4:  * the terms of the Berkeley Software License Agreement.
       5:  */
       6:
       7: #if !defined(lint) && !defined(pdp11)
       8: static char sccsid[] = "@(#)cypher.c	1.3.1 1996/10/26";
       9: #endif
      10:
      11: #include "externs.h"
      12:
      13: cypher()
      14: {
      15:     register int n;
      16:     int junk;
      17:     int lflag = -1;
      18:     char buffer[10];
      19:
      20:     while (wordtype[wordnumber] == ADJS)
      21:         wordnumber++;
      22:     while (wordnumber <= wordcount) {
      23:         switch(wordvalue[wordnumber]) {
      24:
      25:             case UP:
      26:                 if (location[position].access || wiz || tempwiz) {
      27:                     if (!location[position].access)
      28:                         puts("Zap!  A gust of wind lifts you up.");
      29:                     if (!move(location[position].up, AHEAD))
      30:                         return(-1);
      31:                 } else {
      32:                     puts("There is no way up");
      33:                     return(-1);
      34:                 }
      35:                 lflag = 0;
      36:                 break;
      37:
      38:              case DOWN:
      39:                 if (!move(location[position].down, AHEAD))
      40:                     return(-1);
      41:                 lflag = 0;
      42:                 break;
      43:
      44:              case LEFT:
      45:                 if (!move(left, LEFT))
      46:                     return(-1);
      47:                 lflag = 0;
      48:                 break;
      49:
      50:              case RIGHT:
      51:                 if (!move(right, RIGHT))
      52:                     return(-1);
      53:                 lflag = 0;
      54:                 break;
      55:
      56:              case AHEAD:
      57:                 if (!move(ahead, AHEAD))
      58:                     return(-1);
      59:                 lflag = 0;
      60:                 break;
      61:
      62:              case BACK:
      63:                 if (!move(back, BACK))
      64:                     return(-1);
      65:                 lflag = 0;
      66:                 break;
      67:
      68:              case SHOOT:
      69:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
      70:                     for (n=0; n < NUMOFOBJECTS; n++)
      71:                         if (testbit(location[position].objects,n) && *objsht[n]){
      72:                             wordvalue[wordnumber+1] = n;
      73:                             wordnumber = shoot();
      74:                         }
      75:                 wordnumber++;
      76:                 wordnumber++;
      77:                 }
      78:                 else
      79:                     shoot();
      80:                 break;
      81:
      82:              case TAKE:
      83:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
      84:                     for (n=0; n < NUMOFOBJECTS; n++)
      85:                         if (testbit(location[position].objects,n) && *objsht[n]){
      86:                             wordvalue[wordnumber+1] = n;
      87:                             wordnumber = take(location[position].objects);
      88:                         }
      89:                 wordnumber++;
      90:                 wordnumber++;
      91:                 }
      92:                 else
      93:                     take(location[position].objects);
      94:                 break;
      95:
      96:              case DROP:
      97:
      98:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
      99:                     for (n=0; n < NUMOFOBJECTS; n++)
     100:                         if (testbit(inven,n)){
     101:                             wordvalue[wordnumber+1] = n;
     102:                             wordnumber = drop("Dropped");
     103:                         }
     104:                 wordnumber++;
     105:                 wordnumber++;
     106:                 }
     107:                 else
     108:                     drop("Dropped");
     109:                 break;
     110:
     111:
     112:              case KICK:
     113:              case THROW:
     114:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     115:                     for (n=0; n < NUMOFOBJECTS; n++)
     116:                         if (testbit(inven,n) ||
     117:                           testbit(location[position].objects, n) && *objsht[n]){
     118:                             wordvalue[wordnumber+1] = n;
     119:                             wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
     120:                         }
     121:                     wordnumber += 2;
     122:                 } else
     123:                     throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
     124:                 break;
     125:
     126:              case TAKEOFF:
     127:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     128:                     for (n=0; n < NUMOFOBJECTS; n++)
     129:                         if (testbit(wear,n)){
     130:                             wordvalue[wordnumber+1] = n;
     131:                             wordnumber = takeoff();
     132:                         }
     133:                     wordnumber += 2;
     134:                 }
     135:                 else
     136:                     takeoff();
     137:                 break;
     138:
     139:
     140:              case DRAW:
     141:
     142:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     143:                     for (n=0; n < NUMOFOBJECTS; n++)
     144:                         if (testbit(wear,n)){
     145:                             wordvalue[wordnumber+1] = n;
     146:                             wordnumber = draw();
     147:                         }
     148:                     wordnumber += 2;
     149:                 }
     150:                 else
     151:                     draw();
     152:                 break;
     153:
     154:
     155:              case PUTON:
     156:
     157:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     158:                     for (n=0; n < NUMOFOBJECTS; n++)
     159:                         if (testbit(location[position].objects,n) && *objsht[n]){
     160:                             wordvalue[wordnumber+1] = n;
     161:                             wordnumber = puton();
     162:                         }
     163:                     wordnumber += 2;
     164:                 }
     165:                 else
     166:                     puton();
     167:                 break;
     168:
     169:              case WEARIT:
     170:
     171:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     172:                     for (n=0; n < NUMOFOBJECTS; n++)
     173:                         if (testbit(inven,n)){
     174:                             wordvalue[wordnumber+1] = n;
     175:                             wordnumber = wearit();
     176:                         }
     177:                     wordnumber += 2;
     178:                 }
     179:                 else
     180:                     wearit();
     181:                 break;
     182:
     183:
     184:              case EAT:
     185:
     186:                 if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
     187:                     for (n=0; n < NUMOFOBJECTS; n++)
     188:                         if (testbit(inven,n)){
     189:                             wordvalue[wordnumber+1] = n;
     190:                             wordnumber = eat();
     191:                         }
     192:                     wordnumber += 2;
     193:                 }
     194:                 else
     195:                     eat();
     196:                 break;
     197:
     198:
     199:             case PUT:
     200:                 put();
     201:                 break;
     202:
     203:
     204:             case INVEN:
     205:                 if (ucard(inven)){
     206:                     puts("You are holding:\n");
     207:                     for (n=0; n < NUMOFOBJECTS; n++)
     208:                         if (testbit(inven,n))
     209:                             printf("\t%s\n", objsht[n]);
     210:                     printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."),(WEIGHT ? carrying*100/WEIGHT : -1));
     211:                     printf("Your arms are %d%% full.\n",encumber*100/CUMBER);
     212:                 }
     213:                 else
     214:                     puts("You aren't carrying anything.");
     215:
     216:                 if (ucard(wear)){
     217:                     puts("\nYou are wearing:\n");
     218:                     for (n=0; n < NUMOFOBJECTS; n++)
     219:                         if (testbit(wear,n))
     220:                             printf("\t%s\n", objsht[n]);
     221:                 }
     222:                 else
     223:                     puts("\nYou are stark naked.");
     224:                 if (card(injuries,NUMOFINJURIES)){
     225:                     puts("\nYou have suffered:\n");
     226:                     for (n=0; n < NUMOFINJURIES; n++)
     227:                         if (injuries[n])
     228:                             printf("\t%s\n",ouch[n]);
     229:                     printf("\nYou can still carry up to %d kilogram%s\n",WEIGHT,(WEIGHT == 1 ? "." : "s."));
     230:                 }
     231:                 else
     232:                     puts("\nYou are in perfect health.");
     233:                 break;
     234:
     235:             case USE:
     236:                 lflag = use();
     237:                 break;
     238:
     239:             case LOOK:
     240:                 if (!notes[CANTSEE] || testbit(inven,LAMPON) || testbit(location[position].objects,LAMPON) || matchlight){
     241:                     beenthere[position] = 2;
     242:                     writedes();
     243:                     printobjs();
     244:                     if (matchlight){
     245:                         puts("\nYour match splutters out.");
     246:                         matchlight = 0;
     247:                     }
     248:                 } else
     249:                     puts("I can't see anything.");
     250:                 return(-1);
     251:                 break;
     252:
     253:              case SU:
     254:              if (wiz || tempwiz){
     255:                 printf("\nRoom (was %d) = ", position);
     256:                 fgets(buffer,10,stdin);
     257:                 if (*buffer != '\n')
     258:                     sscanf(buffer,"%d", &position);
     259:                 printf("Time (was %d) = ",Time);
     260:                 fgets(buffer,10,stdin);
     261:                 if (*buffer != '\n')
     262:                     sscanf(buffer,"%d", &Time);
     263:                 printf("Fuel (was %d) = ",fuel);
     264:                 fgets(buffer,10,stdin);
     265:                 if (*buffer != '\n')
     266:                     sscanf(buffer,"%d", &fuel);
     267:                 printf("Torps (was %d) = ",torps);
     268:                 fgets(buffer,10,stdin);
     269:                 if (*buffer != '\n')
     270:                     sscanf(buffer,"%d", &torps);
     271:                 printf("CUMBER (was %d) = ",CUMBER);
     272:                 fgets(buffer,10,stdin);
     273:                 if (*buffer != '\n')
     274:                     sscanf(buffer,"%d", &CUMBER);
     275:                 printf("WEIGHT (was %d) = ",WEIGHT);
     276:                 fgets(buffer,10,stdin);
     277:                 if (*buffer != '\n')
     278:                     sscanf(buffer,"%d",&WEIGHT);
     279:                 printf("Clock (was %d) = ",clock);
     280:                 fgets(buffer,10,stdin);
     281:                 if (*buffer != '\n')
     282:                     sscanf(buffer,"%d",&clock);
     283:                 printf("Wizard (was %d, %d) = ",wiz, tempwiz);
     284:                 fgets(buffer,10,stdin);
     285:                 if (*buffer != '\n'){
     286:                     sscanf(buffer,"%d",&junk);
     287:                     if (!junk)
     288:                         tempwiz = wiz = 0;
     289:                 }
     290:                 printf("\nDONE.\n");
     291:                 return(0);
     292:              }
     293:              else
     294:                  puts("You aren't a wizard.");
     295:              break;
     296:
     297:              case SCORE:
     298:                 printf("\tPLEASURE\tPOWER\t\tEGO\n");
     299:                 printf("\t%3d\t\t%3d\t\t%3d\n\n",pleasure,power,ego);
     300:                 printf("This gives you the rating of %s in %d turns.\n",rate(),Time);
     301:                 printf("You have visited %d out of %d rooms this run (%d%%).\n",card(beenthere,NUMOFROOMS),NUMOFROOMS,card(beenthere,NUMOFROOMS)*100/NUMOFROOMS);
     302:                 break;
     303:
     304:              case KNIFE:
     305:              case KILL:
     306:                 murder();
     307:                 break;
     308:
     309:              case UNDRESS:
     310:              case RAVAGE:
     311:                 ravage();
     312:                 break;
     313:
     314:              case SAVE:
     315:                 save();
     316:                 break;
     317:
     318:              case FOLLOW:
     319:                 lflag = follow();
     320:                 break;
     321:
     322:              case GIVE:
     323:                 give();
     324:                 break;
     325:
     326:              case KISS:
     327:                 kiss();
     328:                 break;
     329:
     330:              case LOVE:
     331:                  love();
     332:                  break;
     333:
     334:              case RIDE:
     335:                 lflag = ride();
     336:                 break;
     337:
     338:              case DRIVE:
     339:                 lflag = drive();
     340:                 break;
     341:
     342:              case LIGHT:
     343:                  light();
     344:                  break;
     345:
     346:              case LAUNCH:
     347:                 if (!launch())
     348:                     return(-1);
     349:                 else
     350:                     lflag = 0;
     351:                 break;
     352:
     353:             case LANDIT:
     354:                 if (!land())
     355:                     return(-1);
     356:                 else
     357:                     lflag = 0;
     358:                 break;
     359:
     360:             case TIME:
     361:                 chime();
     362:                 break;
     363:
     364:              case SLEEP:
     365:                 zzz();
     366:                 break;
     367:
     368:              case DIG:
     369:                 dig();
     370:                 break;
     371:
     372:              case JUMP:
     373:                 lflag = jump();
     374:                 break;
     375:
     376:              case BURY:
     377:                 bury();
     378:                 break;
     379:
     380:              case SWIM:
     381:                 puts("Surf's up!");
     382:                 break;
     383:
     384:              case DRINK:
     385:                 drink();
     386:                 break;
     387:
     388:              case QUIT:
     389:                 die();
     390:
     391:              default:
     392:                 puts("How's that?");
     393:                 return(-1);
     394:                 break;
     395:
     396:
     397:         }
     398:         if (wordnumber < wordcount && *words[wordnumber++] == ',')
     399:             continue;
     400:         else return(lflag);
     401:        }
     402:        return(lflag);
     403: }

#### Defined functions

cypher defined in line 13; used 5 times

- in /usr/src/games/battlestar/battlestar.c line 55
- in /usr/src/games/battlestar/com2.c line 78-82(2)
- in /usr/src/games/battlestar/com4.c line 23
- in /usr/src/games/battlestar/com7.c line 206

#### Defined variables

sccsid defined in line 8; never used

Last modified: 1996-10-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 1659 |