var ERR=bcurses.ERR,sum=MochiKit.Iter.sum;function rand(){return Math.floor(Math.random()*32768)}function usleep(A,B){napms(Math.round(A/1000),B)}function createCookie(C,D,E){var B,A;if(E){B=new Date();B.setTime(B.getTime()+E*24*60*60*1000);A="; expires="+B.toGMTString()}else{A=""}document.cookie=C+"="+escape(D)+A+"; path=/"}function readCookie(B){var D,A,C,E;D=B+"=";A=document.cookie.split(";");for(C=0;C<A.length;C++){E=A[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(D)==0){return unescape(E.substring(D.length,E.length))}}return null}function App(){this.GENERIC=1;this.LI_YUEN=2;this.version=2;this.meta=["version","capacity","damage","hkw_","hold_","month","year","wu_warn","wu_bailout","ec","ed","firm","cash","debt","hold","guns","li","bp","bank","port","price","base_price"];this.capacity=60;this.damage=0;this.hkw_=[0,0,0,0];this.hold_=[0,0,0,0];this.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];this.month=1;this.year=1860;this.location=["At sea","Hong Kong","Shanghai","Nagasaki","Saigon","Manila","Singapore","Batavia"];this.st=["Critical","  Poor","  Fair","  Good"," Prime","Perfect"];this.item=["Opium","Silk","Arms","General Cargo"];this.wu_warn=0;this.wu_bailout=0;this.ec=20;this.ed=0.5;this.booty=0;this.firm=undefined;this.cash=undefined;this.debt=undefined;this.hold=undefined;this.guns=undefined;this.li=undefined;this.bp=undefined;this.bank=0;this.port=1;this.price=[];this.base_price=[[1000,11,16,15,14,12,10,13],[100,11,14,15,16,10,13,12],[10,12,16,10,11,13,14,15],[1,10,11,12,13,14,15,16]];initscr();this.main()}App.prototype.marshall=function(){for(var A=0,B={};A<this.meta.length;A++){B[this.meta[A]]=this[this.meta[A]]}return serializeJSON(B)};App.prototype.unmarshall=function(B){var A,C=evalJSON(B);if((C.version==1)&&(this.version>1)){C.version=this.version;C.base_price=this.base_price}for(A=0;A<this.meta.length;A++){this[this.meta[A]]=C[this.meta[A]]}};App.prototype.main=function(){var C=this,B=0;function A(){switch(B){case 0:B++;C.splash_intro(A);break;case 1:B++;C.name_firm(A);break;case 2:B++;C.cash_or_guns(A);break;case 3:C.set_prices();C.loop()}}A()};App.prototype.loop=function(){var B,D=this,C=0;function A(){switch(C){case 0:D.port_stats();C++;if((D.port==1)&&(D.li==0)&&(D.cash>0)){D.li_yuen_extortion(A);return }case 1:C++;if((D.port==1)&&(D.damage>0)){D.mchenry(A);return }case 2:if((D.port!=1)||(D.debt<10000)||D.wu_warn){C=6;A();return }move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Elder Brother Wu has sent "+(rand()%100+50)+" braves\n");printw("to escort you to the Wu mansion, Taipan.\n");refresh();timeout(3000);C++;getch(A);break;case 3:timeout(-1);move(18,0);clrtobot();printw("Elder Brother Wu reminds you of the\n");printw("Confucian ideal of personal worthiness,\n");printw("and how this applies to paying one's\n");printw("debts.\n");refresh();timeout(3000);C++;getch(A);break;case 4:timeout(-1);move(18,0);clrtobot();printw("He is reminded of a fabled barbarian\n");printw("who came to a bad end, after not caring\n");printw("for his obligations.\n\n");printw("He hopes no such fate awaits you, his\n");printw("friend, Taipan.\n");refresh();timeout(5000);C++;getch(A);break;case 5:timeout(-1);D.wu_warn=1;C++;case 6:C++;if(D.port==1){D.elder_brother_wu(A);return }case 7:C=71;if(rand()%4==0){D.new_ship(A);return }case 71:C=8;if(rand()%3==0){D.new_gun(A);return }case 8:if((D.port==1)||rand()%18||!D.hold_[0]){C=10;A();return }B=Math.round((D.cash/1.8)*Math.random())+1;B=B<=D.cash?B:D.cash;D.hold+=D.hold_[0];D.hold_[0]=0;D.cash-=B;D.port_stats();move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Bad Joss!!\n");printw("The local authorities have seized your\n");printw("Opium cargo and have also fined you\n");printw(D.fancy_numbers(B)+", Taipan!\n");refresh();timeout(5000);C++;getch(A);break;case 9:timeout(-1);C++;case 10:if(rand()%50||!(D.hkw_[0]+D.hkw_[1]+D.hkw_[2]+D.hkw_[3])){C=12;A();return }for(B=0;B<4;B++){D.hkw_[B]=Math.round((D.hkw_[B]/1.8)*Math.random())}D.port_stats();move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Messenger reports large theft\n");printw("from warehouse, Taipan.\n");refresh();timeout(5000);C++;getch(A);break;case 11:timeout(-1);C++;case 12:if(rand()%20==0){D.li=0}if((D.port==1)||D.li||(rand()%4==0)){C=14;A();return }move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Li Yuen has sent a Lieutenant,\n");printw("Taipan.  He says his admiral wishes\n");printw("to see you in Hong Kong, posthaste!\n");refresh();timeout(3000);C++;getch(A);break;case 13:timeout(-1);C++;case 14:C++;if(rand()%9==0){D.good_prices(A);return }case 15:if((D.cash<=25000)||rand()%20){C=17;A();return }B=Math.round((D.cash/1.4)*Math.random());D.cash-=B;D.port_stats();move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Bad Joss!!\n");printw("You've been beaten up and\n");printw("robbed of "+D.fancy_numbers(B)+" in cash, Taipan!!\n");refresh();timeout(5000);C++;getch(A);break;case 16:timeout(-1);C++;case 17:C++;D.port_choices(A);break;case 18:B=function(){D.port_choices(A)};switch(arguments[0]){case"B":case"b":D.buy(B);break;case"S":case"s":D.sell(B);break;case"V":case"v":C=15;D.visit_bank(A);break;case"T":case"t":if((D.hkw_[0]==0)&&(D.hold_[0]==0)&&(D.hkw_[1]==0)&&(D.hold_[1]==0)&&(D.hkw_[2]==0)&&(D.hold_[2]==0)&&(D.hkw_[3]==0)&&(D.hold_[3]==0)){C=17}else{C=15}D.transfer(A);break;case"R":case"r":D.retire(B);break;case"L":case"l":D.load(B);break;case"A":case"a":D.save(B);break;case"Q":case"q":if(D.hold>=0){D.quit(bind(D.loop,D))}else{C=15;D.overload(A)}break;default:B();break}break}}A()};App.prototype.splash_intro=function(C){var B=0;function A(){switch(B){case 0:flushinp();clear();printw("\n");printw("         _____  _    ___ ____   _    _   _               ===============\n");printw("        |_   _|/ \\  |_ _|  _ \\ / \\  | \\ | |              Created by:\n");printw("          | | / _ \\  | || |_) / _ \\ |  \\| |                 Art Canfil\n");printw("          | |/ ___ \\ | ||  __/ ___ \\| |\\  |              ===============\n");printw("          |_/_/   \\_\\___|_| /_/   \\_\\_| \\_|              TRS80 code by:\n");printw("                                                            Art Canfil\n");printw("   A game based on the China trade of the 1800's         ===============\n");printw("                                                         ncurses port:\n");printw("                      ~~|     ,                             Jay Link\n");printw("                       ,|`-._/|\n");printw("                     .' |   /||\\                         jaylink1971\n");printw("                   .'   | ./ ||`\\                             @gmail.com\n");printw("                  / `-. |/._ ||  \\                       ===============\n");printw("                 /     `||  `|;-._\\                      Browser port:\n");printw("                 |      ||   ||   \\                         M. X. Heyeck\n");printw("~^~_-~^~=~^~~^= /       ||   ||__  \\~^=~^~-~^~_~^~=      ===============\n");printw(' ~=~^~ _~^~ =~ `--------|`---||  `"-`___~~^~ =_~^=        Press ');attrset(A_REVERSE);printw("ANY");attrset(A_NORMAL);printw(" key\n");printw("~ ~^~=~^_~^~ =~ \\~~~~~~~'~~~~'~~~~/~~`` ~=~^~ ~^=           to start.\n");printw(" ~^=~^~_~-=~^~ ^ `--------------'~^~=~^~_~^=~^~=~\n");curs_set(0);refresh();B++;getch(A);break;case 1:curs_set(1);C()}}A()};App.prototype.flash_msg=function(A,B){timeout(A);getch(function(){timeout(-1);B()})};App.prototype.get_raw=function(B){function A(C){if((C==ERR)||(C.length!=5)){B(ERR)}else{B(C.charAt(4))}}getch(A)};App.prototype.get_one=function(E){var C,B=[],D=0;function A(){switch(D){case 0:D++;getch(A);break;case 1:C=arguments[0];if((C=="KEY_BACKSPACE")||(C=="KEY_DELETE")){if(B.length){printw("\b \b");B.length-=1;refresh()}}else{if((C.length==5)&&!B.length){printw(C.charAt(4));B.push(C.charAt(4));refresh()}}if(B.length&&(C=="KEY_ENTER")){E(B[0])}else{getch(A)}}}A()};App.prototype.get_num=function(F,E){var C,B=[],D=0;function A(){switch(D){case 0:D++;getch(A);break;case 1:C=arguments[0];if(C=="KEY_ENTER"){if(!B.length){E(0)}else{if((B[0]=="A")||(B[0]=="a")){E(-1)}else{E(parseInt(B.join("")))}}return }else{if((C=="KEY_BACKSPACE")||(C=="KEY_DELETE")){if(B.length){printw("\b \b");B.length-=1;refresh()}}else{if((B.length<F)&&(C.length==5)){C=C.charAt(4);if(((C>="0")&&(C<="9"))||(!B.length&&(F>1)&&((C=="A")||(C=="a")))){printw(C);B.push(C);refresh()}}}}getch(A)}}A()};App.prototype.name_firm=function(F){var C,B=[],E=this,D=0;function A(){switch(D){case 0:clear();move(7,0);printw(" _______________________________________\n");printw("|     Taipan,                           |\n");printw("|                                       |\n");printw("| What will you name your               |\n");printw("|                                       |\n");printw("|     Firm:                             |\n");printw("|           ----------------------      |\n");printw("|_______________________________________|\n");move(12,12);refresh();D++;getch(A);break;case 1:C=arguments[0];if((C=="KEY_BACKSPACE")||(C=="KEY_DELETE")){if(B.length){printw("\b \b");B.length-=1;refresh()}}else{if(C=="KEY_SPACEBAR"){printw(" ");B.push(" ");refresh()}else{if(C.length==5){printw(C.charAt(4));B.push(C.charAt(4));refresh()}}}if(B.length&&(C=="KEY_ENTER")||(B.length==22)){E.firm=B.join("");F()}else{getch(A)}}}A()};App.prototype.cash_or_guns=function(E){var B=0,D=this,C=0;function A(){switch(C){case 0:clear();move(5,0);printw("Do you want to start . . .\n\n");printw("  1) With cash (and a debt)\n\n");printw("                >> or <<\n\n");printw("  2) With five guns and no cash\n");printw("                (But no debt!)\n");C++;case 1:B=arguments[0];if((B!="1")&&(B!="2")){move(15,0);clrtoeol();printw("          ?");refresh();D.get_one(A)}else{if(B=="1"){D.cash=400;D.debt=5000;D.hold=60;D.guns=0;D.li=0;D.bp=10}else{D.cash=0;D.debt=0;D.hold=10;D.guns=5;D.li=1;D.bp=7}E()}}}A()};App.prototype.set_prices=function(){this.price[0]=Math.round(this.base_price[0][this.port]/2*(rand()%3+1)*this.base_price[0][0]);this.price[1]=Math.round(this.base_price[1][this.port]/2*(rand()%3+1)*this.base_price[1][0]);this.price[2]=Math.round(this.base_price[2][this.port]/2*(rand()%3+1)*this.base_price[2][0]);this.price[3]=Math.round(this.base_price[3][this.port]/2*(rand()%3+1)*this.base_price[3][0])};App.prototype.port_stats=function(){var E,A=100-Math.round((this.damage/this.capacity)*100),C,B,D;clear();C=12-(this.firm.length/2);for(D=1;D<=C;D++){printw(" ")}printw("Firm: "+this.firm+", Hong Kong\n");printw(" ______________________________________\n");printw("|Hong Kong Warehouse                   |     Date\n");printw("|   Opium           In Use:            |\n");printw("|   Silk                               |\n");printw("|   Arms            Vacant:            |   Location\n");printw("|   General                            |\n");printw("|______________________________________|\n");printw("|Hold               Guns               |     Debt\n");printw("|   Opium                              |\n");printw("|   Silk                               |\n");printw("|   Arms                               |  Ship Status\n");printw("|   General                            |\n");printw("|______________________________________|\n");printw("Cash:               Bank:\n");printw("________________________________________\n");move(3,12);printw(""+this.hkw_[0]);move(4,12);printw(""+this.hkw_[1]);move(5,12);printw(""+this.hkw_[2]);move(6,12);printw(""+this.hkw_[3]);move(8,6);if(this.hold>=0){printw(""+this.hold)}else{attrset(A_REVERSE);printw("Overload");attrset(A_NORMAL)}move(9,12);printw(""+this.hold_[0]);move(10,12);printw(""+this.hold_[1]);move(11,12);printw(""+this.hold_[2]);move(12,12);printw(""+this.hold_[3]);move(14,5);printw(this.fancy_numbers(this.cash));E=this.hkw_[0]+this.hkw_[1]+this.hkw_[2]+this.hkw_[3];move(4,21);printw(""+E);move(6,21);printw(""+(10000-E));move(8,25);printw(""+this.guns);move(14,25);printw(this.fancy_numbers(this.bank));move(3,42);printw("15 ");attrset(A_REVERSE);printw(this.months[this.month-1]);attrset(A_NORMAL);printw(" "+this.year);move(6,43);C=(9-this.location[this.port].length)/2;for(D=1;D<=C;D++){printw(" ")}attrset(A_REVERSE);printw(this.location[this.port]);attrset(A_NORMAL);move(9,41);B=this.fancy_numbers(this.debt);C=(12-B.length)/2;for(D=1;D<=C;D++){printw(" ")}attrset(A_REVERSE);printw(B);attrset(A_NORMAL);D=Math.floor(A/20);if(D<2){attrset(A_REVERSE);move(12,51);printw("  ")}move(12,42);printw(this.st[D]+":"+A);attrset(A_NORMAL)};App.prototype.port_choices=function(F){var B=0,D="",E=this,C=0;function A(){switch(C){case 0:move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Taipan, present prices per unit here are\n");printw("   Opium:          Silk:\n");printw("   Arms:           General:\n");move(19,11);printw(""+E.price[0]);move(19,29);printw(""+E.price[1]);move(20,11);printw(""+E.price[2]);move(20,29);printw(""+E.price[3]);arguments[0]="X";C++;case 1:if(E.port==1){if((E.cash+E.bank-E.debt)>=1000000){D="BSVTLAQR"}else{D="BSVTLAQ"}}else{D="BSLAQ"}B=arguments[0];if(findValue(D.split(""),B)<0){move(22,0);clrtobot();if(E.port==1){if((E.cash+E.bank-E.debt)>=1000000){printw("Shall I Buy, Sell, Visit bank, Transfer\n");printw("cargo, Load, sAve, Quit, or Retire? ");refresh();E.get_one(A)}else{printw("Shall I Buy, Sell, Visit bank, Transfer\n");printw("cargo, Load, sAve, or Quit trading? ");refresh();E.get_one(A)}}else{printw("Shall I Buy, Sell, Load, sAve,\n");printw("or Quit trading? ");refresh();E.get_one(A)}}else{F(B)}}}A()};App.prototype.buy=function(H){var F,B=0,D,C,G=this,E=0;function A(){switch(E){case 0:arguments[0]="X";E++;case 1:if((B=findValue("OSAG".split(""),arguments[0]))<0){move(22,0);clrtobot();printw("What do you wish me to buy, Taipan? ");refresh();G.get_one(A);return }D=Math.floor(G.cash/G.price[B]);arguments[0]=G.cash+1;E++;case 2:if((C=arguments[0])>D){move(21,42);clrtobot();attrset(A_REVERSE);printw(" You can ");attrset(A_NORMAL);move(22,0);printw("How much "+G.item[B]+" shall");move(22,42);attrset(A_REVERSE);printw("  afford ");move(23,42);printw("         ");move(23,42);if(D<100){F="    "}else{if(D<10000){F="   "}else{if(D<1000000){F="  "}else{if(D<100000000){F=" "}else{F=""}}}}printw(F+D);attrset(A_NORMAL);move(23,0);printw("I buy, Taipan: ");refresh();G.get_num(9,A);return }if(C==-1){C=D}G.cash-=(C*G.price[B]);G.hold_[B]+=C;G.hold-=C;G.port_stats();H()}}A()};App.prototype.sell=function(F){var B=0,C,E=this,D=0;function A(){switch(D){case 0:arguments[0]="X";D++;case 1:if((B=findValue("OSAG".split(""),arguments[0]))<0){move(22,0);clrtobot();printw("What do you wish me to sell, Taipan? ");refresh();E.get_one(A);return }arguments[0]=E.hold_[B]+1;D++;case 2:if((C=arguments[0])>E.hold_[B]){move(22,0);clrtobot();printw("How much "+E.item[B]+" shall\n");printw("I sell, Taipan: ");refresh();E.get_num(9,A);return }if(C==-1){C=E.hold_[B]}E.cash+=(C*E.price[B]);E.hold_[B]-=C;E.hold+=C;E.port_stats();F()}}A()};App.prototype.visit_bank=function(E){var B,D=this,C=0;function A(){switch(C){case 0:timeout(-1);move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much will you deposit? ");refresh();C++;D.get_num(9,A);break;case 1:if((B=arguments[0])>D.cash){move(18,0);clrtobot();printw("Taipan, you only have "+D.fancy_numbers(D.cash)+"\n");printw("in cash.\n");refresh();timeout(5000);C=0;getch(A);return }if(B==-1){B=D.cash}D.cash-=B;D.bank+=B;D.port_stats();C++;case 2:timeout(-1);move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much will you withdraw? ");refresh();C++;D.get_num(9,A);break;case 3:if((B=arguments[0])>D.bank){move(18,0);clrtobot();printw("Taipan, you only have "+D.fancy_numbers(D.bank)+"\n");printw("in the bank.\n");refresh();timeout(5000);C=2;getch(A);return }if(B==-1){B=D.bank}D.cash+=B;D.bank-=B;D.port_stats();E()}}A()};App.prototype.transfer=function(G){var E=this,C=0;if((E.hkw_[0]==0)&&(E.hold_[0]==0)&&(E.hkw_[1]==0)&&(E.hold_[1]==0)&&(E.hkw_[2]==0)&&(E.hold_[2]==0)&&(E.hkw_[3]==0)&&(E.hold_[3]==0)){move(22,0);clrtobot();printw("You have no cargo, Taipan.\n");refresh();return E.flash_msg(5000,G)}function F(){if(!E.hold_[C]){return D()}move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much "+E.item[C]+" shall I move\n");printw("to the warehouse, Taipan? ");refresh();E.get_num(9,B)}function B(){var H,I;H=arguments[0];if(H==-1){H=E.hold_[C]}if(H<=E.hold_[C]){I=E.hkw_[0]+E.hkw_[1]+E.hkw_[2]+E.hkw_[3];if((I+H)<=10000){E.hold_[C]-=H;E.hkw_[C]+=H;E.hold+=H;E.port_stats();return D()}else{if(I==10000){move(21,0);printw("Your warehouse is full, Taipan!")}else{move(21,0);printw("Your warehouse will only hold an\n");printw("additional "+(10000-I)+", Taipan!")}}refresh();return E.flash_msg(5000,F)}else{move(18,0);clrtobot();printw("You have only "+E.hold_[C]+", Taipan.\n");refresh();return E.flash_msg(5000,F)}}function D(){if(!E.hkw_[C]){return(++C==4)?G():F()}move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much "+E.item[C]+" shall I move\n");printw("aboard ship, Taipan? ");refresh();E.get_num(9,A)}function A(){var H=arguments[0];if(H==-1){H=E.hkw_[C]}if(H<=E.hkw_[C]){E.hold_[C]+=H;E.hkw_[C]-=H;E.hold-=H;E.port_stats();return(++C==4)?G():F()}else{move(18,0);clrtobot();printw("You have only "+E.hkw_[C]+", Taipan.\n");refresh();return E.flash_msg(5000,D)}}F()};App.prototype.load=function(D){var C=this,B;move(16,0);clrtobot();if(B=readCookie("taipan_savegame")){move(18,0);printw("Are you sure you want to load your saved\n");printw("game, and abandon your current one? ");refresh();C.get_one(A)}else{move(18,0);printw("No saved game available");refresh();C.flash_msg(3000,D)}function A(E){if((E!="Y")&&(E!="N")){move(19,0);clrtoeol();printw("game, and abandon your current one? ");refresh();return C.get_one(A)}if(E=="Y"){C.unmarshall(B);C.port_stats()}D()}};App.prototype.save=function(D){var C=this,B;move(16,0);clrtobot();if(B=readCookie("taipan_savegame")){move(18,0);printw("Are you sure you want to overwrite your\n");printw("saved game with the current one? ");refresh();C.get_one(A)}else{A("Y")}function A(E){if((E!="Y")&&(E!="N")){move(19,0);clrtoeol();printw("saved game with the current one? ");refresh();return C.get_one(A)}if(E=="Y"){createCookie("taipan_savegame",C.marshall(),365);printw("\n\nGame saved to your browser");refresh();C.flash_msg(3000,D)}else{printw("\n\nSave canceled");refresh();C.flash_msg(3000,D)}}};App.prototype.quit=function(J){var F=this;move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Taipan, do you wish me to go to:\n");printw("1) Hong Kong, 2) Shanghai, 3) Nagasaki,\n");printw("4) Saigon, 5) Manila, 6) Singapore, or\n");printw("7) Batavia ? ");refresh();F.get_num(1,B);function H(){move(21,13);clrtobot();refresh();F.get_num(1,B)}function B(P){if(P==F.port){printw("\n\nYou're already here, Taipan.");refresh();F.flash_msg(5000,H)}else{if((P>=1)&&(P<=7)){F.port=P;move(6,43);printw(" ");attrset(A_REVERSE);printw(F.location[0]);attrset(A_NORMAL);printw("  ");move(16,0);clrtobot();printw("  Captain's Report\n\n");if(rand()%F.bp==0){E()}else{if((rand()%(4+(8*F.li)))==0){A()}else{if(rand()%10==0){G()}else{I()}}}}else{H()}}}function E(){var P=rand()%((F.capacity/10)+F.guns)+1;printw(P+" hostile ships approaching, Taipan!\n");refresh();F.flash_msg(3000,bind(F.sea_battle,F,F.GENERIC,P,L))}function A(){move(18,0);clrtobot();printw("Li Yuen's pirates, Taipan!!\n\n");refresh();if(F.li>0){F.flash_msg(3000,M)}else{F.flash_msg(3000,O)}}function M(){printw("Good joss!! They let us be!!\n");refresh();if(rand()%10==0){F.flash_msg(3000,G)}else{F.flash_msg(3000,I)}}function O(){var P=rand()%((F.capacity/5)+F.guns)+5;printw(P+" ships of Li Yuen's pirate\n");printw("fleet, Taipan!!\n");refresh();F.flash_msg(3000,bind(F.sea_battle,F,F.LI_YUEN,P,L))}function L(P){F.port_stats();move(6,43);printw(" ");attrset(A_REVERSE);printw(F.location[0]);attrset(A_NORMAL);printw("  ");move(16,0);clrtobot();printw("  Captain's Report\n\n");switch(P){case 1:printw("We captured some booty.\n");printw("It's worth "+F.fancy_numbers(F.booty)+"!");F.cash+=F.booty;break;case 2:printw("Li Yuen's fleet drove them off!");refresh();return F.flash_msg(3000,A);case 3:printw("We made it!");break;default:printw("The buggers got us, Taipan!!!\n");printw("It's all over, now!!!");refresh();return F.flash_msg(5000,bind(F.final_stats,F))}refresh();if(rand()%10==0){F.flash_msg(3000,G)}else{F.flash_msg(3000,I)}}function G(){move(18,0);clrtobot();printw("Storm, Taipan!!\n\n");refresh();if(rand()%30==0){F.flash_msg(3000,D)}else{F.flash_msg(3000,K)}}function D(){printw("   I think we're going down!!\n\n");refresh();if(((F.damage/F.capacity*3)*Math.random())>=1){F.flash_msg(3000,N)}else{F.flash_msg(3000,K)}}function N(){printw("We're going down, Taipan!!\n");refresh();F.flash_msg(5000,bind(F.final_stats,F))}function K(){printw("    We made it!!\n\n");refresh();if(rand()%3==0){F.flash_msg(3000,C)}else{F.flash_msg(3000,I)}}function C(){var P=F.port;while(F.port==P){F.port=rand()%7+1}move(18,0);clrtobot();printw("We've been blown off course\n");printw("to "+F.location[F.port]);refresh();F.flash_msg(3000,I)}function I(){var Q,P;F.month++;if(F.month==13){F.year++;F.month=1;F.ec+=10;F.ed+=0.5;for(Q=0;Q<4;Q++){for(P=1;P<8;P++){F.base_price[Q][P]+=rand()%2}}}F.debt=F.debt+Math.round(F.debt*0.1);F.bank=F.bank+Math.round(F.bank*0.005);F.set_prices();move(18,0);clrtobot();printw("Arriving at "+F.location[F.port]+"...");refresh();F.flash_msg(3000,J)}};App.prototype.li_yuen_extortion=function(I){var C=((this.year-1860)*12)+this.month,E=0,F=1.8,D=0,G=0,B=this,A=0;function H(){switch(A){case 0:if(C>12){D=rand()%(1000*C)+(1000*C);F=1}G=Math.round((B.cash/F)*Math.random())+D;move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Li Yuen asks "+B.fancy_numbers(G)+" in donation\n");printw("to the temple of Tin Hau, the Sea\n");A++;case 1:E=arguments[0];if((E!="Y")&&(E!="y")&&(E!="N")&&(E!="n")){move(20,0);clrtoeol();printw("Goddess.  Will you pay? ");refresh();B.get_one(H);return }if((E=="N")||(E=="n")){I();return }if(G<=B.cash){B.cash-=G;B.li=1;B.port_stats();I();return }move(18,0);clrtobot();printw("Taipan, you do not have enough cash!!\n\n");refresh();timeout(3000);A++;getch(H);break;case 2:timeout(-1);printw("Do you want Elder Brother Wu to make up\n");arguments[0]="X";A++;case 3:E=arguments[0];if((E!="Y")&&(E!="y")&&(E!="N")&&(E!="n")){move(21,0);clrtoeol();printw("the difference for you? ");refresh();B.get_one(H);return }move(18,0);clrtobot();if((E=="Y")||(E=="y")){G-=B.cash;B.debt+=G;B.cash=0;B.li=1;printw("Elder Brother has given Li Yuen the\n");printw("difference between what he wanted and\n");printw("your cash on hand and added the same\n");printw("amount to your debt.\n")}else{B.cash=0;printw("Very well. Elder Brother Wu will not pay\n");printw("Li Yuen the difference.  I would be very\n");printw("wary of pirates if I were you, Taipan.\n")}refresh();timeout(5000);A++;getch(H);break;case 4:timeout(-1);B.port_stats();I()}}H()};App.prototype.elder_brother_wu=function(H){var B=0,G=0,D,C,F=this,E=0;function A(){switch(E){case 0:move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Do you have business with Elder Brother\n");printw("Wu, the moneylender? ");E++;case 1:B=arguments[0];if((B!="Y")&&(B!="y")&&(B!="N")&&(B!="n")){move(19,21);clrtoeol();refresh();F.get_one(A);return }if((B=="N")||(B=="n")){E=8;A();return }if(F.cash||F.bank||F.guns||F.hold_[0]||F.hkw_[0]||F.hold_[1]||F.hkw_[1]||F.hold_[2]||F.hkw_[2]||F.hold_[3]||F.hkw_[3]){E=4;A();return }F.wu_bailout++;D=rand()%1500+500;C=rand()%2000*F.wu_bailout+1500;move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Elder Brother is aware of your plight,\n");printw("Taipan.  He is willing to loan you an\n");printw("additional "+D+" if you will pay back\n");arguments[0]="X";E++;case 2:B=arguments[0];if((B!="Y")&&(B!="y")&&(B!="N")&&(B!="n")){move(21,0);clrtoeol();printw(C+". Are you willing, Taipan? ");refresh();F.get_one(A);return }if((B=="N")||(B=="n")){move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Very well, Taipan, the game is over!\n")}else{F.cash+=D;F.debt+=C;F.port_stats();move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Very well, Taipan.  Good joss!!\n")}refresh();timeout(5000);E++;getch(A);break;case 3:timeout(-1);if((B=="N")||(B=="n")){F.final_stats()}else{H()}E++;break;case 4:timeout(-1);if(!F.cash||!F.debt){E=6;A();return }move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much do you wish to repay\n");printw("him? ");refresh();E++;F.get_num(9,A);break;case 5:G=arguments[0];if(G==-1){G=F.cash}if(G>F.cash){move(18,0);clrtobot();printw("Taipan, you only have "+F.fancy_numbers(F.cash)+"\n");printw("in cash.\n");refresh();timeout(5000);E=4;getch(A);return }F.cash-=G;F.debt-=G;F.port_stats();E++;case 6:timeout(-1);move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("How much do you wish to\n");printw("borrow? ");refresh();E++;F.get_num(9,A);break;case 7:G=arguments[0];if(G==-1){G=F.cash*2}if(G>F.cash*2){printw("\n\nHe won't loan you so much, Taipan!");refresh();timeout(5000);E=6;getch(A);return }F.cash+=G;F.debt+=G;F.port_stats();E++;case 8:if((F.debt<=20000)||!F.cash||rand()%5){H();return }F.cash=0;F.port_stats();move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Bad joss!!\n");printw((rand()%3+1)+" of your bodyguards have been killed\n");printw("by cutthroats and you have been robbed\n");printw("of all of your cash, Taipan!!\n");refresh();timeout(5000);E++;getch(A);break;case 9:timeout(-1);H()}}A()};App.prototype.good_prices=function(F){var C,B,E=this,D=0;function A(){switch(D){case 0:C=rand()%4;B=rand()%2;move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Taipan!!  The price of "+E.item[C]+"\n");if(B==0){E.price[C]=Math.ceil(E.price[C]/5);printw("has dropped to "+E.price[C]+"!!\n")}else{E.price[C]=E.price[C]*(rand()%5+5);printw("has risen to "+E.price[C]+"!!\n")}refresh();timeout(3000);D++;getch(A);break;case 1:timeout(-1);F()}}A()};App.prototype.overload=function(C){var B=0;function A(){switch(B){case 0:move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Your ship is overloaded, Taipan!!");refresh();timeout(5000);B++;getch(A);break;case 1:timeout(-1);C()}}A()};App.prototype.new_ship=function(G){var B=0,E,C,F=this,D=0;function A(){switch(D){case 0:E=((F.year-1860)*12)+F.month;C=Math.round((rand()%(1000*(E+5)/6)+1000)*(F.damage>0?F.capacity/50+1:1));if(F.cash<C){G();return }move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Do you wish to trade in your ");if(F.damage>0){attrset(A_REVERSE);printw("damaged");attrset(A_NORMAL)}else{printw("fine")}printw("\nship for one with 50 more capacity by\n");D++;case 1:B=arguments[0];if((B!="Y")&&(B!="y")&&(B!="N")&&(B!="n")){move(20,0);clrtoeol();printw("paying an additional "+F.fancy_numbers(C)+", Taipan? ");refresh();F.get_one(A);return }if((B=="Y")||(B=="y")){F.cash-=C;F.hold+=50;F.capacity+=50;F.damage=0}F.port_stats();G()}}A()};App.prototype.new_gun=function(G){var B=0,E,C,F=this,D=0;function A(){switch(D){case 0:E=((F.year-1860)*12)+F.month;C=Math.round(rand()%(1000*(E+5)/6))+500;if((F.cash<C)||(F.hold<10)){G();return }move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Do you wish to buy a ship's gun\n");D++;case 1:B=arguments[0];if((B!="Y")&&(B!="y")&&(B!="N")&&(B!="n")){move(19,0);clrtoeol();printw("for "+F.fancy_numbers(C)+", Taipan? ");refresh();F.get_one(A);return }if((B=="Y")||(B=="y")){F.cash-=C;F.hold-=10;F.guns+=1}F.port_stats();G()}}A()};App.prototype.fancy_numbers=function(B){var A;if(B>=100000000){return Math.round(B/1000000)+" Million"}else{if(B>=10000000){A=Math.round((B%1000000)/100000);if(A&&(A<10)){return""+Math.floor(B/1000000)+"."+A+" Million"}else{return Math.round(B/1000000)+" Million"}}else{if(B>=1000000){A=Math.round((B%1000000)/10000);if(A&&(A<10)){return""+Math.floor(B/1000000)+".0"+A+" Million"}else{if(A&&(A<100)){return""+Math.floor(B/1000000)+"."+A+" Million"}else{return Math.round(B/1000000)+" Million"}}}else{return""+Math.round(B)}}}};App.prototype.sea_battle=function(Q,B,W){var J=this,A=0,R=0,K=[0,0,0,0,0,0,0,0,0,0],H=((J.year-1860)*12)+J.month,D=B,N=0,L=1;J.booty=Math.round(H/4*1000*Math.pow(B,1.05)*Math.random())+rand()%1000+250;clear();flushinp();J.fight_stats(B,A);G();function G(){if(!B){return U()}var a=Math.round(100-((J.damage/J.capacity)*100));if(a<=0){return W(4)}flushinp();move(3,0);clrtoeol();printw("Current seaworthiness: "+J.st[Math.floor(a/20)]+" ("+a+"%)");refresh();X(0,P)}function C(b,e){var a=(b%5+1)*10,d=b<5?6:12;K[b]=Math.round((J.ec*Math.random())+20);J.draw_lorcha(a,d);R++;refresh();X(b+1,e)}function X(a,b){for(;a<10;a++){if((B>R)&&(K[a]==0)){return usleep(100000,partial(C,a,b))}}move(11,62);printw(B>R?"+":" ");move(16,0);printw("\n");refresh();b()}function V(b,e){var a=(b%5+1)*10,d=b<5?6:12;K[b]=0;J.clear_lorcha(a,d);R--;refresh();usleep(100000,partial(E,b-1,e))}function E(a,b){for(;a>=0;a--){if((R>B)&&(K[a]>0)){return V(a,b)}}move(11,62);printw(B>R?"+":" ");refresh();b()}function P(){timeout(A?3000:6000);J.get_raw(function(a){timeout(-1);F(a)})}function Z(a){var b;if((a!=ERR)&&((b=findValue("FRT".split(""),a))>=0)){A=b+1}}function F(b){Z(b);if(A){return Y()}function a(c){Z(c);A?Y():J.get_raw(a)}move(3,0);clrtoeol();printw("Taipan, what shall we do??    (F=Fight, R=Run, T=Throw cargo)");refresh();J.get_raw(a)}function Y(){J.fight_stats(B,A);switch(A){case 1:return J.guns?M():T();case 2:return O();case 3:return I()}}function M(){var d,n,m,p=1,h=0;N=3;L=1;function l(){move(3,0);clrtoeol();printw("Aye, we'll fight 'em, Taipan.");refresh();J.flash_msg(3000,k)}function k(){move(3,0);clrtoeol();printw("We're firing on 'em, Taipan!");refresh();J.flash_msg(1000,f)}function f(){if(p>J.guns){return i()}if(!sum(K)){return X(0,f)}for(d=rand()%10;!K[d];d=rand()%10){}n=(d%5+1)*10,m=d<5?6:12;g()}function g(){J.draw_blast(n,m);refresh();usleep(100000,e)}function e(){J.draw_lorcha(n,m);refresh();usleep(100000,c)}function c(){J.draw_blast(n,m);refresh();usleep(100000,a)}function a(){J.draw_lorcha(n,m);refresh();usleep(100000,b)}function b(){K[d]-=(rand()%30+10);if(K[d]<=0){R--;B--;h++;K[d]=0;usleep(100000,partial(J.sink_lorcha,n,m,o))}else{o()}}function o(){if(K[d]==0){J.fight_stats(B,A);refresh()}if(B==0){i()}else{p++;usleep(500000,f)}}function i(){move(3,0);clrtoeol();if(h>0){printw("Sunk "+h+" of the buggers, Taipan!")}else{printw("Hit 'em, but didn't sink 'em, Taipan!")}refresh();J.flash_msg(3000,j)}function j(){var q;if((rand()%D>=(B*0.6/Q))&&(B<D)&&(B>2)){q=Math.round(Math.random()*B/3/Q)+1;B-=q;J.fight_stats(B,A);move(3,0);clrtoeol();printw(q+" ran away, Taipan!");refresh();if(B<=10){return E(9,bind(J.flash_msg,J,3000,S))}else{return J.flash_msg(3000,S)}}S()}l()}function T(){move(3,0);clrtoeol();printw("We have no guns, Taipan!!");refresh();J.flash_msg(3000,S)}function O(){if(A==2){move(3,0);clrtoeol();printw("Aye, we'll run, Taipan.");refresh();J.flash_msg(3000,a)}else{a()}function a(){N+=L++;if(rand()%Math.round(N)>rand()%B){B=0;flushinp();move(3,0);clrtoeol();printw("We got away from 'em, Taipan!");refresh();J.flash_msg(3000,U)}else{move(3,0);clrtoeol();printw("Couldn't lose 'em.");refresh();if((B>2)&&(rand()%5==0)){J.flash_msg(3000,b)}else{J.flash_msg(3000,S)}}}function b(){var c=Math.round(rand()%B/2)+1;B-=c;J.fight_stats(B,A);move(3,0);clrtoeol();printw("But we escaped from "+c+" of 'em!");refresh();if(B<=10){return E(9,bind(J.flash_msg,J,3000,S))}else{return J.flash_msg(3000,S)}}}function I(){var a;move(18,0);printw("You have the following on board, Taipan:");move(19,4);printw("Opium: "+J.hold_[0]);move(19,24);printw("Silk: "+J.hold_[1]);move(20,5);printw("Arms: "+J.hold_[2]);move(20,21);printw("General: "+J.hold_[3]);move(3,0);clrtoeol();printw("What shall I throw overboard, Taipan? ");refresh();J.get_one(c);function c(d){if((a=findValue("OSAGE".split(""),d))<0){return J.get_one(c)}if(a<4){move(3,0);clrtoeol();printw("How much, Taipan? ");refresh();J.get_num(9,b)}else{b()}}function b(d){var e;if(a<4){if((J.hold_[a]>0)&&((d==-1)||(d>J.hold_[a]))){d=J.hold_[a]}e=J.hold_[a]}else{e=sum(J.hold_)}if(e){move(3,0);clrtoeol();printw("Let's hope we lose 'em, Taipan!");if(a<4){J.hold_[a]-=d;J.hold+=d;N+=(d/10)}else{J.hold_[0]=0;J.hold_[1]=0;J.hold_[2]=0;J.hold_[3]=0;J.hold+=e;N+=(e/10)}move(18,0);clrtobot();refresh();J.flash_msg(3000,O)}else{move(3,0);clrtoeol();printw("There's nothing there, Taipan!");move(18,0);clrtobot();refresh();J.flash_msg(3000,O)}}}function S(){if(!B){return U()}move(3,0);clrtoeol();printw("They're firing on us, Taipan!");refresh();J.flash_msg(3000,partial(c,0));function c(g){var h,f;for(h=0;h<24;h++){for(f=0;f<79;f++){move(h,f);printw("*")}}refresh();usleep(200000,partial(b,g))}function b(f){clear();refresh();usleep(200000,f>=2?e:partial(c,f+1))}function e(){var g,f,h;J.fight_stats(B,A);for(g=0;g<=9;g++){if(K[g]>0){f=(g%5+1)*10;h=g<5?6:12;J.draw_lorcha(f,h)}}move(11,62);printw(B>R?"+":" ");move(3,0);clrtoeol();printw("We've been hit, Taipan!!");refresh();J.flash_msg(3000,d)}function d(){var f,g;f=(B>15)?15:B;if((J.guns>0)&&((rand()%100<((J.damage/J.capacity)*100))||(((J.damage/J.capacity)*100)>80))){f=1;J.guns--;J.hold+=10;J.fight_stats(B,A);move(3,0);clrtoeol();printw("The buggers hit a gun, Taipan!!");refresh();g=Math.round(((J.ed*f*Q)*Math.random())+(f/2));J.flash_msg(3000,partial(a,g))}else{g=Math.round(((J.ed*f*Q)*Math.random())+(f/2));a(g)}}function a(f){J.damage+=f;if((Q==J.GENERIC)&&(rand()%20==0)){W(2)}else{G()}}}function U(){if(A==1){clear();J.fight_stats(B,A);move(3,0);clrtoeol();printw("We got 'em all, Taipan!");refresh();J.flash_msg(3000,partial(W,1))}else{W(3)}}};App.prototype.draw_lorcha=function(A,B){move(B,A);printw("-|-_|_  ");move((B+1),A);printw("-|-_|_  ");move((B+2),A);printw("_|__|__/");move((B+3),A);printw("\\_____/ ")};App.prototype.clear_lorcha=function(A,B){move(B,A);printw("        ");move((B+1),A);printw("        ");move((B+2),A);printw("        ");move((B+3),A);printw("        ")};App.prototype.draw_blast=function(A,B){move(B,A);printw("********");move((B+1),A);printw("********");move((B+2),A);printw("********");move((B+3),A);printw("********")};App.prototype.sink_lorcha=function(B,H,G){var E=rand()%20;function D(){move(H,B);printw("        ");move((H+1),B);printw("-|-_|_  ");move((H+2),B);printw("-|-_|_  ");move((H+3),B);printw("_|__|__/");refresh();usleep(E?500000:1000000,C)}function C(){move((H+1),B);printw("        ");move((H+2),B);printw("-|-_|_  ");move((H+3),B);printw("-|-_|_  ");refresh();usleep(E?500000:1000000,A)}function A(){move((H+2),B);printw("        ");move((H+3),B);printw("-|-_|_  ");refresh();usleep(E?500000:1000000,F)}function F(){move((H+3),B);printw("        ");refresh();usleep(E?500000:1000000,G)}D()};App.prototype.fight_stats=function(A,C){var B=["","Fight      ","Run        ","Throw Cargo"];move(0,0);if(A>=1000){printw(A)}else{if(A>=100){printw(" "+A)}else{if(A>=10){printw("  "+A)}else{printw("   "+A)}}}move(0,5);if(A==1){printw("ship attacking, Taipan! \n")}else{printw("ships attacking, Taipan!\n")}printw("Your orders are to: "+B[C]);move(0,50);printw("|  We have");move(1,50);clrtoeol();printw("|  "+this.guns+" guns");move(2,50);printw("----------");move(16,0);return };App.prototype.mchenry=function(I){var E=0,H,D,J,B,F,C=this,A=0;function G(){switch(A){case 0:move(16,0);clrtobot();printw("Comprador's Report\n\n");printw("Taipan, Mc Henry from the Hong Kong\n");printw('Shipyards has arrived!!  He says, "I see\n');printw("ye've a wee bit of damage to yer ship.\n");A++;case 1:E=arguments[0];if((E!="Y")&&(E!="y")&&(E!="N")&&(E!="n")){move(21,0);clrtoeol();printw("Will ye be wanting repairs? ");refresh();C.get_one(G);return }if((E=="N")||(E=="n")){I();return }H=Math.round(C.damage/C.capacity*100);D=((C.year-1860)*12)+C.month;J=Math.round((((60*(D+3)/4)*Math.random())+25*(D+3)/4)*C.capacity/50);B=(J*C.damage)+1;move(18,0);clrtobot();printw("Och, 'tis a pity to be "+H+"% damaged.\n");printw("We can fix yer whole ship for "+B+",\n");printw("or make partial repairs if you wish.\n");printw("How much will ye spend? ");refresh();arguments[0]=C.cash+1;A++;case 2:F=arguments[0];if(F>C.cash){move(21,24);clrtoeol();refresh();C.get_num(9,G);return }if(F==-1){F=C.cash}C.cash-=F;C.damage-=Math.round(F/J);C.damage=(C.damage<0)?0:C.damage;C.port_stats();I()}}G()};App.prototype.retire=function(D){var C=this,B=0;function A(){switch(B){case 0:move(16,0);clrtobot();printw("Comprador's Report\n\n");attrset(A_REVERSE);printw("                         \n");printw(" Y o u ' r e    a        \n");printw("                         \n");printw(" M I L L I O N A I R E ! \n");printw("                         \n");attrset(A_NORMAL);refresh();timeout(5000);B++;getch(A);break;case 1:timeout(-1);C.final_stats()}}A()};App.prototype.final_stats=function(){var C=this.year-1860,E=((this.year-1860)*12)+this.month,B=0,F=this,D=0;function A(){switch(D){case 0:clear();printw("Your final status:\n\n");cash=F.cash+F.bank-F.debt;printw("Net cash:  "+F.fancy_numbers(cash)+"\n\n");printw("Ship size: "+F.capacity+" units with "+F.guns+" guns\n\n");printw("You traded for "+C+" year");if(C!=1){printw("s")}printw(" and "+F.month+" month");if(F.month>1){printw("s")}printw("\n\n");cash=cash/100/Math.pow(E,1.1);attrset(A_REVERSE);printw("Your score is "+Math.round(cash)+"\n");attrset(A_NORMAL);printw("\n");if((cash<100)&&(cash>=0)){printw("Have you considered a land based job?\n\n\n")}else{if(cash<0){printw("The crew has requested that you stay on\n");printw("shore for their safety!!\n\n")}else{printw("\n\n\n")}}printw("Your Rating:\n");printw(" _______________________________\n");printw("|");if(cash>49999){attrset(A_REVERSE)}printw("Ma Tsu");attrset(A_NORMAL);printw("         50,000 and over |\n");printw("|");if((cash<50000)&&(cash>7999)){attrset(A_REVERSE)}printw("Master Taipan");attrset(A_NORMAL);printw("   8,000 to 49,999|\n");printw("|");if((cash<8000)&&(cash>999)){attrset(A_REVERSE)}printw("Taipan");attrset(A_NORMAL);printw("          1,000 to  7,999|\n");printw("|");if((cash<1000)&&(cash>499)){attrset(A_REVERSE)}printw("Compradore");attrset(A_NORMAL);printw("        500 to    999|\n");printw("|");if(cash<500){attrset(A_REVERSE)}printw("Galley Hand");attrset(A_NORMAL);printw("      less than  500|\n");printw("|_______________________________|\n\n");D++;case 1:B=arguments[0];if((B!="Y")&&(B!="y")&&(B!="N")&&(B!="n")){move(22,0);clrtoeol();printw("Play again? ");refresh();F.get_one(A);return }if((B=="Y")||(B=="y")){F.bank=0;F.hkw_[0]=0;F.hkw_[1]=0;F.hkw_[2]=0;F.hkw_[3]=0;F.hold_[0]=0;F.hold_[1]=0;F.hold_[2]=0;F.hold_[3]=0;F.capacity=60;F.damage=0;F.month=1;F.year=1860;F.port=1;F.base_price=[[1000,11,16,15,14,12,10,13],[100,11,14,15,16,10,13,12],[10,12,16,10,11,13,14,15],[1,10,11,12,13,14,15,16]];F.wu_warn=0;F.wu_bailout=0;F.ec=20;F.ed=0.5;F.main()}}}A()};App.prototype.test_wait0=function(){alert("foo");getch();alert("bar");getch();alert("baz");getch()};App.prototype.test_wait1=function(C){var B=0;function A(){switch(B){case 0:alert("foo");B++;getch(A);break;case 1:alert("bar");B++;getch(A);break;case 2:alert("baz");B++;getch(A);break;case 3:C()}}A()};
