mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Ported LEM to Javascript
This commit is contained in:
9
59 Lunar LEM Rocket/javascript/lem.html
Normal file
9
59 Lunar LEM Rocket/javascript/lem.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>LEM</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="lem.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
326
59 Lunar LEM Rocket/javascript/lem.js
Normal file
326
59 Lunar LEM Rocket/javascript/lem.js
Normal file
@@ -0,0 +1,326 @@
|
||||
// LEM
|
||||
//
|
||||
// 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(34) + "LEM\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
// ROCKT2 is an interactive game that simulates a lunar
|
||||
// landing is similar to that of the Apollo program.
|
||||
// There is absolutely no chance involved
|
||||
zs = "GO";
|
||||
b1 = 1;
|
||||
while (1) {
|
||||
m = 17.95;
|
||||
f1 = 5.25;
|
||||
n = 7.5;
|
||||
r0 = 926;
|
||||
v0 = 1.29;
|
||||
t = 0;
|
||||
h0 = 60;
|
||||
r = r0 + h0;
|
||||
a = -3,425;
|
||||
r1 = 0;
|
||||
a1 = 8.84361e-4;
|
||||
r3 = 0;
|
||||
a3 = 0;
|
||||
m1 = 7.45;
|
||||
m0 = m1;
|
||||
b = 750;
|
||||
t1 = 0;
|
||||
f = 0;
|
||||
p = 0;
|
||||
n = 1;
|
||||
m2 = 0;
|
||||
s = 0;
|
||||
c = 0;
|
||||
if (zs == "YES") {
|
||||
print("\n");
|
||||
print("OK, DO YOU WANT THE COMPLETE INSTRUCTIONS OR THE INPUT -\n");
|
||||
print("OUTPUT STATEMENTS?\n");
|
||||
while (1) {
|
||||
print("1=COMPLETE INSTRUCTIONS\n");
|
||||
print("2=INPUT-OUTPUT STATEMENTS\n");
|
||||
print("3=NEITHER\n");
|
||||
b1 = parseInt(await input());
|
||||
qs = "NO";
|
||||
if (b1 == 1)
|
||||
break;
|
||||
qs = "YES";
|
||||
if (b1 == 2 || b1 == 3)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
print("\n");
|
||||
print("LUNAR LANDING SIMULATION\n");
|
||||
print("\n");
|
||||
print("HAVE YOU FLOWN AN APOLLO/LEM MISSION BEFORE");
|
||||
while (1) {
|
||||
print(" (YES OR NO)");
|
||||
qs = await input();
|
||||
if (qs == "YES" || qs == "NO")
|
||||
break;
|
||||
print("JUST ANSWER THE QUESTION, PLEASE, ");
|
||||
}
|
||||
}
|
||||
if (qs == "YES") {
|
||||
print("\n");
|
||||
print("INPUT MEASUREMENT OPTION NUMBER");
|
||||
} else {
|
||||
print("\n");
|
||||
print("WHICH SYSTEM OF MEASUREMENT DO YOU PREFER?\n");
|
||||
print(" 1=METRIC 0=ENGLISH\n");
|
||||
print("ENTER THE APPROPIATE NUMBER");
|
||||
}
|
||||
while (1) {
|
||||
k = parseInt(await input());
|
||||
if (k == 0 || k == 1)
|
||||
break;
|
||||
print("ENTER THE APPROPIATE NUMBER");
|
||||
}
|
||||
if (k == 1) {
|
||||
z = 1852.8;
|
||||
ms = "METERS";
|
||||
g3 = 3.6;
|
||||
ns = " KILOMETERS";
|
||||
g5 = 1000;
|
||||
} else {
|
||||
z = 6080;
|
||||
ms = "FEET";
|
||||
g3 = 0.592;
|
||||
ns = "N.MILES";
|
||||
g5 = z;
|
||||
}
|
||||
if (b1 != 3) {
|
||||
if (qs != "YES") {
|
||||
print("\n");
|
||||
print(" YOU ARE ON A LUNAR LANDING MISSION. AS THE PILOT OF\n");
|
||||
print("THE LUNAR EXCURSION MODULE, YOU WILL BE EXPECTED TO\n");
|
||||
print("GIVE CERTAIN COMMANDS TO THE MODULE NAVIGATION SYSTEM.\n");
|
||||
print("THE ON-BOARD COMPUTER WILL GIVE A RUNNING ACCOUNT\n");
|
||||
print("OF INFORMATION NEEDED TO NAVIGATE THE SHIP.\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("THE ATTITUDE ANGLE CALLED FOR IS DESCRIBED AS FOLLOWS.\n");
|
||||
print("+ OR -180 DEGREES IS DIRECTLY AWAY FROM THE MOON\n");
|
||||
print("-90 DEGREES IS ON A TANGENT IN THE DIRECTION OF ORBIT\n");
|
||||
print("+90 DEGREES IS ON A TANGENT FROM THE DIRECTION OF ORBIT\n");
|
||||
print("0 (ZERO) DEGREES IS DIRECTLY TOWARD THE MOON\n");
|
||||
print("\n");
|
||||
print(tab(30) + "-180|+180\n");
|
||||
print(tab(34) + "^\n");
|
||||
print(tab(27) + "-90 < -+- > +90\n");
|
||||
print(tab(34) + "!\n");
|
||||
print(tab(34) + "0\n");
|
||||
print(tab(21) + "<<<< DIRECTION OF ORBIT <<<<\n");
|
||||
print("\n");
|
||||
print(tab(20) + "------ SURFACE OF MOON ------\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("ALL ANGLES BETWEEN -180 AND +180 DEGREES ARE ACCEPTED.\n");
|
||||
print("\n");
|
||||
print("1 FUEL UNIT = 1 SEC. AT MAX THRUST\n");
|
||||
print("ANY DISCREPANCIES ARE ACCOUNTED FOR IN THE USE OF FUEL\n");
|
||||
print("FOR AN ATTITUDE CHANGE.\n");
|
||||
print("AVAILABLE ENGINE POWER: 0 (ZERO) AND ANY VALUE BETWEEN\n");
|
||||
print("10 AND 100 PERCENT.\n");
|
||||
print("\n");
|
||||
print("NEGATIVE THRUST OR TIME IS PROHIBITED.\n");
|
||||
print("\n");
|
||||
}
|
||||
print("\n");
|
||||
print("INPUT: TIME INTERVAL IN SECONDS ------ (T)\n");
|
||||
print(" PERCENTAGE OF THRUST ---------- (P)\n");
|
||||
print(" ATTITUDE ANGLE IN DEGREES ----- (A)\n");
|
||||
print("\n");
|
||||
if (qs != "YES") {
|
||||
print("FOR EXAMPLE:\n");
|
||||
print("T,P,A? 10,65,-60\n");
|
||||
print("TO ABORT THE MISSION AT ANY TIME, ENTER 0,0,0\n");
|
||||
print("\n");
|
||||
}
|
||||
print("OUTPUT: TOTAL TIME IN ELAPSED SECONDS\n");
|
||||
print(" HEIGHT IN " + ms + "\n");
|
||||
print(" DISTANCE FROM LANDING SITE IN " + ms + "\n");
|
||||
print(" VERTICAL VELOCITY IN " + ms + "/SECOND\n");
|
||||
print(" HORIZONTAL VELOCITY IN " + ms + "/SECOND\n");
|
||||
print(" FUEL UNITS REMAINING\n");
|
||||
print("\n");
|
||||
}
|
||||
while (1) {
|
||||
for (i = 1; i <= n; i++) {
|
||||
if (m1 != 0) {
|
||||
m1 -= m2;
|
||||
if (m1 <= 0) {
|
||||
f = f * (1 + m1 / m2);
|
||||
m2 = m1 + m2;
|
||||
print("YOU ARE OUT OF FUEL.\n");
|
||||
m1 = 0;
|
||||
}
|
||||
} else {
|
||||
f = 0;
|
||||
m2 = 0;
|
||||
}
|
||||
m = m - 0.5 * m2;
|
||||
r4 = r3;
|
||||
r3 = -0.5 * r0 * Math.pow(v0 / r, 2) + r * a1 * a1;
|
||||
r2 = (3 * r3 - r4) / 2 + 0.00526 * f1 * f * c / m;
|
||||
a4 = a3;
|
||||
a3 = -2 * r1 * a1 / r;
|
||||
a2 = (3 * a3 - a4) / 2 + 0.0056 * f1 * f * s / (m * r);
|
||||
x = r1 * t1 + 0.5 * r2 * t1 * t1;
|
||||
r = r + x;
|
||||
h0 = h0 + x;
|
||||
r1 = r1 + r2 * t1;
|
||||
a = a + a1 * t1 + 0.5 * a2 * t1 * t1;
|
||||
a1 = a1 + a2 * t1;
|
||||
m = m - 0.5 * m2;
|
||||
t = t + t1;
|
||||
if (h0 < 3.287828e-4)
|
||||
break;
|
||||
}
|
||||
h = h0 * z;
|
||||
h1 = r1 * z;
|
||||
d = r0 * a * z;
|
||||
d1 = r * a1 * z;
|
||||
t2 = m1 * b / m0;
|
||||
print(" " + t + "\t" + h + "\t" + d + "\t" + h1 + "\t" + d1 + "\t" + t2 + "\n");
|
||||
if (h0 < 3.287828e-4) {
|
||||
if (r1 < -8.21957e-4 || Math.abs(r * a1) > 4.93174e-4 || h0 < -3.287828e-4) {
|
||||
print("\n");
|
||||
print("CRASH !!!!!!!!!!!!!!!!\n");
|
||||
print("YOUR IMPACT CREATED A CRATER " + Math.abs(h) + " " + ms + " DEEP.\n");
|
||||
x1 = Math.sqrt(d1 * d1 + h1 * h1) * g3;
|
||||
print("AT CONTACT YOU WERE TRAVELING " + x1 + " " + ns + "/HR\n");
|
||||
break;
|
||||
}
|
||||
if (Math.abs(d) > 10 * z) {
|
||||
print("YOU ARE DOWN SAFELY - \n");
|
||||
print("\n");
|
||||
print("BUT MISSED THE LANDING SITE BY " + Math.abs(d / g5) + " " + ns + ".\n");
|
||||
break;
|
||||
}
|
||||
print("\n");
|
||||
print("TRANQUILITY BASE HERE -- THE EAGLE HAS LANDED.\n");
|
||||
print("CONGRATULATIONS -- THERE WAS NO SPACECRAFT DAMAGE.\n");
|
||||
print("YOU MAY NOW PROCEED WITH SURFACE EXPLORATION.\n");
|
||||
break;
|
||||
}
|
||||
if (r0 * a > 164.474) {
|
||||
print("\n");
|
||||
print("YOU HAVE BEEN LOST IN SPACE WITH NO HOPE OF RECOVERY.\n");
|
||||
break;
|
||||
}
|
||||
if (m1 > 0) {
|
||||
while (1) {
|
||||
print("T,P,A");
|
||||
str = await input();
|
||||
t1 = parseFloat(str);
|
||||
f = parseFloat(str.substr(str.indexOf(",") + 1));
|
||||
p = parseFloat(str.substr(str.lastIndexOf(",") + 1));
|
||||
f = f / 100;
|
||||
if (t1 < 0) {
|
||||
print("\n");
|
||||
print("THIS SPACECRAFT IS NOT ABLE TO VIOLATE THE SPACE-");
|
||||
print("TIME CONTINUUM.\n");
|
||||
print("\n");
|
||||
} else if (t1 == 0) {
|
||||
break;
|
||||
} else if (Math.abs(f - 0.05) > 1 || Math.abs(f - 0.05) < 0.05) {
|
||||
print("IMPOSSIBLE THRUST VALUE ");
|
||||
if (f < 0) {
|
||||
print("NEGATIVE\n");
|
||||
} else if (f - 0.05 < 0.05) {
|
||||
print("TOO SMALL\n");
|
||||
} else {
|
||||
print("TOO LARGE\n");
|
||||
}
|
||||
print("\n");
|
||||
} else if (Math.abs(p) > 180) {
|
||||
print("\n");
|
||||
print("IF YOU WANT TO SPIN AROUND, GO OUTSIDE THE MODULE\n");
|
||||
print("FOR AN E.V.A.\n");
|
||||
print("\n");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (t1 == 0) {
|
||||
print("\n");
|
||||
print("MISSION ABENDED\n");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
t1 = 20;
|
||||
f = 0;
|
||||
p = 0;
|
||||
}
|
||||
n = 20;
|
||||
if (t1 >= 400)
|
||||
n = t1 / 20;
|
||||
t1 = t1 / n;
|
||||
p = p * 3.14159 / 180;
|
||||
s = Math.sin(p);
|
||||
c = Math.cos(p);
|
||||
m2 = m0 * t1 * f / b;
|
||||
r3 = -0.5 * r0 * Math.pow(v0 / r, 2) + r * a1 * a1;
|
||||
a3 = -2 * r1 * a1 / r;
|
||||
}
|
||||
print("\n");
|
||||
while (1) {
|
||||
print("DO YOU WANT TO TRY IT AGAIN (YES/NO)?\n");
|
||||
zs = await input();
|
||||
if (zs == "YES" || zs == "NO")
|
||||
break;
|
||||
}
|
||||
if (zs != "YES")
|
||||
break;
|
||||
}
|
||||
print("\n");
|
||||
print("TOO BAD, THE SPACE PROGRAM HATES TO LOSE EXPERIENCED\n");
|
||||
print("ASTRONAUTS.\n");
|
||||
}
|
||||
|
||||
main();
|
||||
9
59 Lunar LEM Rocket/javascript/lunar.html
Normal file
9
59 Lunar LEM Rocket/javascript/lunar.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>LUNAR</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="output" style="font-size: 12pt;"></pre>
|
||||
<script src="lunar.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
376
59 Lunar LEM Rocket/javascript/lunar.js
Normal file
376
59 Lunar LEM Rocket/javascript/lunar.js
Normal file
@@ -0,0 +1,376 @@
|
||||
// KING
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
function hate_your_guts()
|
||||
{
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("OVER ONE THIRD OF THE POPULATION HAS DIED SINCE YOU\n");
|
||||
print("WERE ELECTED TO OFFICE. THE PEOPLE (REMAINING)\n");
|
||||
print("HATE YOUR GUTS.\n");
|
||||
}
|
||||
|
||||
// Main program
|
||||
async function main()
|
||||
{
|
||||
print(tab(34) + "KING\n");
|
||||
print(tab(15) + "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("DO YOU WANT INSTRUCTIONS");
|
||||
str = await input();
|
||||
n5 = 8;
|
||||
if (str == "AGAIN") {
|
||||
while (1) {
|
||||
print("HOW MANY YEARS HAD YOU BEEN IN OFFICE WHEN INTERRUPTED");
|
||||
x5 = parseInt(await input());
|
||||
if (x5 == 0)
|
||||
return;
|
||||
if (x5 < 8)
|
||||
break;
|
||||
print(" COME ON, YOUR TERM IN OFFICE IS ONLY " + n5 + " YEARS.\n");
|
||||
}
|
||||
print("HOW MUCH DID YOU HAVE IN THE TREASURY");
|
||||
a = parseInt(await input());
|
||||
if (a < 0)
|
||||
return;
|
||||
print("HOW MANY COUNTRYMEN");
|
||||
b = parseInt(await input());
|
||||
if (b < 0)
|
||||
return;
|
||||
print("HOW MANY WORKERS");
|
||||
c = parseInt(await input());
|
||||
if (c < 0)
|
||||
return;
|
||||
while (1) {
|
||||
print("HOW MANY SQUARE MILES OF LAND");
|
||||
d = parseInt(await input());
|
||||
if (d < 0)
|
||||
return;
|
||||
if (d > 1000 && d <= 2000)
|
||||
break;
|
||||
print(" COME ON, YOU STARTED WITH 1000 SQ. MILES OF FARM LAND\n");
|
||||
print(" AND 10,000 SQ. MILES OF FOREST LAND.\n");
|
||||
}
|
||||
} else {
|
||||
if (str.substr(0, 1) != "N") {
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("CONGRATULATIONS! YOU'VE JUST BEEN ELECTED PREMIER OF SETATS\n");
|
||||
print("DETINU, A SMALL COMMUNIST ISLAND 30 BY 70 MILES LONG. YOUR\n");
|
||||
print("JOB IS TO DECIDE UPON THE CONTRY'S BUDGET AND DISTRIBUTE\n");
|
||||
print("MONEY TO YOUR COUNTRYMEN FROM THE COMMUNAL TREASURY.\n");
|
||||
print("THE MONEY SYSTEM IS RALLODS, AND EACH PERSON NEEDS 100\n");
|
||||
print("RALLODS PER YEAR TO SURVIVE. YOUR COUNTRY'S INCOME COMES\n");
|
||||
print("FROM FARM PRODUCE AND TOURISTS VISITING YOUR MAGNIFICENT\n");
|
||||
print("FORESTS, HUNTING, FISHING, ETC. HALF YOUR LAND IS FARM LAND\n");
|
||||
print("WHICH ALSO HAS AN EXCELLENT MINERAL CONTENT AND MAY BE SOLD\n");
|
||||
print("TO FOREIGN INDUSTRY (STRIP MINING) WHO IMPORT AND SUPPORT\n");
|
||||
print("THEIR OWN WORKERS. CROPS COST BETWEEN 10 AND 15 RALLODS PER\n");
|
||||
print("SQUARE MILE TO PLANT.\n");
|
||||
print("YOUR GOAL IS TO COMPLETE YOUR " + n5 + " YEAR TERM OF OFFICE.\n");
|
||||
print("GOOD LUCK!\n");
|
||||
}
|
||||
print("\n");
|
||||
a = Math.floor(60000 + (1000 * Math.random()) - (1000 * Math.random()));
|
||||
b = Math.floor(500 + (10 * Math.random()) - (10 * Math.random()));
|
||||
c = 0;
|
||||
d = 2000;
|
||||
x5 = 0;
|
||||
}
|
||||
v3 = 0;
|
||||
b5 = 0;
|
||||
x = false;
|
||||
while (1) {
|
||||
w = Math.floor(10 * Math.random() + 95);
|
||||
print("\n");
|
||||
print("YOU NOW HAVE " + a + " RALLODS IN THE TREASURY.\n");
|
||||
print(b + " COUNTRYMEN, ");
|
||||
v9 = Math.floor(((Math.random() / 2) * 10 + 10));
|
||||
if (c != 0)
|
||||
print(c + " FOREIGN WORKERS, ");
|
||||
print("AND " + Math.floor(d) + " SQ. MILES OF LAND.\n");
|
||||
print("THIS YEAR INDUSTRY WILL BUY LAND FOR " + w + " ");
|
||||
print("RALLODS PER SQUARE MILE.\n");
|
||||
print("LAND CURRENTLY COSTS " + v9 + " RALLODS PER SQUARE MILE TO PLANT.\n");
|
||||
print("\n");
|
||||
while (1) {
|
||||
print("HOW MANY SQUARE MILES DO YOU WISH TO SELL TO INDUSTRY");
|
||||
h = parseInt(await input());
|
||||
if (h < 0)
|
||||
continue;
|
||||
if (h <= d - 1000)
|
||||
break;
|
||||
print("*** THINK AGAIN. YOU ONLY HAVE " + (d - 1000) + " SQUARE MILES OF FARM LAND.\n");
|
||||
if (x == false) {
|
||||
print("\n");
|
||||
print("(FOREIGN INDUSTRY WILL ONLY BUY FARM LAND BECAUSE\n");
|
||||
print("FOREST LAND IS UNECONOMICAL TO STRIP MINE DUE TO TREES,\n");
|
||||
print("THICKER TOP SOIL, ETC.)\n");
|
||||
x = true;
|
||||
}
|
||||
}
|
||||
d = Math.floor(d - h);
|
||||
a = Math.floor(a + (h * w));
|
||||
while (1) {
|
||||
print("HOW MANY RALLODS WILL YOU DISTRIBUTE AMONG YOUR COUNTRYMEN");
|
||||
i = parseInt(await input());
|
||||
if (i < 0)
|
||||
continue;
|
||||
if (i < a)
|
||||
break;
|
||||
if (i == a) {
|
||||
j = 0;
|
||||
k = 0;
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
print(" THINK AGAIN. YOU'VE ONLY " + a + " RALLODS IN THE TREASURY\n");
|
||||
}
|
||||
if (a) {
|
||||
a = Math.floor(a - i);
|
||||
while (1) {
|
||||
print("HOW MANY SQUARE MILES DO YOU WISH TO PLANT");
|
||||
j = parseInt(await input());
|
||||
if (j < 0)
|
||||
continue;
|
||||
if (j <= b * 2) {
|
||||
if (j <= d - 1000) {
|
||||
u1 = Math.floor(j * v9);
|
||||
if (u1 > a) {
|
||||
print(" THINK AGAIN. YOU'VE ONLY " + a + " RALLODS LEFT IN THE TREASURY.\n");
|
||||
continue;
|
||||
} else if (u1 == a) {
|
||||
k = 0;
|
||||
a = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
print(" SORRY, BUT YOU'VE ONLY " + (d - 1000) + " SQ. MILES OF FARM LAND.\n");
|
||||
continue;
|
||||
}
|
||||
print(" SORRY, BUT EACH COUNTRYMAN CAN ONLY PLANT 2 SQ. MILES.\n");
|
||||
}
|
||||
}
|
||||
if (a) {
|
||||
a -= u1;
|
||||
while (1) {
|
||||
print("HOW MANY RALLODS DO YOU WISH TO SPEND ON POLLUTION CONTROL");
|
||||
k = parseInt(await input());
|
||||
if (k < 0)
|
||||
continue;
|
||||
if (k <= a)
|
||||
break;
|
||||
print(" THINK AGAIN. YOU ONLY HAVE " + a + " RALLODS REMAINING.\n");
|
||||
}
|
||||
}
|
||||
if (h == 0 && i == 0 && j == 0 && k == 0) {
|
||||
print("GOODBYE.\n");
|
||||
print("(IF YOU WISH TO CONTINUE THIS GAME AT A LATER DATE, ANSWER\n");
|
||||
print("'AGAIN' WHEN ASKED IF YOU WANT INSTRUCTIONS AT THE START\n");
|
||||
print("OF THE GAME).\n");
|
||||
return;
|
||||
}
|
||||
print("\n");
|
||||
print("\n");
|
||||
a = Math.floor(a - k);
|
||||
a4 = a;
|
||||
if (Math.floor(i / 100 - b) < 0) {
|
||||
if (i / 100 < 50) {
|
||||
hate_your_guts();
|
||||
break;
|
||||
}
|
||||
print(Math.floor(b - (i / 100)) + " COUNTRYMEN DIED OF STARVATION\n");
|
||||
}
|
||||
f1 = Math.floor(Math.random() * (2000 - d));
|
||||
if (k >= 25)
|
||||
f1 = Math.floor(f1 / (k / 25));
|
||||
if (f1 > 0)
|
||||
print(f1 + " COUNTRYMEN DIED OF CARBON-MONOXIDE AND DUST INHALATION\n");
|
||||
funeral = false;
|
||||
if (Math.floor((i / 100) - b) >= 0) {
|
||||
if (f1 > 0) {
|
||||
print(" YOU WERE FORCED TO SPEND " + Math.floor(f1 * 9) + " RALLODS ON ");
|
||||
print("FUNERAL EXPENSES.\n");
|
||||
b5 = f1;
|
||||
a = Math.floor(a - (f1 * 9));
|
||||
funeral = true;
|
||||
}
|
||||
} else {
|
||||
print(" YOU WERE FORCED TO SPEND " + Math.floor((f1 + (b - (i / 100))) * 9));
|
||||
print(" RALLODS ON FUNERAL EXPENSES.\n");
|
||||
b5 = Math.floor(f1 + (b - (i / 100)));
|
||||
a = Math.floor(a - ((f1 + (b - (i / 100))) * 9));
|
||||
funeral = true;
|
||||
}
|
||||
if (funeral) {
|
||||
if (a < 0) {
|
||||
print(" INSUFFICIENT RESERVES TO COVER COST - LAND WAS SOLD\n");
|
||||
d = Math.floor(d + (a / w));
|
||||
a = 0;
|
||||
}
|
||||
b = Math.floor(b - b5);
|
||||
}
|
||||
c1 = 0;
|
||||
if (h != 0) {
|
||||
c1 = Math.floor(h + (Math.random() * 10) - (Math.random() * 20));
|
||||
if (c <= 0)
|
||||
c1 += 20;
|
||||
print(c1 + " WORKERS CAME TO THE COUNTRY AND ");
|
||||
}
|
||||
p1 = Math.floor(((i / 100 - b) / 10) + (k / 25) - ((2000 - d) / 50) - (f1 / 2));
|
||||
print(Math.abs(p1) + " COUNTRYMEN ");
|
||||
if (p1 >= 0)
|
||||
print("CAME TO");
|
||||
else
|
||||
print("LEFT");
|
||||
print(" THE ISLAND.\n");
|
||||
b = Math.floor(b + p1);
|
||||
c = Math.floor(c + c1);
|
||||
u2 = Math.floor(((2000 - d) * ((Math.random() + 1.5) / 2)));
|
||||
if (c != 0) {
|
||||
print("OF " + Math.floor(j) + " SQ. MILES PLANTED,");
|
||||
}
|
||||
if (j <= u2)
|
||||
u2 = j;
|
||||
print(" YOU HARVESTED " + Math.floor(j - u2) + " SQ. MILES OF CROPS.\n");
|
||||
if (u2 != 0 && t1 < 2) {
|
||||
print(" (DUE TO ");
|
||||
if (t1 != 0)
|
||||
print("INCREASED ");
|
||||
print("AIR AND WATER POLLUTION FROM FOREIGN INDUSTRY.)\n");
|
||||
}
|
||||
q = Math.floor((j - u2) * (w / 2));
|
||||
print("MAKING " + q + " RALLODS.\n");
|
||||
a = Math.floor(a + q);
|
||||
v1 = Math.floor(((b - p1) * 22) + (Math.random() * 500));
|
||||
v2 = Math.floor((2000 - d) * 15);
|
||||
print(" YOU MADE " + Math.abs(Math.floor(v1 - v2)) + " RALLODS FROM TOURIST TRADE.\n");
|
||||
if (v2 != 0 && v1 - v2 < v3) {
|
||||
print(" DECREASE BECAUSE ");
|
||||
g1 = 10 * Math.random();
|
||||
if (g1 <= 2)
|
||||
print("FISH POPULATION HAS DWINDLED DUE TO WATER POLLUTION.\n");
|
||||
else if (g1 <= 4)
|
||||
print("AIR POLLUTION IS KILLING GAME BIRD POPULATION.\n");
|
||||
else if (g1 <= 6)
|
||||
print("MINERAL BATHS ARE BEING RUINED BY WATER POLLUTION.\n");
|
||||
else if (g1 <= 8)
|
||||
print("UNPLEASANT SMOG IS DISCOURAGING SUN BATHERS.\n");
|
||||
else if (g1 <= 10)
|
||||
print("HOTELS ARE LOOKING SHABBY DUE TO SMOG GRIT.\n");
|
||||
}
|
||||
v3 = Math.floor(a + v3); // Probable bug from original game
|
||||
a = Math.floor(a + v3);
|
||||
if (b5 > 200) {
|
||||
print("\n");
|
||||
print("\n");
|
||||
print(b5 + " COUNTRYMEN DIED IN ONE YEAR!!!!!\n");
|
||||
print("DUE TO THIS EXTREME MISMANAGEMENT, YOU HAVE NOT ONLY\n");
|
||||
print("BEEN IMPEACHED AND THROWN OUT OF OFFICE, BUT YOU\n");
|
||||
m6 = Math.floor(Math.random() * 10);
|
||||
if (m6 <= 3)
|
||||
print("ALSO HAD YOUR LEFT EYE GOUGED OUT!\n");
|
||||
else if (m6 <= 6)
|
||||
print("HAVE ALSO GAINED A VERY BAD REPUTATION.\n");
|
||||
else
|
||||
print("HAVE ALSO BEEN DECLARED NATIONAL FINK.\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
if (b < 343) {
|
||||
hate_your_guts();
|
||||
break;
|
||||
}
|
||||
if (a4 / 100 > 5 && b5 - f1 >= 2) {
|
||||
print("\n");
|
||||
print("MONEY WAS LEFT OVER IN THE TREASURY WHICH YOU DID\n");
|
||||
print("NOT SPEND. AS A RESULT, SOME OF YOUR COUNTRYMEN DIED\n");
|
||||
print("OF STARVATION. THE PUBLIC IS ENRAGED AND YOU HAVE\n");
|
||||
print("BEEN FORCED TO EITHER RESIGN OR COMMIT SUICIDE.\n");
|
||||
print("THE CHOICE IS YOURS.\n");
|
||||
print("IF YOU CHOOSE THE LATTER, PLEASE TURN OFF YOUR COMPUTER\n");
|
||||
print("BEFORE PROCEEDING.\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
if (c > b) {
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("THE NUMBER OF FOREIGN WORKERS HAS EXCEEDED THE NUMBER\n");
|
||||
print("OF COUNTRYMEN. AS A MINORITY, THEY HAVE REVOLTED AND\n");
|
||||
print("TAKEN OVER THE COUNTRY.\n");
|
||||
break;
|
||||
}
|
||||
if (n5 - 1 == x5) {
|
||||
print("\n");
|
||||
print("\n");
|
||||
print("CONGRATULATIONS!!!!!!!!!!!!!!!!!!\n");
|
||||
print("YOU HAVE SUCCESFULLY COMPLETED YOUR " + n5 + " YEAR TERM\n");
|
||||
print("OF OFFICE. YOU WERE, OF COURSE, EXTREMELY LUCKY, BUT\n");
|
||||
print("NEVERTHELESS, IT'S QUITE AN ACHIEVEMENT. GOODBYE AND GOOD\n");
|
||||
print("LUCK - YOU'LL PROBABLY NEED IT IF YOU'RE THE TYPE THAT\n");
|
||||
print("PLAYS THIS GAME.\n");
|
||||
print("\n");
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
x5++;
|
||||
b5 = 0;
|
||||
}
|
||||
if (Math.random() <= 0.5) {
|
||||
print("YOU HAVE BEEN ASSASSINATED.\n");
|
||||
} else {
|
||||
print("YOU HAVE BEEN THROWN OUT OF OFFICE AND ARE NOW\n");
|
||||
print("RESIDING IN PRISON.\n");
|
||||
}
|
||||
print("\n");
|
||||
print("\n");
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user