summaryrefslogtreecommitdiffstats
path: root/battlestar
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2000-09-17 23:04:17 +0000
committerjsm <jsm@NetBSD.org>2000-09-17 23:04:17 +0000
commit0c5056102773ba23e89c985e185f895b7877e839 (patch)
treefc5ccd28886a95ea7a93bc11177213469e4e6dd6 /battlestar
parente828812cad1edfdd4b4f01f93330a6421cd816ab (diff)
downloadbsdgames-darwin-0c5056102773ba23e89c985e185f895b7877e839.tar.gz
bsdgames-darwin-0c5056102773ba23e89c985e185f895b7877e839.tar.zst
bsdgames-darwin-0c5056102773ba23e89c985e185f895b7877e839.zip
Clean up formatting; partly from OpenBSD.
Diffstat (limited to 'battlestar')
-rw-r--r--battlestar/com1.c9
-rw-r--r--battlestar/com2.c28
-rw-r--r--battlestar/com4.c77
-rw-r--r--battlestar/com5.c61
-rw-r--r--battlestar/com6.c76
-rw-r--r--battlestar/com7.c181
-rw-r--r--battlestar/getcom.c17
7 files changed, 209 insertions, 240 deletions
diff --git a/battlestar/com1.c b/battlestar/com1.c
index 0e3f474e..b3e4f6ff 100644
--- a/battlestar/com1.c
+++ b/battlestar/com1.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com1.c,v 1.11 2000/09/08 17:25:31 jsm Exp $ */
+/* $NetBSD: com1.c,v 1.12 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com1.c,v 1.11 2000/09/08 17:25:31 jsm Exp $");
+__RCSID("$NetBSD: com1.c,v 1.12 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -51,7 +51,7 @@ moveplayer(thataway, token)
wordnumber++;
if ((!notes[CANTMOVE] && !notes[LAUNCHED]) ||
testbit(location[position].objects, LAND) ||
- (fuel > 0 && notes[LAUNCHED]))
+ (fuel > 0 && notes[LAUNCHED])) {
if (thataway) {
position = thataway;
newway(token);
@@ -62,11 +62,12 @@ moveplayer(thataway, token)
whichway(location[position]);
return (0);
}
- else
+ } else {
if (notes[CANTMOVE] && !notes[LAUNCHED])
puts("You aren't able to move; you better drop something.");
else
puts("You are out of fuel; now you will rot in space forever!");
+ }
return (1);
}
diff --git a/battlestar/com2.c b/battlestar/com2.c
index 96748eba..19ec2ec6 100644
--- a/battlestar/com2.c
+++ b/battlestar/com2.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com2.c,v 1.9 2000/09/10 10:51:16 jsm Exp $ */
+/* $NetBSD: com2.c,v 1.10 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com2.c,v 1.9 2000/09/10 10:51:16 jsm Exp $");
+__RCSID("$NetBSD: com2.c,v 1.10 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -159,20 +159,16 @@ use()
ourtime++;
notes[CANTSEE] = 0;
return (0);
- } else
- if (position == FINAL)
- puts("The amulet won't work in here.");
- else
- if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
- printf("Your compass points %s.\n", truedirec(NORTH, '-'));
- else
- if (wordvalue[wordnumber] == COMPASS)
- puts("You aren't holding the compass.");
- else
- if (wordvalue[wordnumber] == AMULET)
- puts("You aren't holding the amulet.");
- else
- puts("There is no apparent use.");
+ } else if (position == FINAL)
+ puts("The amulet won't work in here.");
+ else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
+ printf("Your compass points %s.\n", truedirec(NORTH, '-'));
+ else if (wordvalue[wordnumber] == COMPASS)
+ puts("You aren't holding the compass.");
+ else if (wordvalue[wordnumber] == AMULET)
+ puts("You aren't holding the amulet.");
+ else
+ puts("There is no apparent use.");
return (-1);
}
diff --git a/battlestar/com4.c b/battlestar/com4.c
index 387eb6d2..d1be836d 100644
--- a/battlestar/com4.c
+++ b/battlestar/com4.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com4.c,v 1.9 2000/09/10 10:51:17 jsm Exp $ */
+/* $NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com4.c,v 1.9 2000/09/10 10:51:17 jsm Exp $");
+__RCSID("$NetBSD: com4.c,v 1.10 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -76,17 +76,14 @@ take(from)
clearbit(from, value);
if (value == MEDALION)
win--;
- } else
- if (testbit(inven, value))
- printf("You're already holding%s%s.\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]);
- else
- if (!heavy)
- printf("The %s %s too heavy.\n", objsht[value], (objsht[value][n - 1] == 's' ? "are" : "is"));
- else
- if (!bulky)
- printf("The %s %s too cumbersome to hold.\n", objsht[value], (objsht[value][n - 1] == 's' ? "are" : "is"));
- else
- printf("I dont see any %s around here.\n", objsht[value]);
+ } else if (testbit(inven, value))
+ printf("You're already holding%s%s.\n", (objsht[value][n - 1] == 's' ? " " : " a "), objsht[value]);
+ else if (!heavy)
+ printf("The %s %s too heavy.\n", objsht[value], (objsht[value][n - 1] == 's' ? "are" : "is"));
+ else if (!bulky)
+ printf("The %s %s too cumbersome to hold.\n", objsht[value], (objsht[value][n - 1] == 's' ? "are" : "is"));
+ else
+ printf("I dont see any %s around here.\n", objsht[value]);
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
else
@@ -117,26 +114,25 @@ take(from)
wordvalue[wordnumber] = MAID;
wordtype[wordnumber--] = OBJECT;
return (take(from));
- } else
- if (testbit(from, DEADWOOD)) {
- wordvalue[wordnumber] = DEADWOOD;
+ } else if (testbit(from, DEADWOOD)) {
+ wordvalue[wordnumber] = DEADWOOD;
+ wordtype[wordnumber--] = OBJECT;
+ return (take(from));
+ } else if (testbit(from, DEADNATIVE)) {
+ wordvalue[wordnumber] = DEADNATIVE;
+ wordtype[wordnumber--] = OBJECT;
+ return (take(from));
+ } else {
+ if (testbit(from, DEADGOD)) {
+ wordvalue[wordnumber] = DEADGOD;
wordtype[wordnumber--] = OBJECT;
return (take(from));
- } else
- if (testbit(from, DEADNATIVE)) {
- wordvalue[wordnumber] = DEADNATIVE;
- wordtype[wordnumber--] = OBJECT;
- return (take(from));
- } else
- if (testbit(from, DEADGOD)) {
- wordvalue[wordnumber] = DEADGOD;
- wordtype[wordnumber--] = OBJECT;
- return (take(from));
- } else {
- wordvalue[wordnumber] = DEADTIME;
- wordtype[wordnumber--] = OBJECT;
- return (take(from));
- }
+ } else {
+ wordvalue[wordnumber] = DEADTIME;
+ wordtype[wordnumber--] = OBJECT;
+ return (take(from));
+ }
+ }
break;
case AMULET:
@@ -306,9 +302,8 @@ drop(name)
if (testbit(location[position].objects, value)) {
if (*name == 'T')
puts("Kicked instead.");
- else
- if (*name == 'G')
- puts("Given anyway.");
+ else if (*name == 'G')
+ puts("Given anyway.");
}
} else
puts("Kicked.");
@@ -377,14 +372,12 @@ eat()
snooze += CYCLE / 10;
ourtime++;
puts("Eaten. You can explore a little longer now.");
- } else
- if (ourtime < ate - CYCLE)
- puts("You're stuffed.");
- else
- if (!testbit(inven, KNIFE))
- puts("You need a knife.");
- else
- printf("You aren't holding the %s.\n", objsht[value]);
+ } else if (ourtime < ate - CYCLE)
+ puts("You're stuffed.");
+ else if (!testbit(inven, KNIFE))
+ puts("You need a knife.");
+ else
+ printf("You aren't holding the %s.\n", objsht[value]);
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
else
diff --git a/battlestar/com5.c b/battlestar/com5.c
index 24afa00b..4ae02a57 100644
--- a/battlestar/com5.c
+++ b/battlestar/com5.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com5.c,v 1.12 2000/09/10 10:51:17 jsm Exp $ */
+/* $NetBSD: com5.c,v 1.13 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com5.c,v 1.12 2000/09/10 10:51:17 jsm Exp $");
+__RCSID("$NetBSD: com5.c,v 1.13 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -189,7 +189,7 @@ chime()
{
if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
switch ((ourtime % CYCLE) / (CYCLE / 7)) {
- case 0:
+ case 0:
puts("It is just after sunrise.");
break;
case 1:
@@ -211,33 +211,32 @@ chime()
puts("It is near sunset.");
break;
}
+ else if (OUTSIDE)
+ switch ((ourtime % CYCLE) / (CYCLE / 7)) {
+ case 0:
+ puts("It is just after sunset.");
+ break;
+ case 1:
+ puts("It is early evening.");
+ break;
+ case 2:
+ puts("The evening is getting old.");
+ break;
+ case 3:
+ puts("It is near midnight.");
+ break;
+ case 4:
+ puts("These are the wee hours of the morning.");
+ break;
+ case 5:
+ puts("The night is waning.");
+ break;
+ case 6:
+ puts("It is almost morning.");
+ break;
+ }
else
- if (OUTSIDE)
- switch ((ourtime % CYCLE) / (CYCLE / 7)) {
- case 0:
- puts("It is just after sunset.");
- break;
- case 1:
- puts("It is early evening.");
- break;
- case 2:
- puts("The evening is getting old.");
- break;
- case 3:
- puts("It is near midnight.");
- break;
- case 4:
- puts("These are the wee hours of the morning.");
- break;
- case 5:
- puts("The night is waning.");
- break;
- case 6:
- puts("It is almost morning.");
- break;
- }
- else
- puts("I can't tell the time in here.");
+ puts("I can't tell the time in here.");
}
int
@@ -274,12 +273,12 @@ give()
* that's no worse than what other commands than give do in
* the same place. */
wordnumber = last1 - 1;
- if (person && testbit(location[position].objects, person))
+ if (person && testbit(location[position].objects, person)) {
if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
puts("The goddess won't look at you.");
else
result = drop("Given");
- else {
+ } else {
puts("I don't think that is possible.");
wordnumber = max(last1, last2) + 1;
return (0);
diff --git a/battlestar/com6.c b/battlestar/com6.c
index 6e7e6d94..3dbe8823 100644
--- a/battlestar/com6.c
+++ b/battlestar/com6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com6.c,v 1.17 2000/09/17 23:03:43 jsm Exp $ */
+/* $NetBSD: com6.c,v 1.18 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com6.c,v 1.17 2000/09/17 23:03:43 jsm Exp $");
+__RCSID("$NetBSD: com6.c,v 1.18 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -153,41 +153,33 @@ rate()
if (score == pleasure) {
if (score < 5)
return ("novice");
+ else if (score < 20)
+ return ("junior voyeur");
+ else if (score < 35)
+ return ("Don Juan");
else
- if (score < 20)
- return ("junior voyeur");
- else
- if (score < 35)
- return ("Don Juan");
- else
- return ("Marquis De Sade");
- } else
- if (score == power) {
- if (score < 5)
- return ("serf");
- else
- if (score < 8)
- return ("Samurai");
- else
- if (score < 13)
- return ("Klingon");
- else
- if (score < 22)
- return ("Darth Vader");
- else
- return ("Sauron the Great");
- } else {
- if (score < 5)
- return ("Polyanna");
- else
- if (score < 10)
- return ("philanthropist");
- else
- if (score < 20)
- return ("Tattoo");
- else
- return ("Mr. Roarke");
- }
+ return ("Marquis De Sade");
+ } else if (score == power) {
+ if (score < 5)
+ return ("serf");
+ else if (score < 8)
+ return ("Samurai");
+ else if (score < 13)
+ return ("Klingon");
+ else if (score < 22)
+ return ("Darth Vader");
+ else
+ return ("Sauron the Great");
+ } else {
+ if (score < 5)
+ return ("Polyanna");
+ else if (score < 10)
+ return ("philanthropist");
+ else if (score < 20)
+ return ("Tattoo");
+ else
+ return ("Mr. Roarke");
+ }
}
int
@@ -218,14 +210,12 @@ ride()
setbit(location[position].objects, HORSE);
if (location[position].north)
position = location[position].north;
+ else if (location[position].south)
+ position = location[position].south;
+ else if (location[position].east)
+ position = location[position].east;
else
- if (location[position].south)
- position = location[position].south;
- else
- if (location[position].east)
- position = location[position].east;
- else
- position = location[position].west;
+ position = location[position].west;
return (0);
} else
puts("There is no horse here.");
diff --git a/battlestar/com7.c b/battlestar/com7.c
index 043de03c..1cc85f19 100644
--- a/battlestar/com7.c
+++ b/battlestar/com7.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com7.c,v 1.8 2000/09/10 10:51:17 jsm Exp $ */
+/* $NetBSD: com7.c,v 1.9 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com7.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com7.c,v 1.8 2000/09/10 10:51:17 jsm Exp $");
+__RCSID("$NetBSD: com7.c,v 1.9 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -77,14 +77,12 @@ fighton:
case SMITE:
if (testbit(inven, TWO_HANDED))
hurt = rnd(70) - 2 * card(injuries, NUMOFINJURIES) - ucard(wear) - exhaustion;
+ else if (testbit(inven, SWORD) || testbit(inven, BROAD))
+ hurt = rnd(50) % (WEIGHT - carrying) - card(injuries, NUMOFINJURIES) - encumber - exhaustion;
+ else if (testbit(inven, KNIFE) || testbit(inven, MALLET) || testbit(inven, CHAIN) || testbit(inven, MACE) || testbit(inven, HALBERD))
+ hurt = rnd(15) - card(injuries, NUMOFINJURIES) - exhaustion;
else
- if (testbit(inven, SWORD) || testbit(inven, BROAD))
- hurt = rnd(50) % (WEIGHT - carrying) - card(injuries, NUMOFINJURIES) - encumber - exhaustion;
- else
- if (testbit(inven, KNIFE) || testbit(inven, MALLET) || testbit(inven, CHAIN) || testbit(inven, MACE) || testbit(inven, HALBERD))
- hurt = rnd(15) - card(injuries, NUMOFINJURIES) - exhaustion;
- else
- hurt = rnd(7) - encumber;
+ hurt = rnd(7) - encumber;
if (hurt < 5)
switch (rnd(3)) {
@@ -98,82 +96,78 @@ fighton:
puts("His filthy tunic hangs by one less thread.");
break;
}
- else
- if (hurt < 10) {
- switch (rnd(3)) {
- case 0:
- puts("He's bleeding.");
- break;
- case 1:
- puts("A trickle of blood runs down his face.");
- break;
- case 2:
- puts("A huge purple bruise is forming on the side of his face.");
- break;
- }
- lifeline++;
- } else
- if (hurt < 20) {
- switch (rnd(3)) {
- case 0:
- puts("He staggers back quavering.");
- break;
- case 1:
- puts("He jumps back with his hand over the wound.");
- break;
- case 2:
- puts("His shirt falls open with a swath across the chest.");
- break;
- }
- lifeline += 5;
- } else
- if (hurt < 30) {
- switch (rnd(3)) {
- case 0:
- printf("A bloody gash opens up on his %s side.\n", (rnd(2) ? "left" : "right"));
- break;
- case 1:
- puts("The steel bites home and scrapes along his ribs.");
- break;
- case 2:
- puts("You pierce him, and his breath hisses through clenched teeth.");
- break;
- }
- lifeline += 10;
- } else
- if (hurt < 40) {
- switch (rnd(3)) {
- case 0:
- puts("You smite him to the ground.");
- if (strength - lifeline > 20)
- puts("But in a flurry of steel he regains his feet!");
- break;
- case 1:
- puts("The force of your blow sends him to his knees.");
- puts("His arm swings lifeless at his side.");
- break;
- case 2:
- puts("Clutching his blood drenched shirt, he collapses stunned.");
- break;
- }
- lifeline += 20;
- } else {
- switch (rnd(3)) {
- case 0:
- puts("His ribs crack under your powerful swing, flooding his lungs with blood.");
- break;
- case 1:
- puts("You shatter his upheld arm in a spray of blood. The blade continues deep");
- puts("into his back, severing the spinal cord.");
- lifeline += 25;
- break;
- case 2:
- puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground.");
- lifeline += 25;
- break;
- }
- lifeline += 30;
- }
+ else if (hurt < 10) {
+ switch (rnd(3)) {
+ case 0:
+ puts("He's bleeding.");
+ break;
+ case 1:
+ puts("A trickle of blood runs down his face.");
+ break;
+ case 2:
+ puts("A huge purple bruise is forming on the side of his face.");
+ break;
+ }
+ lifeline++;
+ } else if (hurt < 20) {
+ switch (rnd(3)) {
+ case 0:
+ puts("He staggers back quavering.");
+ break;
+ case 1:
+ puts("He jumps back with his hand over the wound.");
+ break;
+ case 2:
+ puts("His shirt falls open with a swath across the chest.");
+ break;
+ }
+ lifeline += 5;
+ } else if (hurt < 30) {
+ switch (rnd(3)) {
+ case 0:
+ printf("A bloody gash opens up on his %s side.\n", (rnd(2) ? "left" : "right"));
+ break;
+ case 1:
+ puts("The steel bites home and scrapes along his ribs.");
+ break;
+ case 2:
+ puts("You pierce him, and his breath hisses through clenched teeth.");
+ break;
+ }
+ lifeline += 10;
+ } else if (hurt < 40) {
+ switch (rnd(3)) {
+ case 0:
+ puts("You smite him to the ground.");
+ if (strength - lifeline > 20)
+ puts("But in a flurry of steel he regains his feet!");
+ break;
+ case 1:
+ puts("The force of your blow sends him to his knees.");
+ puts("His arm swings lifeless at his side.");
+ break;
+ case 2:
+ puts("Clutching his blood drenched shirt, he collapses stunned.");
+ break;
+ }
+ lifeline += 20;
+ } else {
+ switch (rnd(3)) {
+ case 0:
+ puts("His ribs crack under your powerful swing, flooding his lungs with blood.");
+ break;
+ case 1:
+ puts("You shatter his upheld arm in a spray of blood. The blade continues deep");
+ puts("into his back, severing the spinal cord.");
+ lifeline += 25;
+ break;
+ case 2:
+ puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground.");
+ lifeline += 25;
+ break;
+ }
+ lifeline += 30;
+ }
break;
case BACK:
@@ -207,17 +201,14 @@ fighton:
puts("A victorious bellow echoes from the battlescene.");
if (back && position != back)
moveplayer(back, BACK);
+ else if (ahead && position != ahead)
+ moveplayer(ahead, AHEAD);
+ else if (left && position != left)
+ moveplayer(left, LEFT);
+ else if (right && position != right)
+ moveplayer(right, RIGHT);
else
- if (ahead && position != ahead)
- moveplayer(ahead, AHEAD);
- else
- if (left && position != left)
- moveplayer(left, LEFT);
- else
- if (right && position != right)
- moveplayer(right, RIGHT);
- else
- moveplayer(location[position].down, AHEAD);
+ moveplayer(location[position].down, AHEAD);
return (0);
}
diff --git a/battlestar/getcom.c b/battlestar/getcom.c
index 76e236fb..3f8f1306 100644
--- a/battlestar/getcom.c
+++ b/battlestar/getcom.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getcom.c,v 1.6 1999/02/10 01:36:50 hubertf Exp $ */
+/* $NetBSD: getcom.c,v 1.7 2000/09/17 23:04:17 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: getcom.c,v 1.6 1999/02/10 01:36:50 hubertf Exp $");
+__RCSID("$NetBSD: getcom.c,v 1.7 2000/09/17 23:04:17 jsm Exp $");
#endif
#endif /* not lint */
@@ -84,19 +84,18 @@ getword(buf1, buf2, flag)
return (0);
}
while (*buf1 && !isspace(*buf1) && *buf1 != ',')
- if (flag < 0)
+ if (flag < 0) {
if (isupper(*buf1))
*buf2++ = tolower(*buf1++);
else
*buf2++ = *buf1++;
- else
- if (flag > 0)
- if (islower(*buf1))
- *buf2++ = toupper(*buf1++);
- else
- *buf2++ = *buf1++;
+ } else if (flag > 0) {
+ if (islower(*buf1))
+ *buf2++ = toupper(*buf1++);
else
*buf2++ = *buf1++;
+ } else
+ *buf2++ = *buf1++;
} else
*buf2++ = *buf1++;
*buf2 = 0;