Skip to content

Instantly share code, notes, and snippets.

@pasamio
Created November 13, 2021 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasamio/3238964489c6594ab1983b7aaa02b91b to your computer and use it in GitHub Desktop.
Save pasamio/3238964489c6594ab1983b7aaa02b91b to your computer and use it in GitHub Desktop.
// ========== Prompter Functions Start ========== //
// NAME: Prompter Functions
// VERSION: 1.0
/**
* Prompter Functions for using the async system to handle some requests.
*/
// Temporary variable to store callback details.
var prompterTempVar = undefined;
/**
* Prompt a confirmation dialog with a simple message.
*
* NOTE: This method uses async, please make sure your calling method is declared 'async'.
*
* @param {string} text - The text to display in the dialog for the confirmation.
* @param {string} continueTitle - The text for the continue button.
* @param {string} cancelTitle - The text for the cancel button.
*
* @return {boolean} Boolean result if the user confirmed or declined the dialog.
*/
function promptConfirm(text, continueTitle = 'Continue', cancelTitle = 'Cancel') {
return new Promise(function(resolve, reject) {
let prompter = Prompter .new();
prompter.cancelButtonTitle = cancelTitle;
prompter.continueButtonTitle = continueTitle;
prompter.show(text, ((status) => {
if (status == true) {
resolve(true);
} else {
resolve(false);
}
}));
});
}
/**
* Prompt
*
* NOTE: This method uses async, please make sure your calling method is declared 'async'.
*
* @param {string} text - The text to display in the dialog for the confirmation.
* @param {string} popupName - The prefix to display for the text box of the prompt.
* @param {string} [continueTitle=Continue] - The text for the continue button.
* @param {string} [cancelTitle=Cancel] - The text for the cancel button.
*
* @return {(string|boolean)} The input text or false if cancelled.
*/
function promptText(text, popupName, continueTitle = 'Continue', cancelTitle = 'Cancel'){
return new Promise(function(resolve, reject) {
prompterTempVar = undefined;
let prompter = Prompter .new();
prompter.addParameter(popupName, 'prompterTempVar')
prompter.cancelButtonTitle = cancelTitle;
prompter.continueButtonTitle = continueTitle;
prompter.show(text, ((status) => {
if (status == true && prompterTempVar) {
resolve(prompterTempVar);
} else {
resolve(false);
}
}));
});
}
/**
* Prompt popup list.
*
* NOTE: This method uses async, please make sure your calling method is declared 'async'.
*
* @param {string} text - The text to display in the dialog for the confirmation.
* @param {string} popupName - The prefix to display for the text box of the prompt.
* @param {array} popupList - An array of options to select in the popup.
* @param {string} [continueTitle=Continue] - The text for the continue button.
* @param {string} [cancelTitle=Cancel] - The text for the cancel button.
*
* @return {(string|boolean)} The input text or false if cancelled.
*/
function promptPopup(text, popupName, popupList, continueTitle = 'Continue', cancelTitle = 'Cancel')
{
return new Promise(function(resolve, reject)
{
prompterTempVar = undefined;
let prompter = Prompter .new();
prompter.addParameter(popupName, 'prompterTempVar', 'popup', popupList);
prompter.cancelButtonTitle = cancelTitle;
prompter.continueButtonTitle = continueTitle;
prompter.show(text, ((status) =>
{
if (status == true && prompterTempVar)
{
resolve(prompterTempVar);
} else
{
resolve(false);
}
}));
});
}
// ========== Prompter Functions End ========== //
// rand maps to Math.random(), shorthand.
function rand() {
return Math.random();
}
// Disp takes a list of strings and turns it into an alert with message.
function Disp(title, ...entries) {
Utils.alertWithMessage(title, entries.join("\n"));
}
// DispInput takes a list of strings and makes a confirmation dialog.
function DispInput(...entries) {
return promptConfirm(entries.join("\n"), "Yes", "No");
}
// DispMenu is a shortcut to emulate the menu with a popup prompt.
function DispMenu(title, label, ...entries) {
return promptPopup(title, label, entries);
}
// https://gist.github.com/mattmanning/1002653 mattmanning/drugwars.txt
// Lbl G
async function Game() {
try {
// ClrHome
// Disp " J.M.'S DRUGWAR"," SIMULATION",""," VERSION 2.00",""," JUST SAY NO."
Disp("J.M.'S DRUGWAR SIMULATION","VERSION 2.00",""," JUST SAY NO.");
// 2000→Z
Z = 2000;
// 5000→Y
Y = 5000;
// 0→V
V = 0;
//100→K
K = 100;
//1→B
B = 1;
//2→N
U = 2; // two things use N, rename to U for location
// 0→I
I = 0;
// 0→J
J = 0;
// 100→T
T = 100;
// 0→M
M = 0;
// 0→N
N = 0;
// 0→O
O = 0;
// 0→P
P = 0;
// 0→Q
Q = 0;
// 0→R
R = 0;
//Pause
//ClrHome
//Disp "","ORIGINAL GAME","FOR IBM BY:"," JOHN E. DELL",""
Utils.alertWithMessage("", ["ORIGINAL GAME","FOR IBM BY:"," JOHN E. DELL",""].join("\n"));
// Disp "INSTRUCTIONS?"
// Input "(1=YES,2=NO)",X
X = await DispMenu("", "INSTRUCTIONS", "Yes", "No");
console.log(X);
// handle cancel option
if (!X) {
console.log("Cancelled instructions, exiting game");
return;
}
// If X=1
// Then
if (X == "Yes") {
// ClrHome
// Disp "THIS IS A GAME","OF BUYING AND","SELLING. YOUR","GOAL IS TO PAY-","OFF YOUR DEBT TO","THE LOAN SHARK,","AND THEN MAKE AS"
Disp("THIS IS A GAME","OF BUYING AND","SELLING. YOUR","GOAL IS TO PAY-","OFF YOUR DEBT TO","THE LOAN SHARK,","AND THEN MAKE AS",
// Pause
// ClrHome
// Disp "MUCH MONEY AS","POSSIBLE IN A 1","MONTH PERIOD.","WATCH-OUT FOR","THE POLICE IF","YOU DEAL TOO","HEAVILY!"
"MUCH MONEY AS","POSSIBLE IN A 1","MONTH PERIOD.","WATCH-OUT FOR","THE POLICE IF","YOU DEAL TOO","HEAVILY!",
// Pause
// ClrHome
// Disp "PRICES FOR DRUGS","ARE:","COCAINE:","15000-28000","HEROINE:","5000-12000","ACID: 1000-4200"
"PRICES FOR DRUGS","ARE:","COCAINE:","15000-28000","HEROINE:","5000-12000","ACID: 1000-4200",
// Pause
// Disp "WEED: 300-720","SPEED: 70-220","LUDES: 10-50"
"WEED: 300-720","SPEED: 70-220","LUDES: 10-50",
// Pause
// ClrHome
// Disp "GENERALY, TYPE","THE FIRST LETTER","OF WHAT YOU WANT","TO DO, I.E.:","W=WEED, L=LUDES","ETC..."
"GENERALY, TYPE","THE FIRST LETTER","OF WHAT YOU WANT","TO DO, I.E.:","W=WEED, L=LUDES","ETC...",
// Pause
// Disp "BUT, 1=YES AND","2=NO"
"BUT, 1=YES AND","2=NO",
// Pause
// ClrHome
// Disp "THE LAST NUMBER","IN THE PRICES","LIST IS YOUR","WALLET. THE LAST","NUMBER IN YOUR","TRENCHCOAT IS","FREE SPACE."
"THE LAST NUMBER","IN THE PRICES","LIST IS YOUR","WALLET. THE LAST","NUMBER IN YOUR","TRENCHCOAT IS","FREE SPACE.");
// Pause
// End
}
// Lbl θ
playing = true;
round = 0;
while (playing) {
round++;
/* // failsafe durig development/debugging
if (round % 5 == 0) {
playing = await promptConfirm("Still playing?");
console.log(playing);
if (!playing) {
return;
}
}
*/
// round(rand*12000+16000,0)→C
C = Math.round(rand()*12000+16000,0);
// round(rand*7000+5000,0)→H
H = Math.round(rand()*7000+5000,0);
// round(rand*34+10,0)*100→A
A = Math.round(rand()*34+10,0)*100;
// round(rand*42+33,0)*10→W
W = Math.round(rand()*42+33,0)*1;
// round(rand*15+7,0)*10→S
S = Math.round(rand()*15+7,0)*10;
// round(rand*4+1,0)*10→L
L = Math.round(rand()*4+1,0)*10;
// round(rand*20,0)→D
D = Math.round(rand()*20,0);
console.log(D);
// If D=1
// Then
if (D == 1) {
// ClrHome
// Disp "RIVAL DEALERS","ARE SELLING","CHEAP LUDES!!!"
Disp("RIVAL DEALERS","ARE SELLING","CHEAP LUDES!!!");
// Pause
// 2→L
L = 2;
// End
}
// If D=2
// Then
if (D == 2) {
// ClrHome
// Disp "WEED PRICES HAVE","BOTTOMED-OUT!!!"
Disp("WEED PRICES HAVE", "BOTTOMED-OUT!!!");
// Pause
// 122→W
W = 122
// End
}
// If D=3
// Then
if (D == 3) {
// ClrHome
// Disp "PIGS ARE SELLING","CHEAP HEROINE","FROM LAST WEEK'S","RAID!!!!"
Disp("PIGS ARE SELLING","CHEAP HEROINE","FROM LAST WEEK'S","RAID!!!!");
// Pause
// rand→H
H = Math.random();
// (850+(H*1150))→H
H = 850 + (H*1150);
// (int(H)→H
H = parseInt(H);
// End
}
// If D=4 or D=5
// Then
if (D == 4 || D == 5) {
// ClrHome
// Disp "ADDICTS ARE","BUYING HEROINE","AT OUTRAGEOUS","PRICES!!!"
Disp("ADDICTS ARE","BUYING HEROINE","AT OUTRAGEOUS","PRICES!!!");
// Pause
// rand→H
H = Math.random();
// (18000+(H*25000))→H
H = (18000+(H*25000));
// (int(H)→H
H = parseInt(H);
// End
}
// If D=6 or D=7
// Then
if (D == 6 || D == 7) {
// ClrHome
// Disp "PIGS MADE A BIG","COKE BUST!","PRICES ARE","OUTRAGEOUS!!!!"
Disp("PIGS MADE A BIG","COKE BUST!","PRICES ARE","OUTRAGEOUS!!!!");
// Pause
// rand→C
C = Math.random();
// (80000+(C*60000))→C
C = (80000+(C*60000));
// (int(C)→C
C = parseInt(C);
// End
}
// If D=8
// Then
if (D == 8) {
// ClrHome
// Disp "YOU WERE MUGGED","IN THE SUBWAY!"
Disp("YOU WERE MUGGED","IN THE SUBWAY!");
// Pause
// (Z/3)→Z
Z = Z / 3;
// (int(Z)→Z
Z = parseInt(Z);
// (Z*2)→Z
Z = Z * 2;
// End
}
// If D=15 and Z≥300
// Then
if (D == 15 && Z >= 300) {
// ClrHome
// Disp "WILL YOU BUY A","NEW TRENCHCOAT","WITH MORE","POCKETS FOR 200","BUCKS?"
// Input X
X = await DispInput("WILL YOU BUY A","NEW TRENCHCOAT","WITH MORE","POCKETS FOR 200","BUCKS?");
console.log("Trenchcoat?");
console.log(X);
// If X=1
// Then
if (X == "Yes" || X === true) {
console.log("Increase trenchcoat");
// (T+10)→T
T = T + 10;
// (T-M-N-O-P-Q-R)→K
K = T - M - N - O - P - Q - R;
// (Z-200)→Z
Z = Z - 200;
// End
}
// End
}
// If D=14
// Then
if (D == 14) {
// ClrHome
// Disp "THERE'S SOME","WEED HERE THAT","SMELLS LIKE GOOD","STUFF!!"
Disp("THERE'S SOME","WEED HERE THAT","SMELLS LIKE GOOD","STUFF!!");
// Pause
// Disp "WILL YOU SMOKE"
// Input "IT?",X
X = await DispInput("WILL YOU SMOKE", "IT?");
console.log("Will you smoke it?");
console.log(X);
// If X=1
// Then
if (X == "Yes" || X === true) {
// ClrHome
// Disp "YOU HALLUCINATE","ON THE WILDEST","TRIP OF YOUR","LIFE,"
Disp("YOU HALLUCINATE","ON THE WILDEST","TRIP OF YOUR","LIFE,",
// Pause
// Disp "STUMBLE ON TO","THE SUBWAY","TRACKS AND GET","CREAMED BY A","TRAIN."
"STUMBLE ON TO","THE SUBWAY","TRACKS AND GET","CREAMED BY A","TRAIN.",
// Pause
// ClrHome
// Disp "JUST SAY NO TO","DRUGS."
"JUST SAY NO TO","DRUGS.");
// Pause
// Goto C
playing = await lblC();
continue;
// End
}
// End
}
// If Z≥500 and K≥5
// Then
if (Z >= 500 && K >= 5) {
// If D=12 or D=13
// Then
if (D == 12 || D == 13) {
// ClrHome
// Disp "WILL YOU BUY A"
message = ["WILL YOU BUY A"];
// round(rand*2,0)→X
X = Math.round(Math.random()*2);
// If X=0
if (X == 0) {
// Disp "BARRETTA"
message.push("BARRETTA");
}
// If X=1
if (X == 1) {
// Disp "SATURDAY NIGHT","SPECIAL"
message.push(...["SATURDAY NIGHT","SPECIAL"]);
}
// If X=2
if (X == 2) {
// Disp ".44 MAGNUM"
message.push(".44 MAGNUM");
}
// Disp "FOR 400 DOLLARS?"
message.push("FOR 400 DOLLARS?");
// Input X
X = await DispInput(...message);
console.log(X);
// If X=1
// Then
if (X == "Yes" || X === true) {
console.log("Bought weapon");
// (I+1)→I
I = I + 1;
// (Z-400)→Z
Z = Z - 400;
// (T-5)→T
T = T - 5;
// (T-M-N-O-P-Q-R)→K
K = T-M-N-O-P-Q-R;
// End
}
// End
}
// End
}
// If D=16 and K≥8
// Then
if (D == 16 && K >= 8) {
// int((rand*7+1)→F
F = parseInt(rand()*7+1);
// ClrHome
// Disp "YOU FOUND:",F,"UNITS OF:"
message = ["YOU FOUND:",F,"UNITS OF:"];
// int((rand*5)→X
X = parseInt(rand()*5);
switch(X) {
// If X=0
// Then
case 0:
// Disp " LUDES"
message.push("LUDES");
// (R+F)→R
R = R + F;
// End
break;
// If X=1
// Then
case 1:
// Disp " SPEED"
message.push("SPEED");
// (Q+F)→Q
Q = Q + F;
// End
break;
// If X=2
// Then
case 2:
// Disp " WEED"
message.push("WEED");
// (P+F)→P
P = P + F;
// End
break;
// If X=3
// Then
case 3:
// Disp " ACID"
message.push("ACID");
// (O+F)→O
O = O+F;
// End
break;
// If X=4
// Then
case 4:
// Disp " HEROINE"
message.push("HEROINE");
// (N+F)→N
N = N + F;
// End
break;
// If X=5
// Then
case 5:
// Disp " COCAINE"
message.push("COCAINE");
// (M+F)→M
M = M + F;
// End
break;
}
// Disp "ON A DEAD DUDE","IN THE SUBWAY!!!"
message.push(...["ON A DEAD DUDE","IN THE SUBWAY!!!"]);
Disp(...message);
// (T-M-N-O-P-Q-R)→K
K = T-M-N-O-P-Q-R;
// Pause
// Goto A
// ???
// End
}
// If D=17
// Then
if (D == 17) {
// ClrHome
// Disp "THE MARKET HAS","BEEN FLOODED","WITH CHEAP HOME-","MADE ACID!!!!"
Disp("THE MARKET HAS","BEEN FLOODED","WITH CHEAP HOME-","MADE ACID!!!!");
// int((250+(rand*550))→A
A = parseInt(250+(rand()*550));
// Pause
// Goto A
// End
}
// If D=9 or D=10 or D=11
// Then
if (D == 9 || D == 10 || D == 11) {
// If (M+N+O+P+Q+R)≥50
// Then
if ((M+N+O+P+Q+R) >= 50) {
// ClrHome
switch(D) {
// If D=9
case 9:
// 1→D
D = 1;
break;
// If D=10
case 10:
// 3→D
D = 3;
break;
// If D=11
case 11:
// 4→D
D = 4;
}
// Disp "OFFICER HARDASS","AND",D,"OF HIS DEPPUTIES","ARE AFTER YOU!"
Disp("OFFICER HARDASS","AND",D,"OF HIS DEPPUTIES","ARE AFTER YOU!");
// Pause
// ClrHome
// Lbl M
fighting = true;
while (fighting) {
// Menu("BEING CHASED!!","VIEW GUNS",H,"VIEW DAMMAGE",I,"NUMBER OF PIGS",J,"RUN",K,"FIGHT",L)
option = await DispMenu("BEING CHASED!!","Action", "VIEW GUNS","VIEW DAMMAGE","NUMBER OF PIGS","RUN","FIGHT");
console.log(option);
switch(option) {
// Lbl H
case "VIEW GUNS":
// ClrHome
// Disp "NUMBER OF GUNS","YOU HAVE:"
Disp("NUMBER OF GUNS","YOU HAVE:",
// Disp I
I);
// Pause
// Goto M
break;
// Lbl I
case "VIEW DAMAGE":
// ClrHome
// Disp "YOUR DAMMAGE="
Disp("You DAMMAGE=",
// Disp J
J,
// Disp "(50 DAMMAGE AND","YOU DIE!)"
"(50 DAMMAGE AND","YOU DIE!)");
// Pause
// Goto M
break;
// Lbl J
case "NUMBER OF PIGS":
// ClrHome
// Disp "THERE ARE:"
Disp("THERE ARE: ",
// (D+1)→D
// Disp D
// (D-1)→D
D+1,
// Disp "PIGS STILL","CHASING YOU!"
"PIGS STILL","CHASING YOU!");
// Pause
// Goto M
break;
// Lbl K
case "RUN":
// ClrHome
// Disp "","","",""," RUNNING"
Disp("","","",""," RUNNING");
// round(rand*1,0)→X
X = Math.round(rand()* 1);
// If X=0
// Then
if (X == 0) {
// ClrHome
// Disp "YOU LOST THEM IN","AN ALLEY!!"
Disp("YOU LOST THEM IN","AN ALLEY!!");
// Pause
// If B=31
// Then
if (B == 31) {
// Goto A
lblA();
// Else
} else {
// Goto θ
fighting = false;
continue; // this feels wrong?
// End
}
// End
}
// If X=1
// Then
if (X == 1) {
// ClrHome
// Disp "YOU CAN'T SHAKE","THEM!"
Disp("YOU CAN'T SHAKE","THEM!");
// Pause
// Goto O
if (!lblO()) {
continue;
}
// End
}
// Lbl L
case "FIGHT":
// If I=0
// Then
if (I == 0) {
// ClrHome
// Disp "YOU DON'T HAVE","ANY GUNS!"
Disp("YOU DON'T HAVE","ANY GUNS!");
// Pause
// Disp "YOU HAVE TO RUN!"
Disp("YOU HAVE TO RUN!");
// Pause
// Goto M
// Else
} else {
// round(rand*1,0)→X
X = Math.round(rand * 1);
// If X=0
// Then
if (X == 0) {
// ClrHome
// Disp "YOU MISSED!!!"
Disp("YOU MISSED!!!");
// Pause
// Else
} else {
// ClrHome
// Disp "YOU KILLED ONE!!"
Disp("YOU KILLED ONE!!");
// Pause
// (D-1)→D
D = D - 1;
// If D=(-1)
if (D == -1) {
// Goto N
}
// End
}
// Normally the script would fall into this block
// But since we don't have goto in JS, we do this.
if (!lblO()) {
continue;
}
}
break;
// Lbl O
async function lblO() {
// round(rand*1,0)→X
X = Math.round(rand() * 1)
// ClrHome
// Disp "THEY'RE FIRING","AT YOU!!"
message = ["THEY'RE FIRING","AT YOU!!"];
// If X=0
// Then
if (X == 0) {
// Disp "THEY MISSED!!"
message.push("THEY MISSED!!");
Disp(...message);
// Pause
// Goto M
// Else
} else {
// Disp "YOU'VE BEEN HIT!"
Disp("YOU'VE BEEN HIT!");
// (J+3)→J
J = J + 3;
// Pause
// If J≥50
// Then
if (J >= 50) {
// Disp "YOU'VE BEEN ","KILLED!!"
Disp("YOU'VE BEEN ","KILLED!!");
// Pause
// Goto C
playing = await lblC();
return false;
// End
}
// Goto M
// End
}
return true;
}
// Lbl N
function lblN() {
// ClrHome
// Disp "YOU KILLED ALL","OF THEM!"
Disp("YOU KILLED ALL","OF THEM!");
// int((rand*1250+750)→X
X = parseInt(rand()*1250+750);
// (Z+X)→Z
Z = Z + X
// Pause
// Disp "YOU FOUND"
Disp("YOU FOUND",
// Disp X
X,
// Disp "DOLLARS ON","OFFICER HARDASS'","CARCASS!!"
"DOLLARS ON","OFFICER HARDASS'","CARCASS!!");
// Pause
// If Z≥1200
// Then
if (Z >= 1200) {
// ClrHome
// Disp "WILL YOU PAY","1000 DOLLARS FOR","A DOCTOR TO SEW","YOU UP?"
// Input X
X = DispInput("WILL YOU PAY","1000 DOLLARS FOR","A DOCTOR TO SEW","YOU UP?");
// If X=1
// Then
if (X == "YES") {
// (Z-1000)→Z
Z = Z - 1000;
// 0→J
J = 0;
// End
}
// End
}
// End
}
// End
}
// End
}
}
}
// -- this is the main menu
playing = await lblA();
}
} catch(e) { console.log(e); }
}
// Lbl A
async function lblA() {
menu = true;
while(menu) {
// ClrHome
// Menu("DRUGWAR!","SEE PRICES",1,"TRENCHCOAT",2,"BUY",3,"SELL",4,"JET",5,"SEE LOAN SHARK",6,"VISIT BANK",7)
option = await DispMenu("DRUGWAR!","Action", "SEE PRICES","TRENCHCOAT","BUY","SELL","JET","SEE LOAN SHARK","VISIT BANK", "QUIT");
console.log(option);
switch(option) {
case "QUIT":
return false;
// Lbl 1
case "SEE PRICES":
// ClrHome
// Disp C,H,A,W,S,L,Z
// Output(1,1,"COCAINE")
// Output(2,1,"HEROINE")
// Output(3,1,"ACID")
// Output(4,1,"WEED")
// Output(5,1,"SPEED")
// Output(6,1,"LUDES")
// Output(7,1,"WALLET")
Disp("PRICES", C + " COCAINE",
H + " HEROINE",
A + " ACID",
W + " WEED",
S + " SPEED",
L + " LUDES",
Z + " WALLET");
// Pause
// Goto A
break;
// Lbl 2
case "TRENCHCOAT":
// ClrHome
// Disp M,N,O,P,Q,R,K
// Output(1,1,"COCAINE")
// Output(2,1,"HEROINE")
// Output(3,1,"ACID")
// Output(4,1,"WEED")
// Output(5,1,"SPEED")
// Output(6,1,"LUDES")
// Output(7,1,"FREE SPACE")
Disp("TRENCHCOAT", M + " COCAINE",
N + " HEROINE",
O + " ACID",
P + " WEED",
Q + " SPEED",
R + " LUDES",
K + " FREE SPACE");
// Pause
// Goto A
break;
// Lbl 3
case "BUY":
buying = true;
while (buying) {
// ClrHome
// Disp "DAY NUMBER:",B
F = await DispMenu(["DAY NUMBER:",B].join(" "),
// Input "WHAT TO BUY?",F
"WHAT TO BUY?", "COCAINE", "HEROINE", "ACID", "WEED", "SPEED", "LUDES");
// If F≠C and F≠H and F≠A and F≠W and F≠S and F≠L
if (!F) {
// Goto 3
break;
}
// __ map name to variable; user friendliness!
switch (F) {
case "COCAINE":
F = C;
break;
case "HEROINE":
F = H;
break;
case "ACID":
F = A;
break;
case "WEED":
F = W;
break;
case "SPEED":
F = S;
break;
case "LUDES":
F = L;
break;
}
// int((Z/F)→E
E = parseInt(Z/F);
// Disp "HOW MUCH?","YOU CAN AFFORD:",E,"YOU CAN HOLD:",K
// Input G
G = await promptText(["YOU CAN AFFORD:",E,"YOU CAN HOLD:",K].join(" "), "HOW MUCH?");
G = parseInt(G);
// If G>K or G<0 or G>E
if (!G || G > K || G <= 0 || G > E) {
// Goto 3
continue;
}
// (Z-(FG))→Z
Z = Z - (F * G);
// If F=C
if (F == C) {
// (M+G)→M
M = M + G;
}
// If F=H
if (F == H) {
// (N+G)→N
N = N + G;
}
// If F=A
if (F == A) {
// (O+G)→O
O = O + G;
}
// If F=W
if (F == W) {
// (P+G)→P
P = P + G;
}
// If F=S
if (F == S) {
// (Q+G)→Q
Q = Q + G;
}
// If F=L
if (F == L) {
// (R+G)→R
R = R + G;
}
// (T-M-N-O-P-Q-R)→K
K = (T-M-N-O-P-Q-R);
// Goto A
break;
}
break;
// Lbl 4
case "SELL":
// ClrHome
// Disp "DAY NUMBER:",B
F = await DispMenu(["DAY NUMBER:",B].join(" "),
// Input "WHAT TO SELL?",F
"WHAT TO SELL?", "COCAINE", "HEROINE", "ACID", "WEED", "SPEED", "LUDES");
// If F≠C and F≠H and F≠A and F≠W and F≠S and F≠L
if (!F) {
// Goto 4
break;
}
// __ map name to variable; user friendliness!
switch (F) {
case "COCAINE":
F = C;
break;
case "HEROINE":
F = H;
break;
case "ACID":
F = A;
break;
case "WEED":
F = W;
break;
case "SPEED":
F = S;
break;
case "LUDES":
F = L;
break;
}
// If F=C
if (F == C) {
// M→E
E = M;
}
// If F=H
if (F == H) {
// N→E
E = N;
}
// If F=A
if (F == A) {
// O→E
E = O;
}
// If F=W
if (F == W) {
// P→E
E = P;
}
// If F=S
if (F == S) {
// Q→E
E = Q;
}
// If F=L
if (F == L) {
// R→E
E = R;
}
// Disp "HOW MUCH?","YOU HAVE:",E
// Input G
G = await promptText(["YOU HAVE:",E].join(" "), "HOW MUCH?");
G = parseInt(G);
// If G>E or G<0
if (!G || G > E || G <= 0) {
// Goto 4
break;
}
// If F=C
if (F == C) {
// (M-G)→M
M = M - G;
}
// If F=H
if (F == H) {
// (N-G)→N
N = N - G;
}
// If F=A
if ( F == A) {
// (O-G)→O
O = O - G;
}
// If F=W
if (F == W) {
// (P-G)→P
P = P - G;
}
// If F=S
if (F == S) {
// (Q-G)→Q
Q = Q - G;
}
// If F=L
if (F == L) {
// (R-G)→R
R = R - G;
}
// (Z+FG)→Z
Z = Z + F * G;
// (T-M-N-O-P-Q-R)→K
K = T-M-N-O-P-Q-R;
// Goto A
break;
// Lbl 5
case "JET":
jetting = true;
while (jetting) {
// ClrHome
// Menu("WHERE TO, DUDE?","BRONX",R,"GHETTO",B,"CENTRAL PARK",B,"MANHATTEN",B,"CONEY ISLAND",B,"BROOKLYN",B,"OOPS... STAY!",A)
dest = await DispMenu("WHERE TO, DUDE?","Destination", "BRONX","GHETTO","CENTRAL PARK","MANHATTEN","CONEY ISLAND","BROOKLYN","OOPS... STAY!");
console.log(dest);
switch(dest) {
case "OOPS...STAY!":
jetting = false;
break;
// Lbl R
case "BRONX":
// If N=2
// Then
if (U == 2) { // N is U, var conflict rename
// ClrHome
// Disp "YOU'RE ALREADY","IN THE BRONX!"
Disp("YOU'RE ALREADY","IN THE BRONX!");
// Pause
// Goto 5
// End
continue;
}
// 2→N
U=2
//
// Goto S
break;
// Lbl B
default:
// 1→N
U = 1;
break;
}
//
// Lbl S
// ClrHome
// Disp "","","",""," SUBWAY"
Disp("","","",""," SUBWAY")
// (B+1)→B
B = B + 1;
// int((Y*1.1)→Y
Y = parseInt(Y*1.1);
// int((V*1.06)→V
V = parseInt(V*1.06)
// If B=31
if (B == 31) {
// Goto C
return lblC();
}
// Goto θ
return true;
}
break;
// Lbl 6
case "SEE LOAN SHARK":
// If N=1
// Then
if (U == 1) { // renamed N to U for location
// ClrHome
// Disp "THE LOAN SHARK","ONLY DEALS IN","THE BRONX."
Disp("THE LOAN SHARK","ONLY DEALS IN","THE BRONX.");
// Pause
// Goto A
// End
break;
}
// ClrHome
// Menu("LOAN SHARK...","REPAY",P,"BORROW",Q)
loan = await DispMenu("LOAN SHARK...", "", "REPAY", "BORROW");
switch(loan) {
// Lbl P
case "REPAY":
// ClrHome
// Disp "YOU'RE DEBT IS:",Y,"YOUR WALLET=",Z,"REPAY HOW MUCH?"
// Input F
F = await promptText(["YOU'RE DEBT IS:",Y,"YOUR WALLET=",Z].join(" "),"REPAY HOW MUCH?");
F = parseInt(F);
// If F>Z or F<0 or F>Y
if (!F || F > Z || F < 0 || F > Y) {
// Goto 6
break;
}
// (Y-F)→Y
Y = Y - F;
// (Z-F)→Z
Z = Z - F;
// Goto A
break;
// Lbl Q
case "BORROW":
// ClrHome
// Disp "YOUR DEBT=",Y,"YOUR WALLET=",Z,"BORROW HOW MUCH"
// Input "MORE?",F
F = await promptText(["YOUR DEBT=",Y,"YOUR WALLET=",Z].join(" "), "BORROW HOW MUCH MORE?");
F = parseInt(F);
// If F>5000
// Then
if (F > 5000) {
// ClrHome
// Disp "YOU THINK HE'S","CRAZY, MAN?!"
Disp("YOU THINK HE'S","CRAZY, MAN?!");
// Pause
// Goto Q
break;
// End
}
// If F<0
if (!F || F < 0) {
// Goto 6
break;
}
// (Y+F)→Y
Y = Y + F;
// (Z+F)→Z
Z = Z + F;
// Goto A
break;
}
break;
// Lbl 7
case "VISIT BANK":
// If N=1
// Then
if (U == 1) { // rename N to U for location
// ClrHome
// Disp "THE BANK IS IN","THE BRONX."
Disp("THE BANK IS IN","THE BRONX.");
// Pause
// Goto A
break;
// End
}
banking = true;;
while (banking) {
// Menu(" BANK ","VIEW ACCOUNT",D,"DEPOSIT",E,"WITHDRAW",F,"GOODBYE",A)
bankopt = await DispMenu("BANK","", "VIEW ACCOUNT","DEPOSIT","WITHDRAW","GOODBYE");
console.log(bankopt);
switch(bankopt) {
// Lbl D
case "VIEW ACCOUNT":
// ClrHome
// Disp "YOUR ACCOUNT=",V
Disp("YOUR ACCOUNT=",V);
// Pause
// Goto 7
break;
// Lbl E
case "DEPOSIT":
// ClrHome
// Disp "HOW MUCH TO","DEPOSIT?","YOU HAVE:",Z
// Input G
G = await promptText(["YOU HAVE:",Z].join(" "), ["HOW MUCH TO","DEPOSIT?"].join(" "));
G = parseInt(G);
// If G>Z or G<0
if (!G || G > Z || G < 0) {
// Goto E
break;
}
// (V+G)→V
V = V + G;
// (Z-G)→Z
Z = Z - G;
// Goto 7
break;
// Lbl F
case "WITHDRAW":
// ClrHome
// Disp "HOW MUCH TO","WITHDRAW?","ACCOUNT=",V
// Input X
X = await promptText(["ACCOUNT=",V].join(" "), ["HOW MUCH TO","WITHDRAW?"].join(" "));
X = parseInt(X);
// If X>V or X<0
if (!X || X > V || X < 0) {
// Goto F
break;
}
// (V-X)→V
V = V - X;
// (Z+X)→Z
Z = Z + X;
// Goto 7
break;
case "GOODBYE":
banking = false;
break;
}
}
break;
}
}
return true;
}
// Lbl C
async function lblC() {
// ClrHome
// Disp " GAME OVER!"
Disp("GAME OVER!");
// (V+Z-Y)→V
V = V + Z - Y;
// If V<0
// Then
if (V < 0) {
// 0→V
V = 0;
// Else
} else {
// (√(V/31.5)→V
V = Math.sqrt(V/ 31.5);
// If V>100
if (V>100) {
// 100→V
V = 100;
}
// End
}
// round(V,0)→V
V = Math.round(V);
// Disp "YOUR SCORE (ON A","SCALE OF 1 TO","100)=",V,""
Disp("YOUR SCORE (ON A","SCALE OF 1 TO","100)=",V,"");
// Pause
// Input "PLAY AGAIN?",V
V = await DispInput("Play Again?")
console.log("Play again?");
console.log(V);
// If V=1
if (V == "Yes" || V === true) {
V=1;
// Goto G1
return true;
} else {
// ClrHome
// Disp " THANKS FOR"," PLAYING!"
Disp(" THANKS FOR"," PLAYING!",
// Pause
// ClrHome
// Disp "","","REMEMBER:","","WATCH YOUR BACK."
"","","REMEMBER:","","WATCH YOUR BACK.",
// Pause
// Disp "","HAVE A NICE DAY!"
"","HAVE A NICE DAY!");
return false;
}
}
try {
console.log("Game start");
Game();d
} catch (e) {
console.log("Runtime Exception");
console.log(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment