mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-04 00:57:13 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -5,19 +5,18 @@ Conversion to [ANSI-C](https://en.wikipedia.org/wiki/ANSI_C)
|
||||
##### Translator Notes:
|
||||
I tried to preserve as much of the original layout and flow of the code
|
||||
as possible. However I did use enumerated types for the Fort numbers
|
||||
and Fur types. I think this was certainly a change for the better, and
|
||||
and Fur types. I think this was certainly a change for the better, and
|
||||
makes the code much easier to read.
|
||||
|
||||
I also tried to minimise the use of pointers, and stuck with old-school
|
||||
I also tried to minimise the use of pointers, and stuck with old-school
|
||||
C formatting, because you never know how old the compiler is.
|
||||
|
||||
Interestingly the code seems to have a bug around the prices of Fox Furs.
|
||||
The commodity-rate for these is stored in the variable `D1`, however some
|
||||
paths through the code do not set this price. So there was a chance of
|
||||
using this uninitialised, or whatever the previous loop set. I don't
|
||||
paths through the code do not set this price. So there was a chance of
|
||||
using this uninitialised, or whatever the previous loop set. I don't
|
||||
think this was the original authors intent. So I preserved the original flow
|
||||
of the code (using the previous `D1` value), but also catching the
|
||||
of the code (using the previous `D1` value), but also catching the
|
||||
uninitialised path, and assigning a "best guess" value.
|
||||
|
||||
krt@krt.com.au 2020-10-10
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace FurTrader
|
||||
private void PlayTurn(GameState state)
|
||||
{
|
||||
state.UnasignedFurCount = 190; /// start with 190 furs each turn
|
||||
|
||||
|
||||
// provide current status to user
|
||||
Console.WriteLine(new string('_', 70));
|
||||
Console.WriteLine("");
|
||||
@@ -134,7 +134,7 @@ namespace FurTrader
|
||||
state.UnasignedFurCount -= state.MinkPelts;
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine($"You have {state.UnasignedFurCount} furs remaining for distribution");
|
||||
Console.WriteLine($"You have {state.UnasignedFurCount} furs remaining for distribution");
|
||||
Console.Write("How many Beaver pelts do you have? ");
|
||||
state.BeaverPelts = GetPelts(state.UnasignedFurCount);
|
||||
state.UnasignedFurCount -= state.BeaverPelts;
|
||||
@@ -149,7 +149,7 @@ namespace FurTrader
|
||||
Console.WriteLine($"You have {state.UnasignedFurCount} furs remaining for distribution");
|
||||
Console.Write("How many Fox pelts do you have? ");
|
||||
state.FoxPelts = GetPelts(state.UnasignedFurCount);
|
||||
state.UnasignedFurCount -= state.FoxPelts;
|
||||
state.UnasignedFurCount -= state.FoxPelts;
|
||||
|
||||
// get input on which fort to trade with; user gets an opportunity to evaluate and re-select fort after selection until user confirms selection
|
||||
do
|
||||
@@ -273,7 +273,7 @@ namespace FurTrader
|
||||
beaverPrice = RandomPriceGenerator(0.2d , 1.00d);
|
||||
foxPrice = RandomPriceGenerator(0.25d, 1.10d);
|
||||
erminePrice = RandomPriceGenerator(0.2d , 0.95d);
|
||||
minkPrice = RandomPriceGenerator(0.15d, 1.05d);
|
||||
minkPrice = RandomPriceGenerator(0.15d, 1.05d);
|
||||
fortname = "Fort New York";
|
||||
suppliesCost = 80.0d;
|
||||
travelExpenses = 25.0d;
|
||||
@@ -418,7 +418,7 @@ namespace FurTrader
|
||||
private int GetPelts(int furCount)
|
||||
{
|
||||
int peltCount;
|
||||
|
||||
|
||||
// loop until the user enters a valid value
|
||||
do
|
||||
{
|
||||
@@ -432,7 +432,7 @@ namespace FurTrader
|
||||
// invalid entry; message back to user
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Sorry, I didn't understand. Please enter the number of pelts.");
|
||||
|
||||
|
||||
// continue looping
|
||||
continue;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ namespace FurTrader
|
||||
// too many pelts selected
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"You may not have that many furs. Do not try to cheat. I can add.");
|
||||
|
||||
|
||||
// continue looping
|
||||
continue;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ namespace FurTrader
|
||||
// no, invalid data
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Sorry, I didn't understand. Please answer 1, 2, or 3.");
|
||||
|
||||
|
||||
// continue looping
|
||||
continue;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ namespace FurTrader
|
||||
// no, invalid for selected
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"Please answer 1, 2, or 3.");
|
||||
|
||||
|
||||
// continue looping
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace FurTrader
|
||||
{
|
||||
internal bool GameOver { get; set; }
|
||||
|
||||
internal double Savings { get; set; }
|
||||
internal double Savings { get; set; }
|
||||
|
||||
internal int ExpeditionCount { get; set; }
|
||||
internal int ExpeditionCount { get; set; }
|
||||
|
||||
internal int UnasignedFurCount { get; set; }
|
||||
internal int UnasignedFurCount { get; set; }
|
||||
|
||||
internal int[] Pelts { get; private set; }
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
1 DIM F(4)
|
||||
1 DIM F(4)
|
||||
2 PRINT TAB(31);"FUR TRADER"
|
||||
4 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
6 PRINT: PRINT: PRINT
|
||||
15 GOSUB 1091
|
||||
15 GOSUB 1091
|
||||
16 LET I=600
|
||||
17 PRINT "DO YOU WISH TO TRADE FURS?"
|
||||
18 GOSUB 1402
|
||||
18 GOSUB 1402
|
||||
19 IF B$="YES" THEN 100
|
||||
20 IF B$="YES " THEN 100
|
||||
21 STOP
|
||||
@@ -17,66 +17,66 @@
|
||||
300 PRINT
|
||||
301 PRINT "YOUR 190 FURS ARE DISTRIBUTED AMONG THE FOLLOWING"
|
||||
302 PRINT "KINDS OF PELTS: MINK, BEAVER, ERMINE AND FOX."
|
||||
310 GOSUB 1430
|
||||
310 GOSUB 1430
|
||||
315 RESTORE
|
||||
330 FOR J=1 TO 4
|
||||
330 FOR J=1 TO 4
|
||||
332 READ B$
|
||||
333 PRINT
|
||||
335 PRINT "HOW MANY ";B$;" PELTS DO YOU HAVE";
|
||||
338 INPUT F(J)
|
||||
340 LET F(0)=F(1)+F(2)+F(3)+F(4)
|
||||
333 PRINT
|
||||
335 PRINT "HOW MANY ";B$;" PELTS DO YOU HAVE";
|
||||
338 INPUT F(J)
|
||||
340 LET F(0)=F(1)+F(2)+F(3)+F(4)
|
||||
342 IF F(0)=190 THEN 1100
|
||||
344 IF F(0)>190 THEN 500
|
||||
348 NEXT J
|
||||
350 GOTO 1100
|
||||
344 IF F(0)>190 THEN 500
|
||||
348 NEXT J
|
||||
350 GOTO 1100
|
||||
500 PRINT
|
||||
501 PRINT "YOU MAY NOT HAVE THAT MANY FURS."
|
||||
502 PRINT "DO NOT TRY TO CHEAT. I CAN ADD."
|
||||
501 PRINT "YOU MAY NOT HAVE THAT MANY FURS."
|
||||
502 PRINT "DO NOT TRY TO CHEAT. I CAN ADD."
|
||||
503 PRINT "YOU MUST START AGAIN."
|
||||
504 GOTO 15
|
||||
504 GOTO 15
|
||||
508 PRINT
|
||||
511 PRINT "DO YOU WANT TO TRADE FURS NEXT YEAR?"
|
||||
513 GOTO 18
|
||||
513 GOTO 18
|
||||
1091 PRINT "YOU ARE THE LEADER OF A FRENCH FUR TRADING EXPEDITION IN "
|
||||
1092 PRINT "1776 LEAVING THE LAKE ONTARIO AREA TO SELL FURS AND GET"
|
||||
1092 PRINT "1776 LEAVING THE LAKE ONTARIO AREA TO SELL FURS AND GET"
|
||||
1093 PRINT "SUPPLIES FOR THE NEXT YEAR. YOU HAVE A CHOICE OF THREE"
|
||||
1094 PRINT "FORTS AT WHICH YOU MAY TRADE. THE COST OF SUPPLIES"
|
||||
1095 PRINT "AND THE AMOUNT YOU RECEIVE FOR YOUR FURS WILL DEPEND"
|
||||
1096 PRINT "ON THE FORT THAT YOU CHOOSE."
|
||||
1099 RETURN
|
||||
1095 PRINT "AND THE AMOUNT YOU RECEIVE FOR YOUR FURS WILL DEPEND"
|
||||
1096 PRINT "ON THE FORT THAT YOU CHOOSE."
|
||||
1099 RETURN
|
||||
1100 PRINT "YOU MAY TRADE YOUR FURS AT FORT 1, FORT 2,"
|
||||
1102 PRINT "OR FORT 3. FORT 1 IS FORT HOCHELAGA (MONTREAL)"
|
||||
1103 PRINT "AND IS UNDER THE PROTECTION OF THE FRENCH ARMY."
|
||||
1104 PRINT "FORT 2 IS FORT STADACONA (QUEBEC) AND IS UNDER THE"
|
||||
1103 PRINT "AND IS UNDER THE PROTECTION OF THE FRENCH ARMY."
|
||||
1104 PRINT "FORT 2 IS FORT STADACONA (QUEBEC) AND IS UNDER THE"
|
||||
1105 PRINT "PROTECTION OF THE FRENCH ARMY. HOWEVER, YOU MUST"
|
||||
1106 PRINT "MAKE A PORTAGE AND CROSS THE LACHINE RAPIDS."
|
||||
1108 PRINT "FORT 3 IS FORT NEW YORK AND IS UNDER DUTCH CONTROL."
|
||||
1106 PRINT "MAKE A PORTAGE AND CROSS THE LACHINE RAPIDS."
|
||||
1108 PRINT "FORT 3 IS FORT NEW YORK AND IS UNDER DUTCH CONTROL."
|
||||
1109 PRINT "YOU MUST CROSS THROUGH IROQUOIS LAND."
|
||||
1110 PRINT "ANSWER 1, 2, OR 3."
|
||||
1111 INPUT B
|
||||
1112 IF B=1 THEN 1120
|
||||
1113 IF B=2 THEN 1135
|
||||
1115 IF B=3 THEN 1147
|
||||
1116 GOTO 1110
|
||||
1120 PRINT "YOU HAVE CHOSEN THE EASIEST ROUTE. HOWEVER, THE FORT"
|
||||
1121 PRINT "IS FAR FROM ANY SEAPORT. THE VALUE"
|
||||
1122 PRINT "YOU RECEIVE FOR YOUR FURS WILL BE LOW AND THE COST"
|
||||
1112 IF B=1 THEN 1120
|
||||
1113 IF B=2 THEN 1135
|
||||
1115 IF B=3 THEN 1147
|
||||
1116 GOTO 1110
|
||||
1120 PRINT "YOU HAVE CHOSEN THE EASIEST ROUTE. HOWEVER, THE FORT"
|
||||
1121 PRINT "IS FAR FROM ANY SEAPORT. THE VALUE"
|
||||
1122 PRINT "YOU RECEIVE FOR YOUR FURS WILL BE LOW AND THE COST"
|
||||
1123 PRINT "OF SUPPLIES HIGHER THAN AT FORTS STADACONA OR NEW YORK."
|
||||
1125 GOSUB 1400
|
||||
1125 GOSUB 1400
|
||||
1129 IF B$="YES" THEN 1110
|
||||
1130 GOTO 1160
|
||||
1135 PRINT "YOU HAVE CHOSEN A HARD ROUTE. IT IS, IN COMPARSION,"
|
||||
1136 PRINT "HARDER THAN THE ROUTE TO HOCHELAGA BUT EASIER THAN"
|
||||
1135 PRINT "YOU HAVE CHOSEN A HARD ROUTE. IT IS, IN COMPARSION,"
|
||||
1136 PRINT "HARDER THAN THE ROUTE TO HOCHELAGA BUT EASIER THAN"
|
||||
1137 PRINT "THE ROUTE TO NEW YORK. YOU WILL RECEIVE AN AVERAGE VALUE"
|
||||
1138 PRINT "FOR YOUR FURS AND THE COST OF YOUR SUPPLIES WILL BE AVERAGE."
|
||||
1141 GOSUB 1400
|
||||
1141 GOSUB 1400
|
||||
1144 IF B$="YES" THEN 1110
|
||||
1145 GOTO 1198
|
||||
1147 PRINT "YOU HAVE CHOSEN THE MOST DIFFICULT ROUTE. AT"
|
||||
1148 PRINT "FORT NEW YORK YOU WILL RECEIVE THE HIGHEST VALUE"
|
||||
1148 PRINT "FORT NEW YORK YOU WILL RECEIVE THE HIGHEST VALUE"
|
||||
1149 PRINT "FOR YOUR FURS. THE COST OF YOUR SUPPLIES"
|
||||
1150 PRINT "WILL BE LOWER THAN AT ALL THE OTHER FORTS."
|
||||
1152 GOSUB 1400
|
||||
1150 PRINT "WILL BE LOWER THAN AT ALL THE OTHER FORTS."
|
||||
1152 GOSUB 1400
|
||||
1155 IF B$="YES" THEN 1110
|
||||
1156 GOTO 1250
|
||||
1160 LET I=I-160
|
||||
@@ -87,7 +87,7 @@
|
||||
1177 LET D1=INT((.2*RND(1)+.8)*10^2+.5)/10^2
|
||||
1180 PRINT "SUPPLIES AT FORT HOCHELAGA COST $150.00."
|
||||
1181 PRINT "YOUR TRAVEL EXPENSES TO HOCHELAGA WERE $10.00."
|
||||
1190 GOTO 1410
|
||||
1190 GOTO 1410
|
||||
1198 LET I=I-140
|
||||
1201 PRINT
|
||||
1205 LET M1=INT((.3*RND(1)+.85)*10^2+.5)/10^2
|
||||
@@ -99,26 +99,26 @@
|
||||
1213 IF P<=8 THEN 1226
|
||||
1215 IF P<=10 THEN 1235
|
||||
1216 LET F(2)=0
|
||||
1218 PRINT "YOUR BEAVER WERE TOO HEAVY TO CARRY ACROSS"
|
||||
1219 PRINT "THE PORTAGE. YOU HAD TO LEAVE THE PELTS, BUT FOUND"
|
||||
1218 PRINT "YOUR BEAVER WERE TOO HEAVY TO CARRY ACROSS"
|
||||
1219 PRINT "THE PORTAGE. YOU HAD TO LEAVE THE PELTS, BUT FOUND"
|
||||
1220 PRINT "THEM STOLEN WHEN YOU RETURNED."
|
||||
1221 GOSUB 1244
|
||||
1222 GOTO 1414
|
||||
1224 PRINT "YOU ARRIVED SAFELY AT FORT STADACONA."
|
||||
1225 GOTO 1239
|
||||
1226 GOSUB 1430
|
||||
1230 PRINT "YOUR CANOE UPSET IN THE LACHINE RAPIDS. YOU"
|
||||
1231 PRINT "LOST ALL YOUR FURS."
|
||||
1232 GOSUB 1244
|
||||
1233 GOTO 1418
|
||||
1235 LET F(4)=0
|
||||
1221 GOSUB 1244
|
||||
1222 GOTO 1414
|
||||
1224 PRINT "YOU ARRIVED SAFELY AT FORT STADACONA."
|
||||
1225 GOTO 1239
|
||||
1226 GOSUB 1430
|
||||
1230 PRINT "YOUR CANOE UPSET IN THE LACHINE RAPIDS. YOU"
|
||||
1231 PRINT "LOST ALL YOUR FURS."
|
||||
1232 GOSUB 1244
|
||||
1233 GOTO 1418
|
||||
1235 LET F(4)=0
|
||||
1237 PRINT "YOUR FOX PELTS WERE NOT CURED PROPERLY."
|
||||
1238 PRINT "NO ONE WILL BUY THEM."
|
||||
1239 GOSUB 1244
|
||||
1240 GOTO 1410
|
||||
1239 GOSUB 1244
|
||||
1240 GOTO 1410
|
||||
1244 PRINT "SUPPLIES AT FORT STADACONA COST $125.00."
|
||||
1246 PRINT "YOUR TRAVEL EXPENSES TO STADACONA WERE $15.00."
|
||||
1248 RETURN
|
||||
1248 RETURN
|
||||
1250 LET I=I-105
|
||||
1254 PRINT
|
||||
1260 LET M1=INT((.15*RND(1)+1.05)*10^2+.5)/10^2
|
||||
@@ -129,30 +129,30 @@
|
||||
1273 IF P<=8 THEN 1295
|
||||
1274 IF P<=10 THEN 1306
|
||||
1281 PRINT "YOU WERE ATTACKED BY A PARTY OF IROQUOIS."
|
||||
1282 PRINT "ALL PEOPLE IN YOUR TRADING GROUP WERE"
|
||||
1283 PRINT "KILLED. THIS ENDS THE GAME."
|
||||
1284 STOP
|
||||
1282 PRINT "ALL PEOPLE IN YOUR TRADING GROUP WERE"
|
||||
1283 PRINT "KILLED. THIS ENDS THE GAME."
|
||||
1284 STOP
|
||||
1291 PRINT "YOU WERE LUCKY. YOU ARRIVED SAFELY"
|
||||
1292 PRINT "AT FORT NEW YORK."
|
||||
1293 GOTO 1311
|
||||
1295 GOSUB 1430
|
||||
1293 GOTO 1311
|
||||
1295 GOSUB 1430
|
||||
1300 PRINT "YOU NARROWLY ESCAPED AN IROQUOIS RAIDING PARTY."
|
||||
1301 PRINT "HOWEVER, YOU HAD TO LEAVE ALL YOUR FURS BEHIND."
|
||||
1303 GOSUB 1320
|
||||
1304 GOTO 1418
|
||||
1303 GOSUB 1320
|
||||
1304 GOTO 1418
|
||||
1306 LET B1=B1/2
|
||||
1307 LET M1=M1/2
|
||||
1308 PRINT "YOUR MINK AND BEAVER WERE DAMAGED ON YOUR TRIP."
|
||||
1309 PRINT "YOU RECEIVE ONLY HALF THE CURRENT PRICE FOR THESE FURS."
|
||||
1311 GOSUB 1320
|
||||
1312 GOTO 1410
|
||||
1320 PRINT "SUPPLIES AT NEW YORK COST $80.00."
|
||||
1312 GOTO 1410
|
||||
1320 PRINT "SUPPLIES AT NEW YORK COST $80.00."
|
||||
1321 PRINT "YOUR TRAVEL EXPENSES TO NEW YORK WERE $25.00."
|
||||
1322 RETURN
|
||||
1322 RETURN
|
||||
1400 PRINT "DO YOU WANT TO TRADE AT ANOTHER FORT?"
|
||||
1402 PRINT "ANSWER YES OR NO",
|
||||
1403 INPUT B$
|
||||
1404 RETURN
|
||||
1404 RETURN
|
||||
1410 PRINT
|
||||
1412 PRINT "YOUR BEAVER SOLD FOR $";B1*F(2);
|
||||
1414 PRINT "YOUR FOX SOLD FOR $";D1*F(4)
|
||||
@@ -162,9 +162,9 @@
|
||||
1420 PRINT
|
||||
1422 PRINT "YOU NOW HAVE $";I;" INCLUDING YOUR PREVIOUS SAVINGS"
|
||||
1425 GOTO 508
|
||||
1430 FOR J=1 TO 4
|
||||
1432 LET F(J)=0
|
||||
1434 NEXT J
|
||||
1436 RETURN
|
||||
1430 FOR J=1 TO 4
|
||||
1432 LET F(J)=0
|
||||
1434 NEXT J
|
||||
1436 RETURN
|
||||
2000 DATA "MINK","BEAVER","ERMINE","FOX"
|
||||
2046 END
|
||||
|
||||
@@ -12,10 +12,10 @@ 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");
|
||||
@@ -178,7 +178,7 @@ async function main()
|
||||
}
|
||||
print("SUPPLIES AT FORT STADACONA COST $125.00.\n");
|
||||
print("YOUR TRAVEL EXPENSES TO STADACONA WERE $15.00.\n");
|
||||
|
||||
|
||||
d1 = Math.floor((0.2 * Math.random() + 0.8) * Math.pow(10, 2) + 0.5) / Math.pow(10, 2);
|
||||
} else if (b == 3) {
|
||||
i -= 105;
|
||||
|
||||
@@ -5,21 +5,20 @@ Conversion to [Python](https://www.python.org/about/)
|
||||
##### Translator Notes:
|
||||
I tried to preserve as much of the original layout and flow of the code
|
||||
as possible. However I did use quasi enumerated types for the Fort numbers
|
||||
and Fur types. I think this was certainly a change for the better, and
|
||||
and Fur types. I think this was certainly a change for the better, and
|
||||
makes the code much easier to read.
|
||||
|
||||
I program in many different languages on a daily basis. Most languages
|
||||
require brackets around expressions, so I just cannot bring myself to
|
||||
write an expression without brackets. IMHO it makes the code easier to study,
|
||||
require brackets around expressions, so I just cannot bring myself to
|
||||
write an expression without brackets. IMHO it makes the code easier to study,
|
||||
but it does contravene the Python PEP-8 Style guide.
|
||||
|
||||
Interestingly the code seems to have a bug around the prices of Fox Furs.
|
||||
The commodity-rate for these is stored in the variable `D1`, however some
|
||||
paths through the code do not set this price. So there was a chance of
|
||||
using this uninitialised, or whatever the previous loop set. I don't
|
||||
paths through the code do not set this price. So there was a chance of
|
||||
using this uninitialised, or whatever the previous loop set. I don't
|
||||
think this was the original authors intent. So I preserved the original flow
|
||||
of the code (using the previous `D1` value), but also catching the
|
||||
of the code (using the previous `D1` value), but also catching the
|
||||
uninitialised path, and assigning a "best guess" value.
|
||||
|
||||
krt@krt.com.au 2020-10-10
|
||||
|
||||
|
||||
@@ -1,68 +1,66 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import sys # for system function, like exit()
|
||||
import random # for generating random numbers
|
||||
|
||||
import random # for generating random numbers
|
||||
import sys # for system function, like exit()
|
||||
|
||||
### global variables for storing player's status
|
||||
player_funds = 0 # no money
|
||||
player_furs = [ 0, 0, 0, 0 ] # no furs
|
||||
player_funds = 0 # no money
|
||||
player_furs = [0, 0, 0, 0] # no furs
|
||||
|
||||
|
||||
### Constants
|
||||
FUR_MINK = 0
|
||||
FUR_MINK = 0
|
||||
FUR_BEAVER = 1
|
||||
FUR_ERMINE = 2
|
||||
FUR_FOX = 3
|
||||
MAX_FURS = 190
|
||||
FUR_NAMES = [ "MINK", "BEAVER", "ERMINE", "FOX" ]
|
||||
FUR_FOX = 3
|
||||
MAX_FURS = 190
|
||||
FUR_NAMES = ["MINK", "BEAVER", "ERMINE", "FOX"]
|
||||
|
||||
FORT_MONTREAL = 1
|
||||
FORT_QUEBEC = 2
|
||||
FORT_NEWYORK = 3
|
||||
FORT_NAMES = [ "HOCHELAGA (MONTREAL)", "STADACONA (QUEBEC)", "NEW YORK" ]
|
||||
FORT_QUEBEC = 2
|
||||
FORT_NEWYORK = 3
|
||||
FORT_NAMES = ["HOCHELAGA (MONTREAL)", "STADACONA (QUEBEC)", "NEW YORK"]
|
||||
|
||||
|
||||
|
||||
def printAtColumn( column:int, words:str ):
|
||||
""" Print the words at the specified column """
|
||||
spaces = ' ' * column # make a fat string of spaces
|
||||
print( spaces + words )
|
||||
def printAtColumn(column: int, words: str):
|
||||
"""Print the words at the specified column"""
|
||||
spaces = " " * column # make a fat string of spaces
|
||||
print(spaces + words)
|
||||
|
||||
|
||||
def showIntroduction():
|
||||
""" Show the player the introductory message """
|
||||
print( "YOU ARE THE LEADER OF A FRENCH FUR TRADING EXPEDITION IN " )
|
||||
print( "1776 LEAVING THE LAKE ONTARIO AREA TO SELL FURS AND GET" )
|
||||
print( "SUPPLIES FOR THE NEXT YEAR. YOU HAVE A CHOICE OF THREE" )
|
||||
print( "FORTS AT WHICH YOU MAY TRADE. THE COST OF SUPPLIES" )
|
||||
print( "AND THE AMOUNT YOU RECEIVE FOR YOUR FURS WILL DEPEND" )
|
||||
print( "ON THE FORT THAT YOU CHOOSE." )
|
||||
print( "" )
|
||||
"""Show the player the introductory message"""
|
||||
print("YOU ARE THE LEADER OF A FRENCH FUR TRADING EXPEDITION IN ")
|
||||
print("1776 LEAVING THE LAKE ONTARIO AREA TO SELL FURS AND GET")
|
||||
print("SUPPLIES FOR THE NEXT YEAR. YOU HAVE A CHOICE OF THREE")
|
||||
print("FORTS AT WHICH YOU MAY TRADE. THE COST OF SUPPLIES")
|
||||
print("AND THE AMOUNT YOU RECEIVE FOR YOUR FURS WILL DEPEND")
|
||||
print("ON THE FORT THAT YOU CHOOSE.")
|
||||
print("")
|
||||
|
||||
|
||||
def getFortChoice():
|
||||
""" Show the player the choices of Fort, get their input, if the
|
||||
input is a valid choice (1,2,3) return it, otherwise keep
|
||||
prompting the user. """
|
||||
"""Show the player the choices of Fort, get their input, if the
|
||||
input is a valid choice (1,2,3) return it, otherwise keep
|
||||
prompting the user."""
|
||||
result = 0
|
||||
while ( result == 0 ):
|
||||
print( "" )
|
||||
print( "YOU MAY TRADE YOUR FURS AT FORT 1, FORT 2," )
|
||||
print( "OR FORT 3. FORT 1 IS FORT HOCHELAGA (MONTREAL)" )
|
||||
print( "AND IS UNDER THE PROTECTION OF THE FRENCH ARMY." )
|
||||
print( "FORT 2 IS FORT STADACONA (QUEBEC) AND IS UNDER THE" )
|
||||
print( "PROTECTION OF THE FRENCH ARMY. HOWEVER, YOU MUST" )
|
||||
print( "MAKE A PORTAGE AND CROSS THE LACHINE RAPIDS." )
|
||||
print( "FORT 3 IS FORT NEW YORK AND IS UNDER DUTCH CONTROL." )
|
||||
print( "YOU MUST CROSS THROUGH IROQUOIS LAND." )
|
||||
print( "ANSWER 1, 2, OR 3." )
|
||||
while result == 0:
|
||||
print("")
|
||||
print("YOU MAY TRADE YOUR FURS AT FORT 1, FORT 2,")
|
||||
print("OR FORT 3. FORT 1 IS FORT HOCHELAGA (MONTREAL)")
|
||||
print("AND IS UNDER THE PROTECTION OF THE FRENCH ARMY.")
|
||||
print("FORT 2 IS FORT STADACONA (QUEBEC) AND IS UNDER THE")
|
||||
print("PROTECTION OF THE FRENCH ARMY. HOWEVER, YOU MUST")
|
||||
print("MAKE A PORTAGE AND CROSS THE LACHINE RAPIDS.")
|
||||
print("FORT 3 IS FORT NEW YORK AND IS UNDER DUTCH CONTROL.")
|
||||
print("YOU MUST CROSS THROUGH IROQUOIS LAND.")
|
||||
print("ANSWER 1, 2, OR 3.")
|
||||
|
||||
player_choice = input( ">> " ) # get input from the player
|
||||
player_choice = input(">> ") # get input from the player
|
||||
|
||||
# try to convert the player's string input into an integer
|
||||
try:
|
||||
result = int( player_choice ) # string to integer
|
||||
result = int(player_choice) # string to integer
|
||||
except:
|
||||
# Whatever the player typed, it could not be interpreted as a number
|
||||
pass
|
||||
@@ -70,228 +68,255 @@ def getFortChoice():
|
||||
return result
|
||||
|
||||
|
||||
def showFortComment( which_fort ):
|
||||
""" Print the description for the fort """
|
||||
print( "" )
|
||||
if ( which_fort == FORT_MONTREAL ):
|
||||
print( "YOU HAVE CHOSEN THE EASIEST ROUTE. HOWEVER, THE FORT" )
|
||||
print( "IS FAR FROM ANY SEAPORT. THE VALUE" )
|
||||
print( "YOU RECEIVE FOR YOUR FURS WILL BE LOW AND THE COST" )
|
||||
print( "OF SUPPLIES HIGHER THAN AT FORTS STADACONA OR NEW YORK." )
|
||||
elif ( which_fort == FORT_QUEBEC ):
|
||||
print( "YOU HAVE CHOSEN A HARD ROUTE. IT IS, IN COMPARSION," )
|
||||
print( "HARDER THAN THE ROUTE TO HOCHELAGA BUT EASIER THAN" )
|
||||
print( "THE ROUTE TO NEW YORK. YOU WILL RECEIVE AN AVERAGE VALUE" )
|
||||
print( "FOR YOUR FURS AND THE COST OF YOUR SUPPLIES WILL BE AVERAGE." )
|
||||
elif ( which_fort == FORT_NEWYORK ):
|
||||
print( "YOU HAVE CHOSEN THE MOST DIFFICULT ROUTE. AT" )
|
||||
print( "FORT NEW YORK YOU WILL RECEIVE THE HIGHEST VALUE" )
|
||||
print( "FOR YOUR FURS. THE COST OF YOUR SUPPLIES" )
|
||||
print( "WILL BE LOWER THAN AT ALL THE OTHER FORTS." )
|
||||
def showFortComment(which_fort):
|
||||
"""Print the description for the fort"""
|
||||
print("")
|
||||
if which_fort == FORT_MONTREAL:
|
||||
print("YOU HAVE CHOSEN THE EASIEST ROUTE. HOWEVER, THE FORT")
|
||||
print("IS FAR FROM ANY SEAPORT. THE VALUE")
|
||||
print("YOU RECEIVE FOR YOUR FURS WILL BE LOW AND THE COST")
|
||||
print("OF SUPPLIES HIGHER THAN AT FORTS STADACONA OR NEW YORK.")
|
||||
elif which_fort == FORT_QUEBEC:
|
||||
print("YOU HAVE CHOSEN A HARD ROUTE. IT IS, IN COMPARSION,")
|
||||
print("HARDER THAN THE ROUTE TO HOCHELAGA BUT EASIER THAN")
|
||||
print("THE ROUTE TO NEW YORK. YOU WILL RECEIVE AN AVERAGE VALUE")
|
||||
print("FOR YOUR FURS AND THE COST OF YOUR SUPPLIES WILL BE AVERAGE.")
|
||||
elif which_fort == FORT_NEWYORK:
|
||||
print("YOU HAVE CHOSEN THE MOST DIFFICULT ROUTE. AT")
|
||||
print("FORT NEW YORK YOU WILL RECEIVE THE HIGHEST VALUE")
|
||||
print("FOR YOUR FURS. THE COST OF YOUR SUPPLIES")
|
||||
print("WILL BE LOWER THAN AT ALL THE OTHER FORTS.")
|
||||
else:
|
||||
print( "Internal error #1, fort " + str( which_fort ) + " does not exist" )
|
||||
sys.exit( 1 ) # you have a bug
|
||||
print( "" )
|
||||
|
||||
print("Internal error #1, fort " + str(which_fort) + " does not exist")
|
||||
sys.exit(1) # you have a bug
|
||||
print("")
|
||||
|
||||
|
||||
def getYesOrNo():
|
||||
""" Prompt the player to enter 'YES' or 'NO'. Keep prompting until
|
||||
valid input is entered. Accept various spellings by only
|
||||
checking the first letter of input.
|
||||
Return a single letter 'Y' or 'N' """
|
||||
"""Prompt the player to enter 'YES' or 'NO'. Keep prompting until
|
||||
valid input is entered. Accept various spellings by only
|
||||
checking the first letter of input.
|
||||
Return a single letter 'Y' or 'N'"""
|
||||
result = 0
|
||||
while ( result not in ( 'Y', 'N' ) ):
|
||||
print( "ANSWER YES OR NO" )
|
||||
player_choice = input( ">> " )
|
||||
while result not in ("Y", "N"):
|
||||
print("ANSWER YES OR NO")
|
||||
player_choice = input(">> ")
|
||||
player_choice = player_choice.strip().upper() # trim spaces, make upper-case
|
||||
if ( player_choice.startswith( 'Y' ) ):
|
||||
result = 'Y'
|
||||
elif ( player_choice.startswith( 'N' ) ):
|
||||
result = 'N'
|
||||
if player_choice.startswith("Y"):
|
||||
result = "Y"
|
||||
elif player_choice.startswith("N"):
|
||||
result = "N"
|
||||
return result
|
||||
|
||||
|
||||
|
||||
def getFursPurchase():
|
||||
""" Prompt the player for how many of each fur type they want.
|
||||
Accept numeric inputs, re-prompting on incorrect input values """
|
||||
"""Prompt the player for how many of each fur type they want.
|
||||
Accept numeric inputs, re-prompting on incorrect input values"""
|
||||
results = []
|
||||
|
||||
print( "YOUR " + str( MAX_FURS ) + " FURS ARE DISTRIBUTED AMONG THE FOLLOWING" )
|
||||
print( "KINDS OF PELTS: MINK, BEAVER, ERMINE AND FOX." )
|
||||
print( "" )
|
||||
print("YOUR " + str(MAX_FURS) + " FURS ARE DISTRIBUTED AMONG THE FOLLOWING")
|
||||
print("KINDS OF PELTS: MINK, BEAVER, ERMINE AND FOX.")
|
||||
print("")
|
||||
|
||||
for i in ( range( len( FUR_NAMES ) ) ):
|
||||
print( "HOW MANY " + FUR_NAMES[i] + " DO YOU HAVE" )
|
||||
count_str = input( ">> " )
|
||||
for i in range(len(FUR_NAMES)):
|
||||
print("HOW MANY " + FUR_NAMES[i] + " DO YOU HAVE")
|
||||
count_str = input(">> ")
|
||||
try:
|
||||
count = int( count_str )
|
||||
results.append( count )
|
||||
count = int(count_str)
|
||||
results.append(count)
|
||||
except:
|
||||
# invalid input, prompt again by re-looping
|
||||
i -= 1
|
||||
return results
|
||||
|
||||
|
||||
|
||||
###
|
||||
### MAIN
|
||||
###
|
||||
|
||||
if ( __name__ == '__main__' ):
|
||||
if __name__ == "__main__":
|
||||
|
||||
printAtColumn( 31, "FUR TRADER" )
|
||||
printAtColumn( 15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" )
|
||||
printAtColumn( 15, "(Ported to Python Oct 2012 krt@krt.com.au)" )
|
||||
print( "\n\n\n" )
|
||||
printAtColumn(31, "FUR TRADER")
|
||||
printAtColumn(15, "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY")
|
||||
printAtColumn(15, "(Ported to Python Oct 2012 krt@krt.com.au)")
|
||||
print("\n\n\n")
|
||||
|
||||
game_state = 'starting'
|
||||
game_state = "starting"
|
||||
fox_price = None # sometimes this takes the "last" price (probably this was a bug)
|
||||
|
||||
while ( True ):
|
||||
while True:
|
||||
|
||||
if ( game_state == 'starting' ):
|
||||
if game_state == "starting":
|
||||
showIntroduction()
|
||||
|
||||
player_funds = 600 # Initial player start money
|
||||
player_furs = [ 0, 0, 0, 0 ] # Player fur inventory
|
||||
player_funds = 600 # Initial player start money
|
||||
player_furs = [0, 0, 0, 0] # Player fur inventory
|
||||
|
||||
print( "DO YOU WISH TO TRADE FURS?" )
|
||||
print("DO YOU WISH TO TRADE FURS?")
|
||||
should_trade = getYesOrNo()
|
||||
if ( should_trade == 'N' ):
|
||||
sys.exit( 0 ) # STOP
|
||||
game_state = 'trading'
|
||||
if should_trade == "N":
|
||||
sys.exit(0) # STOP
|
||||
game_state = "trading"
|
||||
|
||||
elif ( game_state == 'trading' ):
|
||||
print( "" )
|
||||
print( "YOU HAVE $ %1.2f IN SAVINGS" % ( player_funds ) )
|
||||
print( "AND " + str( MAX_FURS ) + " FURS TO BEGIN THE EXPEDITION" )
|
||||
elif game_state == "trading":
|
||||
print("")
|
||||
print("YOU HAVE $ %1.2f IN SAVINGS" % (player_funds))
|
||||
print("AND " + str(MAX_FURS) + " FURS TO BEGIN THE EXPEDITION")
|
||||
player_furs = getFursPurchase()
|
||||
|
||||
if ( sum( player_furs ) > MAX_FURS ):
|
||||
print( "" )
|
||||
print( "YOU MAY NOT HAVE THAT MANY FURS." )
|
||||
print( "DO NOT TRY TO CHEAT. I CAN ADD." )
|
||||
print( "YOU MUST START AGAIN." )
|
||||
game_state = 'starting' # T/N: Wow, harsh.
|
||||
if sum(player_furs) > MAX_FURS:
|
||||
print("")
|
||||
print("YOU MAY NOT HAVE THAT MANY FURS.")
|
||||
print("DO NOT TRY TO CHEAT. I CAN ADD.")
|
||||
print("YOU MUST START AGAIN.")
|
||||
game_state = "starting" # T/N: Wow, harsh.
|
||||
else:
|
||||
game_state = 'choosing fort'
|
||||
game_state = "choosing fort"
|
||||
|
||||
elif ( game_state == 'choosing fort' ):
|
||||
elif game_state == "choosing fort":
|
||||
which_fort = getFortChoice()
|
||||
showFortComment( which_fort )
|
||||
print( "DO YOU WANT TO TRADE AT ANOTHER FORT?" )
|
||||
showFortComment(which_fort)
|
||||
print("DO YOU WANT TO TRADE AT ANOTHER FORT?")
|
||||
change_fort = getYesOrNo()
|
||||
if ( change_fort == 'N' ):
|
||||
game_state = 'travelling'
|
||||
if change_fort == "N":
|
||||
game_state = "travelling"
|
||||
|
||||
elif ( game_state == 'travelling' ):
|
||||
print( "" )
|
||||
if ( which_fort == FORT_MONTREAL ):
|
||||
mink_price = int( ( 0.2 * random.random() + 0.70 ) * 100 + 0.5 ) / 100 #INT((.2*RND(1)+.7)*10^2+.5)/10^2
|
||||
ermine_price = int( ( 0.2 * random.random() + 0.65 ) * 100 + 0.5 ) / 100 #INT((.2*RND(1)+.65)*10^2+.5)/10^2
|
||||
beaver_price = int( ( 0.2 * random.random() + 0.75 ) * 100 + 0.5 ) / 100 #INT((.2*RND(1)+.75)*10^2+.5)/10^2
|
||||
fox_price = int( ( 0.2 * random.random() + 0.80 ) * 100 + 0.5 ) / 100 #INT((.2*RND(1)+.8)*10^2+.5)/10^2
|
||||
elif game_state == "travelling":
|
||||
print("")
|
||||
if which_fort == FORT_MONTREAL:
|
||||
mink_price = (
|
||||
int((0.2 * random.random() + 0.70) * 100 + 0.5) / 100
|
||||
) # INT((.2*RND(1)+.7)*10^2+.5)/10^2
|
||||
ermine_price = (
|
||||
int((0.2 * random.random() + 0.65) * 100 + 0.5) / 100
|
||||
) # INT((.2*RND(1)+.65)*10^2+.5)/10^2
|
||||
beaver_price = (
|
||||
int((0.2 * random.random() + 0.75) * 100 + 0.5) / 100
|
||||
) # INT((.2*RND(1)+.75)*10^2+.5)/10^2
|
||||
fox_price = (
|
||||
int((0.2 * random.random() + 0.80) * 100 + 0.5) / 100
|
||||
) # INT((.2*RND(1)+.8)*10^2+.5)/10^2
|
||||
|
||||
print( "SUPPLIES AT FORT HOCHELAGA COST $150.00." )
|
||||
print( "YOUR TRAVEL EXPENSES TO HOCHELAGA WERE $10.00." )
|
||||
print("SUPPLIES AT FORT HOCHELAGA COST $150.00.")
|
||||
print("YOUR TRAVEL EXPENSES TO HOCHELAGA WERE $10.00.")
|
||||
player_funds -= 160
|
||||
|
||||
elif ( which_fort == FORT_QUEBEC ):
|
||||
mink_price = int( ( 0.30 * random.random() + 0.85 ) * 100 + 0.5 ) / 100 #INT((.3*RND(1)+.85)*10^2+.5)/10^2
|
||||
ermine_price = int( ( 0.15 * random.random() + 0.80 ) * 100 + 0.5 ) / 100 #INT((.15*RND(1)+.8)*10^2+.5)/10^2
|
||||
beaver_price = int( ( 0.20 * random.random() + 0.90 ) * 100 + 0.5 ) / 100 #INT((.2*RND(1)+.9)*10^2+.5)/10^2
|
||||
fox_price = int( ( 0.25 * random.random() + 1.10 ) * 100 + 0.5 ) / 100 #INT((.25*RND(1)+1.1)*10^2+.5)/10^2
|
||||
event_picker = int( 10 * random.random() ) + 1
|
||||
elif which_fort == FORT_QUEBEC:
|
||||
mink_price = (
|
||||
int((0.30 * random.random() + 0.85) * 100 + 0.5) / 100
|
||||
) # INT((.3*RND(1)+.85)*10^2+.5)/10^2
|
||||
ermine_price = (
|
||||
int((0.15 * random.random() + 0.80) * 100 + 0.5) / 100
|
||||
) # INT((.15*RND(1)+.8)*10^2+.5)/10^2
|
||||
beaver_price = (
|
||||
int((0.20 * random.random() + 0.90) * 100 + 0.5) / 100
|
||||
) # INT((.2*RND(1)+.9)*10^2+.5)/10^2
|
||||
fox_price = (
|
||||
int((0.25 * random.random() + 1.10) * 100 + 0.5) / 100
|
||||
) # INT((.25*RND(1)+1.1)*10^2+.5)/10^2
|
||||
event_picker = int(10 * random.random()) + 1
|
||||
|
||||
if ( event_picker <= 2 ):
|
||||
print( "YOUR BEAVER WERE TOO HEAVY TO CARRY ACROSS" )
|
||||
print( "THE PORTAGE. YOU HAD TO LEAVE THE PELTS, BUT FOUND" )
|
||||
print( "THEM STOLEN WHEN YOU RETURNED." )
|
||||
player_furs[ FUR_BEAVER ] = 0
|
||||
elif ( event_picker <= 6 ):
|
||||
print( "YOU ARRIVED SAFELY AT FORT STADACONA." )
|
||||
elif ( event_picker <= 8 ):
|
||||
print( "YOUR CANOE UPSET IN THE LACHINE RAPIDS. YOU" )
|
||||
print( "LOST ALL YOUR FURS." )
|
||||
player_furs = [ 0, 0, 0, 0 ]
|
||||
elif ( event_picker <= 10 ):
|
||||
print( "YOUR FOX PELTS WERE NOT CURED PROPERLY." )
|
||||
print( "NO ONE WILL BUY THEM." )
|
||||
player_furs[ FUR_FOX ] = 0
|
||||
if event_picker <= 2:
|
||||
print("YOUR BEAVER WERE TOO HEAVY TO CARRY ACROSS")
|
||||
print("THE PORTAGE. YOU HAD TO LEAVE THE PELTS, BUT FOUND")
|
||||
print("THEM STOLEN WHEN YOU RETURNED.")
|
||||
player_furs[FUR_BEAVER] = 0
|
||||
elif event_picker <= 6:
|
||||
print("YOU ARRIVED SAFELY AT FORT STADACONA.")
|
||||
elif event_picker <= 8:
|
||||
print("YOUR CANOE UPSET IN THE LACHINE RAPIDS. YOU")
|
||||
print("LOST ALL YOUR FURS.")
|
||||
player_furs = [0, 0, 0, 0]
|
||||
elif event_picker <= 10:
|
||||
print("YOUR FOX PELTS WERE NOT CURED PROPERLY.")
|
||||
print("NO ONE WILL BUY THEM.")
|
||||
player_furs[FUR_FOX] = 0
|
||||
else:
|
||||
print( "Internal Error #3, Out-of-bounds event_picker" + str( event_picker ) )
|
||||
sys.exit( 1 ) # you have a bug
|
||||
print(
|
||||
"Internal Error #3, Out-of-bounds event_picker"
|
||||
+ str(event_picker)
|
||||
)
|
||||
sys.exit(1) # you have a bug
|
||||
|
||||
print( "" )
|
||||
print( "SUPPLIES AT FORT STADACONA COST $125.00." )
|
||||
print( "YOUR TRAVEL EXPENSES TO STADACONA WERE $15.00." )
|
||||
print("")
|
||||
print("SUPPLIES AT FORT STADACONA COST $125.00.")
|
||||
print("YOUR TRAVEL EXPENSES TO STADACONA WERE $15.00.")
|
||||
player_funds -= 140
|
||||
|
||||
elif ( which_fort == FORT_NEWYORK ):
|
||||
mink_price = int( ( 0.15 * random.random() + 1.05 ) * 100 + 0.5 ) / 100 #INT((.15*RND(1)+1.05)*10^2+.5)/10^2
|
||||
ermine_price = int( ( 0.15 * random.random() + 0.95 ) * 100 + 0.5 ) / 100 #INT((.15*RND(1)+.95)*10^2+.5)/10^2
|
||||
beaver_price = int( ( 0.25 * random.random() + 1.00 ) * 100 + 0.5 ) / 100 #INT((.25*RND(1)+1.00)*10^2+.5)/10^2
|
||||
if ( fox_price == None ):
|
||||
elif which_fort == FORT_NEWYORK:
|
||||
mink_price = (
|
||||
int((0.15 * random.random() + 1.05) * 100 + 0.5) / 100
|
||||
) # INT((.15*RND(1)+1.05)*10^2+.5)/10^2
|
||||
ermine_price = (
|
||||
int((0.15 * random.random() + 0.95) * 100 + 0.5) / 100
|
||||
) # INT((.15*RND(1)+.95)*10^2+.5)/10^2
|
||||
beaver_price = (
|
||||
int((0.25 * random.random() + 1.00) * 100 + 0.5) / 100
|
||||
) # INT((.25*RND(1)+1.00)*10^2+.5)/10^2
|
||||
if fox_price == None:
|
||||
# Original Bug? There is no Fox price generated for New York, it will use any previous "D1" price
|
||||
# So if there was no previous value, make one up
|
||||
fox_price = int( ( 0.25 * random.random() + 1.05 ) * 100 + 0.5 ) / 100 # not in orginal code
|
||||
event_picker = int( 10 * random.random() ) + 1
|
||||
fox_price = (
|
||||
int((0.25 * random.random() + 1.05) * 100 + 0.5) / 100
|
||||
) # not in orginal code
|
||||
event_picker = int(10 * random.random()) + 1
|
||||
|
||||
if ( event_picker <= 2 ):
|
||||
print( "YOU WERE ATTACKED BY A PARTY OF IROQUOIS." )
|
||||
print( "ALL PEOPLE IN YOUR TRADING GROUP WERE" )
|
||||
print( "KILLED. THIS ENDS THE GAME." )
|
||||
sys.exit( 0 )
|
||||
elif ( event_picker <= 6 ):
|
||||
print( "YOU WERE LUCKY. YOU ARRIVED SAFELY" )
|
||||
print( "AT FORT NEW YORK." )
|
||||
elif ( event_picker <= 8 ):
|
||||
print( "YOU NARROWLY ESCAPED AN IROQUOIS RAIDING PARTY." )
|
||||
print( "HOWEVER, YOU HAD TO LEAVE ALL YOUR FURS BEHIND." )
|
||||
player_furs = [ 0, 0, 0, 0 ]
|
||||
elif ( event_picker <= 10 ):
|
||||
if event_picker <= 2:
|
||||
print("YOU WERE ATTACKED BY A PARTY OF IROQUOIS.")
|
||||
print("ALL PEOPLE IN YOUR TRADING GROUP WERE")
|
||||
print("KILLED. THIS ENDS THE GAME.")
|
||||
sys.exit(0)
|
||||
elif event_picker <= 6:
|
||||
print("YOU WERE LUCKY. YOU ARRIVED SAFELY")
|
||||
print("AT FORT NEW YORK.")
|
||||
elif event_picker <= 8:
|
||||
print("YOU NARROWLY ESCAPED AN IROQUOIS RAIDING PARTY.")
|
||||
print("HOWEVER, YOU HAD TO LEAVE ALL YOUR FURS BEHIND.")
|
||||
player_furs = [0, 0, 0, 0]
|
||||
elif event_picker <= 10:
|
||||
mink_price /= 2
|
||||
fox_price /= 2
|
||||
print( "YOUR MINK AND BEAVER WERE DAMAGED ON YOUR TRIP." )
|
||||
print( "YOU RECEIVE ONLY HALF THE CURRENT PRICE FOR THESE FURS." )
|
||||
fox_price /= 2
|
||||
print("YOUR MINK AND BEAVER WERE DAMAGED ON YOUR TRIP.")
|
||||
print("YOU RECEIVE ONLY HALF THE CURRENT PRICE FOR THESE FURS.")
|
||||
else:
|
||||
print( "Internal Error #4, Out-of-bounds event_picker" + str( event_picker ) )
|
||||
sys.exit( 1 ) # you have a bug
|
||||
print(
|
||||
"Internal Error #4, Out-of-bounds event_picker"
|
||||
+ str(event_picker)
|
||||
)
|
||||
sys.exit(1) # you have a bug
|
||||
|
||||
print( "" )
|
||||
print( "SUPPLIES AT NEW YORK COST $85.00." )
|
||||
print( "YOUR TRAVEL EXPENSES TO NEW YORK WERE $25.00." )
|
||||
print("")
|
||||
print("SUPPLIES AT NEW YORK COST $85.00.")
|
||||
print("YOUR TRAVEL EXPENSES TO NEW YORK WERE $25.00.")
|
||||
player_funds -= 105
|
||||
|
||||
|
||||
else:
|
||||
print( "Internal error #2, fort " + str( which_fort ) + " does not exist" )
|
||||
sys.exit( 1 ) # you have a bug
|
||||
print("Internal error #2, fort " + str(which_fort) + " does not exist")
|
||||
sys.exit(1) # you have a bug
|
||||
|
||||
# Calculate sales
|
||||
beaver_value = beaver_price * player_furs[ FUR_BEAVER ]
|
||||
fox_value = fox_price * player_furs[ FUR_FOX ]
|
||||
ermine_value = ermine_price * player_furs[ FUR_ERMINE ]
|
||||
mink_value = mink_price * player_furs[ FUR_MINK ]
|
||||
|
||||
print( "" )
|
||||
print( "YOUR BEAVER SOLD FOR $%6.2f" % ( beaver_value ) )
|
||||
print( "YOUR FOX SOLD FOR $%6.2f" % ( fox_value ) )
|
||||
print( "YOUR ERMINE SOLD FOR $%6.2f" % ( ermine_value ) )
|
||||
print( "YOUR MINK SOLD FOR $%6.2f" % ( mink_value ) )
|
||||
beaver_value = beaver_price * player_furs[FUR_BEAVER]
|
||||
fox_value = fox_price * player_furs[FUR_FOX]
|
||||
ermine_value = ermine_price * player_furs[FUR_ERMINE]
|
||||
mink_value = mink_price * player_furs[FUR_MINK]
|
||||
|
||||
print("")
|
||||
print("YOUR BEAVER SOLD FOR $%6.2f" % (beaver_value))
|
||||
print("YOUR FOX SOLD FOR $%6.2f" % (fox_value))
|
||||
print("YOUR ERMINE SOLD FOR $%6.2f" % (ermine_value))
|
||||
print("YOUR MINK SOLD FOR $%6.2f" % (mink_value))
|
||||
|
||||
player_funds += beaver_value + fox_value + ermine_value + mink_value
|
||||
|
||||
print( "" )
|
||||
print( "YOU NOW HAVE $ %1.2f INCLUDING YOUR PREVIOUS SAVINGS" % ( player_funds ) )
|
||||
print("")
|
||||
print(
|
||||
"YOU NOW HAVE $ %1.2f INCLUDING YOUR PREVIOUS SAVINGS" % (player_funds)
|
||||
)
|
||||
|
||||
print( "" )
|
||||
print( "DO YOU WANT TO TRADE FURS NEXT YEAR?" )
|
||||
print("")
|
||||
print("DO YOU WANT TO TRADE FURS NEXT YEAR?")
|
||||
should_trade = getYesOrNo()
|
||||
if ( should_trade == 'N' ):
|
||||
sys.exit( 0 ) # STOP
|
||||
if should_trade == "N":
|
||||
sys.exit(0) # STOP
|
||||
else:
|
||||
game_state = 'trading'
|
||||
|
||||
|
||||
|
||||
game_state = "trading"
|
||||
|
||||
Reference in New Issue
Block a user