Removed spaces from top-level directory names.

Spaces tend to cause annoyances in a Unix-style shell environment.
This change fixes that.
This commit is contained in:
Chris Reuter
2021-11-21 18:30:21 -05:00
parent df2e7426eb
commit d26dbf036a
1725 changed files with 0 additions and 0 deletions

7
15_Boxing/README.md Normal file
View File

@@ -0,0 +1,7 @@
### Boxing
As published in Basic Computer Games (1978)
https://www.atariarchives.org/basicgames/showpage.php?page=28
Downloaded from Vintage Basic at
http://www.vintage-basic.net/games.html

142
15_Boxing/boxing.bas Normal file
View File

@@ -0,0 +1,142 @@
1 PRINT TAB(33);"BOXING"
2 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
3 PRINT:PRINT:PRINT
4 PRINT "BOXING OLYMPIC STYLE (3 ROUNDS -- 2 OUT OF 3 WINS)"
5 J=0
6 L=0
8 PRINT
10 PRINT "WHAT IS YOUR OPPONENT'S NAME";
20 INPUT J$
30 PRINT "INPUT YOUR MAN'S NAME";
40 INPUT L$
50 PRINT "DIFFERENT PUNCHES ARE: (1) FULL SWING; (2) HOOK; (3) UPPERCUT; (4) JAB."
60 PRINT "WHAT IS YOUR MANS BEST";
64 INPUT B
70 PRINT "WHAT IS HIS VULNERABILITY";
80 INPUT D
90 B1=INT(4*RND(1)+1)
100 D1=INT(4*RND(1)+1)
110 IF B1=D1 THEN 90
120 PRINT J$;"'S ADVANTAGE IS";B1;"AND VULNERABILITY IS SECRET.":PRINT
130 FOR R=1 TO 3
140 IF J>= 2 THEN 1040
150 IF L>=2 THEN 1060
160 X=0
170 Y=0
180 PRINT "ROUND";R;"BEGINS..."
185 FOR R1= 1 TO 7
190 I=INT(10*RND(1)+1)
200 IF I>5 THEN 600
210 PRINT L$;"'S PUNCH";
220 INPUT P
221 IF P=B THEN 225
222 GOTO 230
225 X=X+2
230 IF P=1 THEN 340
240 IF P=2 THEN 450
250 IF P=3 THEN 520
270 PRINT L$;" JABS AT ";J$"'S HEAD ";
271 IF D1=4 THEN 290
275 C=INT(8*RND(1)+1)
280 IF C<4 THEN 310
290 X=X+3
300 GOTO 950
310 PRINT "IT'S BLOCKED."
330 GOTO 950
340 PRINT L$ " SWINGS AND ";
341 IF D1=4 THEN 410
345 X3=INT(30*RND(1)+1)
350 IF X3<10 THEN 410
360 PRINT "HE MISSES ";
370 PRINT
375 IF X=1 THEN 950
380 PRINT
390 PRINT
400 GOTO 300
410 PRINT "HE CONNECTS!"
420 IF X>35 THEN 980
425 X=X+15
440 GOTO 300
450 PRINT L$;" GIVES THE HOOK... ";
455 IF D1=2 THEN 480
460 H1=INT(2*RND(1)+1)
470 IF H1=1 THEN 500
475 PRINT "CONNECTS..."
480 X=X+7
490 GOTO 300
500 PRINT "BUT IT'S BLOCKED!!!!!!!!!!!!!"
510 GOTO 300
520 PRINT L$ " TRIES AN UPPERCUT ";
530 IF D1=3 THEN 570
540 D5=INT(100*RND(1)+1)
550 IF D5<51 THEN 570
560 PRINT "AND IT'S BLOCKED (LUCKY BLOCK!)"
565 GOTO 300
570 PRINT "AND HE CONNECTS!"
580 X=X+4
590 GOTO 300
600 J7=INT(4*RND(1)+1)
601 IF J7 =B1 THEN 605
602 GOTO 610
605 Y=Y+2
610 IF J7=1 THEN 720
620 IF J7=2 THEN 810
630 IF J7 =3 THEN 860
640 PRINT J$;" JABS AND ";
645 IF D=4 THEN 700
650 Z4=INT(7*RND(1)+1)
655 IF Z4>4 THEN 690
660 PRINT "IT'S BLOCKED!"
670 GOTO 300
690 PRINT " BLOOD SPILLS !!!"
700 Y=Y+5
710 GOTO 300
720 PRINT J$" TAKES A FULL SWING AND";
730 IF D=1 THEN 770
740 R6=INT(60*RND(1)+1)
745 IF R6 <30 THEN 770
750 PRINT " IT'S BLOCKED!"
760 GOTO 300
770 PRINT " POW!!!!! HE HITS HIM RIGHT IN THE FACE!"
780 IF Y>35 THEN 1010
790 Y=Y+15
800 GOTO 300
810 PRINT J$;" GETS ";L$;" IN THE JAW (OUCH!)"
820 Y=Y+7
830 PRINT "....AND AGAIN!"
835 Y=Y+5
840 IF Y>35 THEN 1010
850 PRINT
860 PRINT L$;" IS ATTACKED BY AN UPPERCUT (OH,OH)..."
865 IF D=3 THEN 890
870 Q4=INT(200*RND(1)+1)
880 IF Q4>75 THEN 920
890 PRINT "AND ";J$;" CONNECTS..."
900 Y=Y+8
910 GOTO 300
920 PRINT " BLOCKS AND HITS ";J$;" WITH A HOOK."
930 X=X+5
940 GOTO 300
950 NEXT R1
951 IF X>Y THEN 955
952 PRINT:PRINT J$" WINS ROUND" R
953 J=J+1
954 GOTO 960
955 PRINT:PRINT L$" WINS ROUND"R
956 L=L+1
960 NEXT R
961 IF J>= 2 THEN 1040
962 IF L>=2 THEN 1060
980 PRINT J$ " IS KNOCKED COLD AND " L$" IS THE WINNER AND CHAMP!";
1000 GOTO 1080
1010 PRINT L$ " IS KNOCKED COLD AND " J$" IS THE WINNER AND CHAMP!";
1030 GOTO 1000
1040 PRINT J$ " WINS (NICE GOING," J$;")."
1050 GOTO 1000
1060 PRINT L$ " AMAZINGLY WINS!!"
1070 GOTO 1000
1080 PRINT
1085 PRINT
1090 PRINT "AND NOW GOODBYE FROM THE OLYMPIC ARENA."
1100 PRINT
1110 END

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Microsoft C#](https://docs.microsoft.com/en-us/dotnet/csharp/)

45
15_Boxing/java/Basic.java Normal file
View File

@@ -0,0 +1,45 @@
import java.util.Scanner;
/**
* It provide some kind of BASIC language behaviour simulations.
*/
final class Basic {
public static int randomOf(int base) {
return (int)Math.round(Math.floor(base* Math.random() + 1));
}
/**
* The Console "simulate" the message error when input does not match with the expected type.
* Specifically for this game if you enter an String when and int was expected.
*/
public static class Console {
private final Scanner input = new Scanner(System.in);
public String readLine() {
return input.nextLine();
}
public int readInt() {
int ret = -1;
boolean failedInput = true;
do {
boolean b = input.hasNextInt();
if (b) {
ret = input.nextInt();
failedInput = false;
} else {
input.next(); // discard read
System.out.print("!NUMBER EXPECTED - RETRY INPUT LINE\n? ");
}
} while (failedInput);
return ret;
}
public void print(String message, Object... args) {
System.out.printf(message, args);
}
}
}

227
15_Boxing/java/Boxing.java Normal file
View File

@@ -0,0 +1,227 @@
/**
* Boxing
*
* <p>
* Based on the Basic game of BatNum here
* https://github.com/coding-horror/basic-computer-games/tree/main/15%20Boxing
* <p>
*/
public class Boxing {
private static final Basic.Console console = new Basic.Console();
private GameSession session;
public void play() {
showIntro();
loadPlayers();
console.print("%s'S ADVANTAGE IS %d AND VULNERABILITY IS SECRET.\n", session.getOpponent().getName(), session.getOpponent().getBestPunch().getCode());
for (int roundNro = 1; roundNro <= 3; roundNro++) {
if (session.isOver())
break;
session.resetPoints();
console.print("\nROUND %d BEGINS...%n", roundNro);
for (int majorPunches = 1; majorPunches <= 7; majorPunches++) {
long i = Basic.randomOf(10);
if (i > 5) {
boolean stopPunches = opponentPunch();
if (stopPunches ) break;
} else {
playerPunch();
}
}
showRoundWinner(roundNro);
}
showWinner();
}
private boolean opponentPunch() {
final Punch punch = Punch.random();
if (punch == session.getOpponent().getBestPunch()) session.addOpponentPoints(2);
if (punch == Punch.FULL_SWING) {
console.print("%s TAKES A FULL SWING AND", session.getOpponent().getName());
long r6 = Basic.randomOf(60);
if (session.getPlayer().hitVulnerability(Punch.FULL_SWING) || r6 < 30) {
console.print(" POW!!!!! HE HITS HIM RIGHT IN THE FACE!\n");
if (session.getPoints(session.getOpponent()) > 35) {
session.setKnocked();
return true;
}
session.addOpponentPoints(15);
} else {
console.print(" IT'S BLOCKED!\n");
}
}
if (punch == Punch.HOOK || punch == Punch.UPPERCUT) {
if (punch == Punch.HOOK) {
console.print("%s GETS %s IN THE JAW (OUCH!)\n", session.getOpponent().getName(), session.getPlayer().getName());
session.addOpponentPoints(7);
console.print("....AND AGAIN!\n");
session.addOpponentPoints(5);
if (session.getPoints(session.getOpponent()) > 35) {
session.setKnocked();
return true;
}
console.print("\n");
}
console.print("%s IS ATTACKED BY AN UPPERCUT (OH,OH)...\n", session.getPlayer().getName());
long q4 = Basic.randomOf(200);
if (session.getPlayer().hitVulnerability(Punch.UPPERCUT) || q4 <= 75) {
console.print("AND %s CONNECTS...\n", session.getOpponent().getName());
session.addOpponentPoints(8);
} else {
console.print(" BLOCKS AND HITS %s WITH A HOOK.\n", session.getOpponent().getName());
session.addPlayerPoints(5);
}
}
else {
console.print("%s JABS AND ", session.getOpponent().getName());
long z4 = Basic.randomOf(7);
if (session.getPlayer().hitVulnerability(Punch.JAB))
session.addOpponentPoints(5);
else if (z4 > 4) {
console.print(" BLOOD SPILLS !!!\n");
session.addOpponentPoints(5);
} else {
console.print("IT'S BLOCKED!\n");
}
}
return true;
}
private void playerPunch() {
console.print("%s'S PUNCH? ", session.getPlayer().getName());
final Punch punch = Punch.fromCode(console.readInt());
if (punch == session.getPlayer().getBestPunch()) session.addPlayerPoints(2);
switch (punch) {
case FULL_SWING -> {
console.print("%s SWINGS AND ", session.getPlayer().getName());
if (session.getOpponent().getBestPunch() == Punch.JAB) {
console.print("HE CONNECTS!\n");
if (session.getPoints(session.getPlayer()) <= 35) session.addPlayerPoints(15);
} else {
long x3 = Basic.randomOf(30);
if (x3 < 10) {
console.print("HE CONNECTS!\n");
if (session.getPoints(session.getPlayer()) <= 35) session.addPlayerPoints(15);
} else {
console.print("HE MISSES \n");
if (session.getPoints(session.getPlayer()) != 1) console.print("\n\n");
}
}
}
case HOOK -> {
console.print("\n%s GIVES THE HOOK... ", session.getPlayer().getName());
long h1 = Basic.randomOf(2);
if (session.getOpponent().getBestPunch() == Punch.HOOK) {
session.addPlayerPoints(7);
} else if (h1 == 1) {
console.print("BUT IT'S BLOCKED!!!!!!!!!!!!!\n");
} else {
console.print("CONNECTS...\n");
session.addPlayerPoints(7);
}
}
case UPPERCUT -> {
console.print("\n%s TRIES AN UPPERCUT ", session.getPlayer().getName());
long d5 = Basic.randomOf(100);
if (session.getOpponent().getBestPunch() == Punch.UPPERCUT || d5 < 51) {
console.print("AND HE CONNECTS!\n");
session.addPlayerPoints(4);
} else {
console.print("AND IT'S BLOCKED (LUCKY BLOCK!)\n");
}
}
default -> {
console.print("%s JABS AT %s'S HEAD \n", session.getPlayer().getName(), session.getOpponent().getName());
if (session.getOpponent().getBestPunch() == Punch.JAB) {
session.addPlayerPoints(3);
} else {
long c = Basic.randomOf(8);
if (c < 4) {
console.print("IT'S BLOCKED.\n");
} else {
session.addPlayerPoints(3);
}
}
}
}
}
private void showRoundWinner(int roundNro) {
if (session.isRoundWinner(session.getPlayer())) {
console.print("\n %s WINS ROUND %d\n", session.getPlayer().getName(), roundNro);
session.addRoundWind(session.getPlayer());
} else {
console.print("\n %s WINS ROUND %d\n", session.getOpponent().getName(), roundNro);
session.addRoundWind(session.getOpponent());
}
}
private void showWinner() {
if (session.isGameWinner(session.getOpponent())) {
console.print("%s WINS (NICE GOING, " + session.getOpponent().getName() + ").", session.getOpponent().getName());
} else if (session.isGameWinner(session.getPlayer())) {
console.print("%s AMAZINGLY WINS!!", session.getPlayer().getName());
} else if (session.isPlayerKnocked()) {
console.print("%s IS KNOCKED COLD AND %s IS THE WINNER AND CHAMP!", session.getPlayer().getName(), session.getOpponent().getName());
} else {
console.print("%s IS KNOCKED COLD AND %s IS THE WINNER AND CHAMP!", session.getOpponent().getName(), session.getPlayer().getName());
}
console.print("\n\nAND NOW GOODBYE FROM THE OLYMPIC ARENA.\n");
}
private void loadPlayers() {
console.print("WHAT IS YOUR OPPONENT'S NAME? ");
final String opponentName = console.readLine();
console.print("INPUT YOUR MAN'S NAME? ");
final String playerName = console.readLine();
console.print("DIFFERENT PUNCHES ARE: (1) FULL SWING; (2) HOOK; (3) UPPERCUT; (4) JAB.\n");
console.print("WHAT IS YOUR MANS BEST? ");
final int b = console.readInt();
console.print("WHAT IS HIS VULNERABILITY? ");
final int d = console.readInt();
final Player player = new Player(playerName, Punch.fromCode(b), Punch.fromCode(d));
final Player opponent = new Player(opponentName);
session = new GameSession(player, opponent);
}
private void showIntro () {
console.print(" BOXING\n");
console.print(" CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n\n\n");
console.print("BOXING OLYMPIC STYLE (3 ROUNDS -- 2 OUT OF 3 WINS)\n\n");
}
}

View File

@@ -0,0 +1,6 @@
public class BoxingGame {
public static void main(String[] args) {
new Boxing().play();
}
}

View File

@@ -0,0 +1,67 @@
/**
* Game Session
* The session store the state of the game
*/
public class GameSession {
private final Player player;
private final Player opponent;
private int opponentRoundWins = 0;
private int playerRoundWins = 0;
int playerPoints = 0;
int opponentPoints = 0;
boolean knocked = false;
GameSession(Player player, Player opponent) {
this.player = player;
this.opponent = opponent;
}
public Player getPlayer() { return player;}
public Player getOpponent() { return opponent;}
public void setKnocked() {
knocked = true;
}
public void resetPoints() {
playerPoints = 0;
opponentPoints = 0;
}
public void addPlayerPoints(int ptos) { playerPoints+=ptos;}
public void addOpponentPoints(int ptos) { opponentPoints+=ptos;}
public int getPoints(Player player) {
if(player.isPlayer())
return playerPoints;
else
return opponentPoints;
}
public void addRoundWind(Player player) {
if(player.isPlayer()) playerRoundWins++; else opponentRoundWins++;
}
public boolean isOver() {
return (opponentRoundWins >= 2 || playerRoundWins >= 2);
}
public boolean isRoundWinner(Player player) {
if (player.isPlayer())
return playerPoints > opponentPoints;
else
return opponentPoints > playerPoints;
}
public boolean isGameWinner(Player player) {
if (player.isPlayer())
return playerRoundWins > 2;
else
return opponentRoundWins > 2;
}
public boolean isPlayerKnocked() {
return knocked;
}
}

View File

@@ -0,0 +1,42 @@
/**
* The Player class model the user and compuer player
*/
public class Player {
private final String name;
private final Punch bestPunch;
private final Punch vulnerability;
private boolean isPlayer = false;
public Player(String name, Punch bestPunch, Punch vulnerability) {
this.name = name;
this.bestPunch = bestPunch;
this.vulnerability = vulnerability;
this.isPlayer = true;
}
/**
* Player with random Best Punch and Vulnerability
*/
public Player(String name) {
this.name = name;
int b1;
int d1;
do {
b1 = Basic.randomOf(4);
d1 = Basic.randomOf(4);
} while (b1 == d1);
this.bestPunch = Punch.fromCode(b1);
this.vulnerability = Punch.fromCode(d1);
}
public boolean isPlayer() { return isPlayer; }
public String getName() { return name; }
public Punch getBestPunch() { return bestPunch; }
public boolean hitVulnerability(Punch punch) {
return vulnerability == punch;
}
}

27
15_Boxing/java/Punch.java Normal file
View File

@@ -0,0 +1,27 @@
import java.util.Arrays;
/**
* Types of Punches
*/
public enum Punch {
FULL_SWING(1),
HOOK(2),
UPPERCUT(3),
JAB(4);
private final int code;
Punch(int code) {
this.code = code;
}
int getCode() { return code;}
public static Punch fromCode(int code) {
return Arrays.stream(Punch.values()).filter(p->p.code == code).findAny().orElse(null);
}
public static Punch random() {
return Punch.fromCode(Basic.randomOf(4));
}
}

3
15_Boxing/java/README.md Normal file
View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Oracle Java](https://openjdk.java.net/)

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Shells)

View File

@@ -0,0 +1,9 @@
<html>
<head>
<title>BOXING</title>
</head>
<body>
<pre id="output" style="font-size: 12pt;"></pre>
<script src="boxing.js"></script>
</body>
</html>

View File

@@ -0,0 +1,212 @@
// BOWLING
//
// Converted from BASIC to Javascript by Oscar Toledo G. (nanochess)
//
function print(str)
{
document.getElementById("output").appendChild(document.createTextNode(str));
}
function input()
{
var input_element;
var input_str;
return new Promise(function (resolve) {
input_element = document.createElement("INPUT");
print("? ");
input_element.setAttribute("type", "text");
input_element.setAttribute("length", "50");
document.getElementById("output").appendChild(input_element);
input_element.focus();
input_str = undefined;
input_element.addEventListener("keydown", function (event) {
if (event.keyCode == 13) {
input_str = input_element.value;
document.getElementById("output").removeChild(input_element);
print(input_str);
print("\n");
resolve(input_str);
}
});
});
}
function tab(space)
{
var str = "";
while (space-- > 0)
str += " ";
return str;
}
// Main program
async function main()
{
print(tab(33) + "BOXING\n");
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
print("\n");
print("\n");
print("\n");
print("BOXING OLYMPIC STYLE (3 ROUNDS -- 2 OUT OF 3 WINS)\n");
j = 0;
l = 0;
print("\n");
print("WHAT IS YOUR OPPONENT'S NAME");
js = await input();
print("INPUT YOUR MAN'S NAME");
ls = await input();
print("DIFFERENT PUNCHES ARE: (1) FULL SWING; (2) HOOK; (3) UPPERCUT; (4) JAB.\n");
print("WHAT IS YOUR MANS BEST");
b = parseInt(await input());
print("WHAT IS HIS VULNERABILITY");
d = parseInt(await input());
do {
b1 = Math.floor(4 * Math.random() + 1);
d1 = Math.floor(4 * Math.random() + 1);
} while (b1 == d1) ;
print(js + "'S ADVANTAGE IS " + b1 + " AND VULNERABILITY IS SECRET.\n");
print("\n");
knocked = 0;
for (r = 1; r <= 3; r++) {
if (j >= 2)
break;
if (l >= 2)
break;
x = 0;
y = 0;
print("ROUND " + r + " BEGIN...\n");
for (r1 = 1; r1 <= 7; r1++) {
i = Math.floor(10 * Math.random() + 1);
if (i <= 5) {
print(ls + "'S PUNCH");
p = parseInt(await input());
if (p == b)
x += 2;
if (p == 1) {
print(ls + " SWINGS AND ");
x3 = Math.floor(30 * Math.random() + 1);
if (d1 == 4 || x3 < 10) {
print("HE CONNECTS!\n");
if (x > 35) {
r = 3;
break;
}
x += 15;
} else {
print("HE MISSES \n");
if (x != 1)
print("\n\n");
}
} else if (p == 2) {
print(ls + " GIVES THE HOOK... ");
h1 = Math.floor(2 * Math.random() + 1);
if (d1 == 2) {
x += 7;
} else if (h1 != 1) {
print("CONNECTS...\n");
x += 7;
} else {
print("BUT IT'S BLOCKED!!!!!!!!!!!!!\n");
}
} else if (p == 3) {
print(ls + " TRIES AN UPPERCUT ");
d5 = Math.floor(100 * Math.random() + 1);
if (d1 == 3 || d5 < 51) {
print("AND HE CONNECTS!\n");
x += 4;
} else {
print("AND IT'S BLOCKED (LUCKY BLOCK!)\n");
}
} else {
print(ls + " JABS AT " + js + "'S HEAD ");
c = Math.floor(8 * Math.random() + 1);
if (d1 == 4 || c >= 4) {
x += 3;
} else {
print("IT'S BLOCKED.\n");
}
}
} else {
j7 = Math.random(4 * Math.random() + 1);
if (j7 == b1)
y += 2;
if (j7 == 1) {
print(js + " TAKES A FULL SWING AND");
r6 = Math.floor(60 * Math.random() + 1);
if (d == 1 || r6 < 30) {
print(" POW!!!!! HE HITS HIM RIGHT IN THE FACE!\n");
if (y > 35) {
knocked = 1;
r = 3;
break;
}
y += 15;
} else {
print(" IT'S BLOCKED!\n");
}
} else if (j7 == 2 || j7 == 3) {
if (j7 == 2) {
print(js + " GETS " + ls + " IN THE JAW (OUCH!)\n");
y += 7;
print("....AND AGAIN!\n");
y += 5;
if (y > 35) {
knocked = 1;
r = 3;
break;
}
print("\n");
// From original, it goes over from handling 2 to handling 3
}
print(ls + " IS ATTACKED BY AN UPPERCUT (OH,OH)...\n");
q4 = Math.floor(200 * Math.random() + 1);
if (d == 3 || q4 <= 75) {
print("AND " + js + " CONNECTS...\n");
y += 8;
} else {
print(" BLOCKS AND HITS " + js + " WITH A HOOK.\n");
x += 5;
}
} else {
print(js + " JABS AND ");
z4 = Math.floor(7 * Math.random() + 1);
if (d == 4)
y += 5;
else if (z4 > 4) {
print(" BLOOD SPILLS !!!\n");
y += 5;
} else {
print("IT'S BLOCKED!\n");
}
}
}
}
if (x > y) {
print("\n");
print(ls + " WINS ROUND " + r + "\n");
l++;
} else {
print("\n");
print(js + " WINS ROUND " + r + "\n");
j++;
}
}
if (j >= 2) {
print(js + " WINS (NICE GOING, " + js + ").\n");
} else if (l >= 2) {
print(ls + " AMAZINGLY WINS!!\n");
} else if (knocked) {
print(ls + " IS KNOCKED COLD AND " + js + " IS THE WINNER AND CHAMP!\n");
} else {
print(js + " IS KNOCKED COLD AND " + ls + " IS THE WINNER AND CHAMP!\n");
}
print("\n");
print("\n");
print("AND NOW GOODBYE FROM THE OLYMPIC ARENA.\n");
print("\n");
}
main();

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))

3
15_Boxing/perl/README.md Normal file
View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Perl](https://www.perl.org/)

View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Python](https://www.python.org/about/)

148
15_Boxing/python/boxing.py Executable file
View File

@@ -0,0 +1,148 @@
#!/usr/bin/env python3
import random
QUESTION_PROMPT = '? '
def play():
print('BOXING')
print('CREATIVE COMPUTING MORRISTOWN, NEW JERSEY')
print('\n\n')
print('BOXING OLYMPIC STYLE (3 ROUNDS -- 2 OUT OF 3 WINS)')
opponent_score = 0
player_score = 0
opponent_damage = 0
player_damage = 0
opponent_knockedout = False
player_knockedout = False
print('WHAT IS YOUR OPPONENT\'S NAME', end=QUESTION_PROMPT)
opponent_name = input()
print('WHAT IS YOUR MAN\'S NAME', end=QUESTION_PROMPT)
player_name = input()
print('DIFFERENT PUNCHES ARE 1 FULL SWING 2 HOOK 3 UPPERCUT 4 JAB')
print('WHAT IS YOUR MAN\'S BEST', end=QUESTION_PROMPT)
player_best = int(input())
print('WHAT IS HIS VULNERABILITY', end=QUESTION_PROMPT)
player_weakness = int(input())
opponent_best = 0
opponent_weakness = 0
while opponent_best == opponent_weakness:
opponent_best = random.randint(1, 4)
opponent_weakness = random.randint(1, 4)
print('{}\'S ADVANTAGE is {} AND VULNERABILITY IS SECRET.'
.format(opponent_name, opponent_weakness))
for round in (1, 2, 3):
print('ROUND {} BEGINS...\n'.format(round))
if opponent_score >= 2 or player_score >= 2:
break
for action in range(7):
if random.randint(1, 10) > 5:
# opponent swings
punch = random.randint(1, 4)
if punch == player_weakness:
player_damage += 2
if punch == 1:
print('{} TAKES A FULL SWING AND'.format(opponent_name), end = ' ')
if player_weakness == 1 or random.randint(1, 60) < 30:
print('POW!!!! HE HITS HIM RIGHT IN THE FACE!')
if player_damage > 35:
player_knockedout = True
break
player_damage += 15
else:
print('BUT IT\'S BLOCKED!')
elif punch == 2:
print('{} GETS {} IN THE JAW (OUCH!)'.format(opponent_name, player_name), end = ' ')
player_damage += 7
print('....AND AGAIN')
if player_damage > 35:
player_knockedout = True
break
player_damage += 5
elif punch == 3:
print('{} IS ATTACKED BY AN UPPERCUT (OH,OH)'.format(player_name))
if player_weakness == 3 or random.randint(1, 200) > 75:
print('{} BLOCKS AND HITS {} WITH A HOOK'.format(player_name, opponent_name))
opponent_damage += 5
else:
print('AND {} CONNECTS...'.format(opponent_name))
player_damage += 8
else:
print('{} JABS AND'.format(opponent_name), end = ' ')
if player_weakness == 4 or random.randint(1, 7) > 4:
print('BLOOD SPILLS !!!')
player_damage += 3
else:
print('AND IT\'S BLOCKED (LUCKY BLOCK!)')
else:
print('{}\'S PUNCH'.format(player_name), end='? ')
punch = int(input())
if punch == opponent_weakness:
opponent_damage += 2
if punch == 1:
print('{} SWINGS AND'.format(player_name), end = ' ')
if opponent_weakness == 1 or random.randint(1, 30) < 10:
print('HE CONNECTS!')
if opponent_damage > 35:
opponent_knockedout = True
break
opponent_damage += 15
else:
print('HE MISSES')
elif punch == 2:
print('{} GIVES THE HOOK...'.format(player_name), end = ' ')
if opponent_weakness == 2 or random.randint(1, 2) == 1:
print('CONNECTS...')
opponent_damage += 7
else:
print('BUT IT\'S BLOCKED!!!!!!!!!!!!!')
elif punch == 3:
print('{} TRIES AN UPPERCUT'.format(player_name), end = ' ')
if opponent_weakness == 3 or random.randint(1, 100) < 51:
print('AND HE CONNECTS!')
opponent_damage += 4
else:
print('AND IT\'S BLOCKED (LUCKY BLOCK!)')
else:
print('{} JABS AT {}\'S HEAD'.format(player_name, opponent_name), end = ' ')
if opponent_weakness == 4 or random.randint(1, 8) < 4:
print('AND HE CONNECTS!')
opponent_damage += 3
else:
print('AND IT\'S BLOCKED (LUCKY BLOCK!)')
if player_knockedout or opponent_knockedout:
break
elif player_damage > opponent_damage:
print('{} WINS ROUND {}'.format(opponent_name, round))
opponent_score += 1
else:
print('{} WINS ROUND {}'.format(player_name, round))
player_score += 1
if player_knockedout:
print('{} IS KNOCKED COLD AND {} IS THE WINNER AND CHAMP'.format(player_name, opponent_name))
elif opponent_knockedout:
print('{} IS KNOCKED COLD AND {} IS THE WINNER AND CHAMP'.format(opponent_name, player_name))
elif opponent_score > player_score:
print('{} WINS (NICE GOING), {}'.format(opponent_name, player_name))
else:
print('{} AMAZINGLY WINS'.format(player_name))
print('\n\nAND NOW GOODBYE FROM THE OLYMPIC ARENA.')
if __name__ == '__main__':
play()

3
15_Boxing/ruby/README.md Normal file
View File

@@ -0,0 +1,3 @@
Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Ruby](https://www.ruby-lang.org/en/)

View File

@@ -0,0 +1,3 @@
Original BASIC source [downloaded from Vintage Basic](http://www.vintage-basic.net/games.html)
Conversion to [Visual Basic .NET](https://en.wikipedia.org/wiki/Visual_Basic_.NET)