0010 REM DopeWars Copyright (c) 2001 Eric M. Schneck, Inc. 0020 LET appSpec={goto:'endProgram,title:"DopeWars"} 0030 window app,appSpec,"APP" 0040 show app 0050 widgetdef Layout_0:={Widget_10:{widgetType:"title",order:9,vB iewBounds:{left:179,top:99,right:238,bottom:114},viewJustifB y:0,viewFont:{family:'espy,face:1,size:12},viewFlags:1,textB :"Savings",viewFormat:0},lbJet:{widgetType:"labelPicker",orB der:11,checkCurrentItem:TRUE,indent:50,viewBounds:{left:11,B top:28,right:151,bottom:48},labelCommands:["Times Square","B Bronx","Harlem","Central Park","Coney Island","Brooklyn"],tB ext:"Jet",viewValue:0,gosub:'processTravel},Widget_7:{widgeB tType:"title",order:6,viewBounds:{left:75,top:206,right:166B ,bottom:222},viewJustify:2,viewFont:{family:'espy,face:0,siB ze:9},viewFlags:1,text:"Units / Dollars",viewFormat:0},txtDB ollars:{widgetType:"text",order:5,viewClass:81,viewBounds:{B left:77,top:181,right:164,bottom:204},viewFlags:10752,viewFB ormat:12625,viewJustify:0,viewLineSpacing:24,text:"",viewFoB nt:{family:'newYork,face:0,size:14},tabs:[20,40,60,80,120,1B 40,160,180]},Widget_21:{widgetType:"textButton",order:21,goB sub:'newGame,viewBounds:{left:173,top:264,right:232,bottom:B 279},viewFlags:514,text:"New Game",viewFont:{family:'espy,fB ace:1,size:9},viewFormat:67109456},Widget_9:{widgetType:"tiB tle",order:8,viewBounds:{top:65,bottom:80,left:180,right:23B 9},viewJustify:0,viewFont:{family:'espy,face:1,size:12},vieB wFlags:1,text:"Debt",viewFormat:0},lbOther:{widgetType:"labB elPicker",order:19,checkCurrentItem:TRUE,indent:50,viewBounB ds:{top:227,bottom:247,left:3,right:239},labelCommands:[""]B ,text:"Other:",viewValue:0,gosub:'processOther},btnSlMax:{wB idgetType:"textButton",order:3,viewBounds:{top:205,bottom:2B 20,left:173,right:232},viewFlags:514,text:"Sell Max",viewFoB nt:{family:'espy,face:1,size:9},viewFormat:67109456,gosub:'B negotiateMaxSell},Widget_1:{widgetType:"textButton",order:1B ,viewBounds:{left:9,top:181,right:68,bottom:196},viewFlags:B 514,text:"Buy",viewFont:{family:'espy,face:1,size:9},viewFoB rmat:67109456,gosub:'negotiateBuy},btnBuyMax:{widgetType:"tB extButton",order:2,viewBounds:{top:205,bottom:220,left:9,riB ght:68},viewFlags:514,text:"Buy Max",viewFont:{family:'espyB ,face:1,size:9},viewFormat:67109456,gosub:'negotiateMax},txB tCoat:{widgetType:"title",order:15,viewBounds:{left:182,topB :153,right:241,bottom:168},viewJustify:0,viewFont:{family:'B espy,face:0,size:12},viewFlags:1,text:"0/140",viewFormat:0}B ,txtCash:{widgetType:"title",order:12,viewBounds:{left:182,B top:43,right:241,bottom:58},viewJustify:0,viewFont:{family:B 'espy,face:0,size:12},viewFlags:1,text:"0",viewFormat:0},txB tDebt:{widgetType:"title",order:13,viewBounds:{left:181,topB :81,right:240,bottom:96},viewJustify:0,viewFont:{family:'esB py,face:0,size:12},viewFlags:1,text:"0",viewFormat:0},WidgeB t_11:{widgetType:"title",order:10,viewBounds:{left:181,top:B 137,right:240,bottom:152},viewJustify:0,viewFont:{family:'eB spy,face:1,size:12},viewFlags:1,text:"Coat",viewFormat:0},WB idget_20:{widgetType:"textButton",order:20,gosub:'OpenHelp,B viewBounds:{top:265,bottom:280,left:7,right:24},viewFlags:5B 14,text:"i",viewFont:{family:'newYork,face:1,size:12},viewFB ormat:67109456},Widget_8:{widgetType:"title",order:7,viewBoB unds:{top:26,bottom:41,left:180,right:239},viewJustify:0,viB ewFont:{family:'espy,face:1,size:12},viewFlags:1,text:"CashB ",viewFormat:0},txtDays:{widgetType:"title",order:17,viewBoB unds:{left:131,top:241,right:149,bottom:260},viewJustify:0,B viewFont:{family:'espy,face:0,size:12},viewFlags:1,text:"31B ",viewFormat:0},Widget_16:{widgetType:"title",order:16,viewB Bounds:{left:7,top:240,right:129,bottom:260},viewJustify:0,B viewFont:{family:'espy,face:1,size:12},viewFlags:1,text:"DaB ys Remaining:",viewFormat:0},txtBank:{widgetType:"title",orB der:14,viewBounds:{left:182,top:115,right:241,bottom:130},vB iewJustify:0,viewFont:{family:'espy,face:0,size:12},viewFlaB gs:1,text:"0",viewFormat:0},btnSell:{widgetType:"textButtonB ",order:4,viewBounds:{top:182,bottom:197,left:173,right:232B },viewFlags:514,text:"Sell",viewFont:{family:'espy,face:1,sB ize:9},viewFormat:67109456,gosub:'negotiateSell},txtGun:{wiB dgetType:"title",order:18,viewBounds:{left:123,top:28,rightB :169,bottom:43},viewJustify:0,viewFont:{family:'espy,face:1B ,size:12},viewFlags:1,text:"",viewFormat:0},lbDrug:{widgetTB ype:"textList",order:0,viewBounds:{left:10,top:52,right:169B ,bottom:168},ListItems:[],useScrollers:TRUE,useMultipleSelections:NIL,ScrollAmounts:[1,3,20],v iewFormat:337}} 0060 window wlist,Layout_0 0062 function Millions(n) begin if (n>1000000) then "$"&FormattedNumberStr(n/1000000,"%.1f")&"MM" else "$"&NumberStr(n) end 0065 gosub loadGameMessages // 0070 gosub getSavedGame // 0080 gosub processForm // 0090 data 13, "The cops just did a big Weed bust! Prices are sky-high!",5,4,0,0 0100 data 20, "The cops just did a big PCP bust! Prices are sky-high!",3,4,0,0 0110 data 25, "The cops just did a big heroin bust! Prices are sky-high!",4,4,0,0 0120 data 13, "The cops just did a big Ludes bust! Prices are sky-high!",2,4,0,0 0130 data 35, "The cops just did a big Cocaine bust! Prices are sky-high!",1,4,0,0 0140 data 15, "The cops just did a big Speed bust! Prices are sky-high!",7,4,0,0 0150 data 25, "Addicts are buying Heroin at outrageous prices!",4,8,0,0 0160 data 20, "Addicts are buying Speed at outrageous prices!",7,8,0,0 0170 data 20, "Addicts are buying PCP at outrageous prices!",3,8,0,0 0180 data 17, "Addicts are buying Shrooms at outrageous prices!",6,8,0,0 0190 data 35, "Addicts are buying Cocaine at outrageous prices!",1,8,0,0 0200 data 17, "The market has been flooded with cheap home-made Acid!",0,0,8,0 0210 data 10, "A Columbian freighter dusted the Coast Guard! Weed prices have bottomed out!", 5,0,4,0 0220 data 11, "A gang raided a local pharmacy and are selling cheap Ludes!",2,0,8,0 0230 data 55, "You found some Cocaine on a dead dude in the subway!",1,0,0,3 0240 data 45, "You found some Acid on a dead dude in the subway!",0,0,0,6 0250 data 35, "You found some PCP on a dead dude in the subway!",3,0,0,4 0270 show wlist 0280 wait -1 //indefinitely 0500 initGame: REM 0510 let oth=[] 0520 LET myDrugs=[0,0,0,0,0,0,0,0] 0530 LET myCash=2000 0540 LET myDebt=5500 0550 LET myBank=0 0560 LET myCoat=100 0570 let myCount=0 0580 LET myGuns=0 0600 LET myLocation=0 0610 LET timeLeft=31 0620 LET copCount=3 0630 LET leaveOut=3 0640 GOSUB makeDrugPrices // 0660 return 0700 makeDrugPrices: REM 0710 dim drugPrices[8] 0720 LET drugPrices[0]=1000+RANDOM(0,3500) 0730 LET drugPrices[1]=15000+RANDOM(0,15000) 0740 LET drugPrices[2]=10+RANDOM(0,50) 0750 LET drugPrices[3]=1000+RANDOM(0,2500) 0760 LET drugPrices[4]=5000+RANDOM(0,9000) 0770 LET drugPrices[5]=300+RANDOM(0,600) 0780 LET drugPrices[6]=600+RANDOM(0,750) 0790 LET drugPrices[7]=70+RANDOM(0,180) 0800 for i=1 to leaveout 0810 LET drugPrices[RANDOM(0,7)]=0 0820 next i 0830 return 0900 loadGameMessages: REM 0905 let drugNames=["Acid ","Cocaine ","Ludes ","PCP ","Heroin ","Weed ","Shrooms","Speed "] 0910 dim gameMessages[17] 0920 dim message[6] 0930 for msgNo=0 to 16 0940 for fld=0 to 5 0950 read f 0960 LET message[fld]=f //freq,msg,drug,plus,minus,add 0970 next fld 0980 LET gameMessages[msgNo]=clone(message) 0990 next msgNo 1000 return 1200 processForm: REM 1210 let myCount=0 1220 dim listItems[8] 1230 for i=0 to 7 1240 LET s=numberstr(myDrugs[i]) 1250 LET spacer=substr(" ",1,10-floor(2*strlen(s))) 1260 LET s=s&spacer&&drugNames[i] 1270 if drugPrices[i]>0 then let s=s&&"$"&drugPrices[i] else let s=s&&"None" 1280 let myCount=myCount+myDrugs[i] 1290 let listItems[i]=s 1300 next i 1310 setvalue(layout_0.lbDrug,'listItems,clone(listItems)) 1320 u.layout_0.lbdrug:setuplist() 1330 u.layout_0.lbdrug:redochildren() 1340 setvalue(layout_0.txtCash,'text,u:Millions(myCash)) 1350 setvalue(layout_0.txtBank,'text,u:Millions(myBank)) 1360 setvalue(layout_0.txtDebt,'text,u:Millions(myDebt)) 1370 setvalue(layout_0.txtCoat,'text,myCount&"/"&myCoat) 1380 setvalue(layout_0.txtDollars,'text,clone("")) 1390 setvalue(layout_0.txtDays,'text,timeLeft) 1400 setvalue(layout_0.txtGun,'text,substr("Gun",0,10*myGuns)) 1410 return 1500 negotiateBuy: REM 1510 let count=stringToNumber(u.layout_0.txtDollars.text) 1520 if count=nil then count=0 1530 LET i=u.layout_0.lbDrug.selection 1540 let dollars=count*drugPrices[i] 1550 let msg="" 1560 if myCount+count>myCoat then let msg="No room in coat" 1570 if count<1 then let msg="How much?" 1580 if drugPrices[i]<1 then let msg="No "&&drugNames[i]&&"here" 1590 if dollars>myCash then let msg="You don't have the cash" 1600 if msg <> "" then 1610 notify("Hey dude",msg) 1620 return 1630 end if 1640 LET myDrugs[i]=myDrugs[i]+count 1650 LET myCash=myCash-count*drugPrices[i] 1660 let myCount=myCount+count 1670 gosub processForm // 1680 return 1690 negotiateMax: REM 1700 let msg="" 1710 LET i=u.layout_0.lbDrug.selection 1720 let dollars=myCash 1730 let count=floor(dollars/max(1,drugPrices[i])) 1740 if count < 1 then let msg="You don't have the cash" 1750 if myCount+count > myCoat then let count=myCoat-myCount 1760 if Count+myCount>= myCoat then let msg="You don't have the pocket space" 1770 if drugPrices[i] < 1 then msg="No "&&drugNames[i]&&"here" 1780 if msg <> "" then 1790 notify("Hey dude",msg) 1800 return 1810 end if 1820 LET myDrugs[i]=myDrugs[i]+count 1830 LET myCash=myCash-count*drugPrices[i] 1840 let myCount =myCount + count 1850 gosub processForm // 1860 return 1870 negotiateSell: REM 1880 let count=stringToNumber(u.layout_0.txtDollars.text) 1890 if count=nil then count=0 1900 LET i=u.layout_0.lbDrug.selection 1910 let dollars=count*drugPrices[i] 1920 let msg="" 1930 if count<1 then let msg="How much?" 1940 if count > myDrugs[i] then msg="You don't have the goods" 1950 if drugPrices[i]<1 then let msg="No one is buying " & drugNames[i]&&"here" 1960 if msg <> "" then 1970 notify("Hey dude", msg) 1980 return 1990 end if 2000 LET myDrugs[i]=myDrugs[i]-count 2010 LET myCash=myCash+count*drugPrices[i] 2020 let myCount=myCount-count 2030 gosub processForm // 2040 return 2050 negotiateMaxSell: REM 2060 let msg="" 2070 LET i=u.layout_0.lbDrug.selection 2080 let count = myDrugs[i] 2090 if count < 1 then msg = "You don't have the goods" 2100 if drugPrices[i] < 1 then msg="No one is buying " &drugNames[i]&&"here" 2110 if msg <> "" then 2120 notify("Hey dude",msg) 2130 return 2140 end if 2150 LET myDrugs[i]=myDrugs[i]-count 2160 LET myCash=myCash+count*drugPrices[i] 2170 let myCount=myCount-count 2180 gosub processForm // 2190 return 2200 finishGame: REM 2205 let leaveout=0 2210 gosub makeDrugPrices // 2220 let dollars=myCash+myBank-myDebt 2230 for i=0 to 7 2240 let dollars=dollars+myDrugs[i]*drugPrices[i] 2260 next i 2270 LET msg="You made $" & dollars 2280 if copCount = -1 then 2290 LET msg = msg && "You're dead. Congratulations" 2300 else 2310 if dollars < 0 then 2320 LET msg = msg && "The Loan Shark's thugs broke your legs" 2330 else 2340 if dollars > 1000000 then 2350 LET msg = msg && "You retired a millionaire in the Caribbean" 2360 else 2370 if dollars > 2000 then 2380 LET msg= msg && "Congratulations! You didn't do half bad." 2390 else 2400 LET msg = msg && "You didn't make any money! Better luck next time." 2410 endif 2420 endif 2430 endif 2440 endif 2450 notify("Hey dude",msg) 2460 return 2500 processTravel: REM 2510 LET myLocation=u.layout_0.lbJet.viewValue 2520 if myLocation=1 then 2530 let oth=["You can:","Deposit to Bank","Withdraw from Bank","Borrow from Shark","Pay Sh ark"] 2540 else 2550 let oth=[""] 2560 end if 2570 LET myBank=floor(myBank+(myBank/16)) 2580 LET myDebt=floor(myDebt+(myDebt/8)) 2590 if random(0,9)=0 then oth[0]="Buy a bigger coat for $200" 2600 setvalue(layout_0.lbOther,'labelCommands,clone(oth)) 2610 u.layout_0.lbOther:UpdateText(clone(oth[0])) 2620 LET timeLeft = timeLeft - 1 2630 if timeLeft < 1 then 2640 gosub FinishGame // 2650 gosub initGame // 2660 end if 2665 let leaveOut=3 2670 gosub makeDrugPrices // 2680 gosub PerformRandomStuff // 2690 gosub processForm // 2700 return 2800 PerformRandomStuff: REM 2810 for i =0 to 16 2820 LET message=gameMessages[i] 2830 let drugNo=message[2] 2840 if random(0,message[0])=0 and drugPrices[drugNo]>0 then 2850 notify("Hey dude", message[1]) 2860 if message[3]>0 then let drugPrices[drugNo]=drugPrices[drugNo]*message[3] 2870 if message[4]>0 then let drugPrices[drugNo]=floor(drugPrices[drugNo]/message[4]) 2880 if message[5]>0 then 2890 if message[5]+myCount>myCoat then 2900 let addCount=myCoat-myCount 2910 else 2920 let addcount=message[5] 2930 end if 2940 let myDrugs[drugNo]=myDrugs[drugNo]+addcount 2950 end if 2960 end if 2970 next i 2980 gosub processForm // 2990 return 3000 processOther: REM 3010 let i=u.layout_0.lbOther.viewValue 3020 let cmd=u.layout_0.lbOther.labelCommands[i] 3030 if cmd="Buy a bigger coat for $200" then 3040 LET myCash=myCash-200 3050 LET myCoat=myCoat+40 3060 LET oth[0]="(No more pockets)" 3070 setvalue(layout_0.lbOther,'labelCommands,clone(oth)) 3080 else 3090 let dollars=stringToNumber(u.layout_0.txtDollars.text) 3100 if dollars=nil then 3110 notify("Hey dude","How much?") 3120 return 3130 end if 3140 if cmd="Deposit to Bank" then gosub processDeposit 3150 if cmd="Withdraw from Bank" then gosub processWithdraw 3160 if cmd="Borrow from Shark" then gosub processBorrow 3170 if cmd="Pay Shark" then gosub processRepay 3180 end if 3190 rem u.layout_0.lbOther:updateText("You can:") 3200 gosub processForm // 3210 return 3220 processDeposit: REM 3230 let dollars=min(dollars,myCash) 3240 let myCash=myCash-dollars 3250 let myBank=myBank+dollars 3260 return 3270 processWithdraw: REM 3280 let dollars=min(dollars, myBank) 3290 let myCash=myCash+dollars 3300 let myBank=myBank-dollars 3310 return 3320 processBorrow: REM 3330 let dollars=min(dollars,30*myCash) 3340 let myCash=myCash+dollars 3350 let myDebt=myDebt+dollars 3360 return 3370 processRepay: REM 3380 let dollars=min(dollars,myCash) 3382 if dollars>myDebt then 3384 notify("Hey dude","You should not overpay the Loan Shark") 3386 return 3388 end if 3390 let myCash=myCash-dollars 3400 let myDebt=myDebt-dollars 3410 return 3420 OpenHelp: REM 3430 GetRoot().Copperfield:OpenBook("NP:4687434E") 3440 return 3500 GetSavedGame: REM 3510 gosub initGame // 3520 let f:={name:"Drugs",oth:oth,myDrugs:myDrugs, myCash:myCash, myDebt:myDebt,myBank:myBank ,myCoat:myCoat,myCount:myCount,myGuns:myGuns,myLocation:myLocation,timeLeft:timeLeft,copCount: copCount,drugPrices:drugPrices} 3530 open chan,"DopeData" 3540 if FSTAT=0 then get chan,f 3550 if fstat=0 then close chan 3555 let oth=f.oth 3560 LET myDrugs=f.myDrugs 3570 LET myCash=f.myCash 3580 LET myDebt=f.myDebt 3590 LET myBank=f.myBank 3600 LET myCoat=f.myCoat 3610 let myCount=f.myCount 3620 LET myGuns=f.myGuns 3630 LET myLocation=f.myLocation 3640 LET timeLeft=f.timeLeft 3650 LET copCount=f.copCount 3660 LET drugPrices=f.drugPrices 3670 u.layout_0.lbJet:updateText(u.layout_0.lbJet.labelCommands[myLocation]) 3690 setvalue(layout_0.lbOther,'labelCommands,clone(oth)) 3700 gosub processForm // 3710 return 3800 SaveGame: REM 3810 let f:={name:"Drugs",oth:oth,myDrugs:myDrugs, myCash:myCash, myDebt:myDebt,myBank:myBank ,myCoat:myCoat,myCount:myCount,myGuns:myGuns,myLocation:myLocation,timeLeft:timeLeft,copCount: copCount,drugPrices:drugPrices} 3820 let name="Drugs" 3830 create chan,"DopeData",name 3840 if fstat=1 then 3850 delete "DopeData" 3860 create chan,"DopeData",name 3870 end if 3880 if fstat=1 then 3890 return 3900 end if 3910 put chan,f 3920 close chan 3930 return 4000 newGame: REM 4010 gosub initGame // 4020 u.layout_0.lbJet:updateText(u.layout_0.lbJet.labelCommands[myLocation]) 4030 setvalue(layout_0.lbOther,'labelCommands,clone(oth)) 4040 gosub processForm // 4050 return 9000 endProgram: rem 9005 gosub SaveGame // 9010 hide 9020 stop